Skip to content

Commit

Permalink
Fix rustc type inferring bug by pinning some types
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ImmanuelSegol and str4d committed Jan 20, 2023
1 parent 7239a02 commit aae4dce
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion halo2_gadgets/src/poseidon/primitives/mds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
};
Expand Down

0 comments on commit aae4dce

Please sign in to comment.