addd8199

By: Ben Ruijl <ben@ruijl.ch>

Weighted lowering tests: the forced-generic reference cancels exact zeros before keying

0b6a622e made the generic polynomial conversion drop only literal zeros
(statistical_zero_test off), for speed. The forced-generic lane is also the
exact reference that the weighted-lowering tests compare the optimized lanes
against. Three tests added by 1a173cab feed a coefficient that is an exact
but non-literal zero at base power i64::MIN:

  exact_weighted::exact_zero_cancels_before_integral_key_underflow_and_preserves_poles
  opaque_weighted::opaque_rational_identity_is_removed_before_integral_key_underflow
  opaque_weighted::opaque_repeated_denominators_preserve_coordinate_mapping_and_poles

The optimized lanes cancel the zero before checked key subtraction, so they
return zero. The literal-zero reference kept the vanishing term and erred
with IntegralPowerUnderflow. That is not a wrong value, and real keys never
reach this power.

Fix: the generic conversion keeps the statistical zero test exactly when the
generic lane is forced (FORCE_GENERIC, compiled only under cfg(test) or the
weighted-lowering-diagnostics feature). The reference then cancels exact
symbolic zeros before keying, as the lanes it checks do. In every other
build force_generic is the constant false, so production behaviour,
including the literal-zero speed-up, is unchanged. The adjacent conversion
call from 0b6a622e is rustfmt-formatted, with no code change.

Tests: the three tests pass, and cargo test -p rustred --lib scalar_numerator
gives 83 passed, 1 ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GitHub
configure