Description
As of #35300, two places in MIR trans look for overflowing operations used when overflow checks are off.
Such operations are then assumed not to overflow, effectively changing semantics on-the-fly.
This is done so that the functions marked #[rustc_inherit_overflow_checks]
in libcore can be used cross-crate (e.g. generics over arithmetic traits like Add
) and use the overflow checks only when enabled.
A better approach would be to run a pass on the inlined MIR itself to remove these operations.
This would let alternative backends get away without reproducing all of the logic to elide overflow checks.
There's also the possibility of distributing multiple libstd versions, one with overflow checks enabled, and one without, or build such versions on demand, but that is longer-term (cc @rust-lang/infra).
cc @rust-lang/compiler