miri: fix exact_div by RalfJung · Pull Request #69126 · rust-lang/rust (original) (raw)

Turns out exact_div was relying on the broken behavior of Rem for int_min % -1 that was fixed in #69002. This PR fixes exact_div.

Inside rustc, exact_div is only used in a single place where the divisor is always positive (in ptr_offset_from), so we cannot test the fix in rustc. The Miri test suite covers this through the exact_div intrinsic, though (and it is how I found out).

One step to #69117 (then we also need to address build failures introduced by #68969)

r? @oli-obk