Per-module control of overflow checks? #70358
Labels
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
For arithmetic that happens inside Miri, I am quite paranoid that we may have an overflow issue, so I spent a lot of time last week-end to go over every occurrence of
+
/-
/*
and replace them all bychecked_*
operations. That has not made code more readable, and I am worried I might have missed some cases.I am not sure if enabling overflow checks for all of rustc is realistic, so it would be great if that could be controlled on a per-module level: if I could set something like
#![enable_overflow_checks]
in the interpreter modules, I could sleep much more soundly as I would be sure we'd not have silently overflowing arithmetic -- and I wouldn't have to make the code unreadable by turning(x * 2) + 1
intox.checked_mul(2).unwrap().checked_add(1).unwrap()
.Overflow checks are embedded into MIR, and it seems entirely possible to take module-level attributes into account during MIR building, so I think this is realistic.
(I am not sure if this should go into this repo or the RFC repo, feel free to move around.)
The text was updated successfully, but these errors were encountered: