From aae4dce533900b5473aea85722d42f9afd1abf42 Mon Sep 17 00:00:00 2001 From: ImmanuelSegol <3ditds@gmail.com> Date: Thu, 19 Jan 2023 23:51:56 +0000 Subject: [PATCH] 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 --- halo2_gadgets/src/poseidon/primitives/mds.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/halo2_gadgets/src/poseidon/primitives/mds.rs b/halo2_gadgets/src/poseidon/primitives/mds.rs index 45718731..bc633478 100644 --- a/halo2_gadgets/src/poseidon/primitives/mds.rs +++ b/halo2_gadgets/src/poseidon/primitives/mds.rs @@ -81,8 +81,13 @@ pub(super) fn generate_mds + 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 } }) };