Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,11 @@ macro_rules! int_impl {
let mut base = self;
let mut acc: Self = 1;

#[safety::loop_invariant(true)]
// Inductive (`acc` starts at 1; `try_opt!` bails on overflow, so
// nonzero × nonzero stays nonzero); discharges the nonzero
// obligation in `NonZero::checked_pow`, which a `true` invariant
// cannot (loop abstraction havocs `acc`).
#[safety::loop_invariant(self == 0 || (acc != 0 && base != 0))]
loop {
if (exp & 1) == 1 {
acc = try_opt!(acc.checked_mul(base));
Expand Down
Loading
Loading