Skip to content

Commit 9d96d1f

Browse files
Centri3NCGThompson
authored andcommitted
Fix overflow check
1 parent a0880a3 commit 9d96d1f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

library/core/src/num/int_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ macro_rules! int_impl {
21022102
power_used * exp;
21032103
let (num_shl, overflowed) = power_used.overflowing_mul(exp);
21042104
let fine = !overflowed
2105-
& (power_used < (mem::size_of::<Self>() * 8) as u32);
2105+
& (num_shl < (mem::size_of::<Self>() * 8) as u32);
21062106
(1 << num_shl) * fine as Self
21072107
} else {
21082108
if exp == 0 {

library/core/src/num/uint_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,7 @@ macro_rules! uint_impl {
19991999
power_used * exp;
20002000
let (num_shl, overflowed) = power_used.overflowing_mul(exp);
20012001
let fine = !overflowed
2002-
& (power_used < (mem::size_of::<Self>() * 8) as u32);
2002+
& (num_shl < (mem::size_of::<Self>() * 8) as u32);
20032003
(1 << num_shl) * fine as Self
20042004
} else {
20052005
if exp == 0 {

0 commit comments

Comments
 (0)