Fix rustc type inferring bug by pinning some types

This has been occurring spuriously during development for a while, but
only when other compilation issues were present. However, now that it
also occurs when using wasm-pack, we are fixing it.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
This commit is contained in:
ImmanuelSegol 2023-01-19 23:51:56 +00:00 committed by Jack Grigg
parent 7239a02ea3
commit aae4dce533
1 changed files with 6 additions and 1 deletions

View File

@ -81,8 +81,13 @@ pub(super) fn generate_mds<F: FromUniformBytes<64> + Ord, const T: usize>(
if m == j {
acc
} else {
// We hard-code the type, to avoid spurious "cannot infer type" rustc errors.
let denominator: F = x_j - x_m;
// We can invert freely; by construction, the elements of xs are distinct.
acc * (x - x_m) * (x_j - x_m).invert().unwrap()
let denominator_inverted: F = denominator.invert().unwrap();
acc * (x - x_m) * denominator_inverted
}
})
};