Revise semantics and implementation of #[rustc_inherit_overflow_checks]. #35310
Labels
A-MIR
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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 likeAdd
) 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
The text was updated successfully, but these errors were encountered: