We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b0768ce commit 60d4b9eCopy full SHA for 60d4b9e
3 files changed
library/core/src/num/int_macros.rs
@@ -1736,7 +1736,10 @@ macro_rules! int_impl {
1736
let mut base = self;
1737
let mut acc: Self = 1;
1738
1739
- #[safety::loop_invariant(true)]
+ // `self == 0` covers the primitive's own harness (e.g. `0.checked_pow(n)`, where
1740
+ // `acc` can reach 0); in the NonZero call path `self` is never 0, so it is dead
1741
+ // but harmless there. The right disjunct (`acc != 0 && base != 0`) is the inductive core.
1742
+ #[safety::loop_invariant(self == 0 || (acc != 0 && base != 0))]
1743
loop {
1744
if (exp & 1) == 1 {
1745
acc = try_opt!(acc.checked_mul(base));
0 commit comments