Skip to content

Commit c981d67

Browse files
[!] Use rustc_inherit_overflow_checks in next_power_of_two
I believe the previous code was calling `ops::Add::add` instead of the `+` operator to get this behavior.
1 parent a29424a commit c981d67

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libcore/num/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::convert::Infallible;
88
use crate::fmt;
99
use crate::intrinsics;
1010
use crate::mem;
11-
use crate::ops;
1211
use crate::str::FromStr;
1312

1413
macro_rules! impl_nonzero_fmt {
@@ -4042,9 +4041,9 @@ assert_eq!(3", stringify!($SelfT), ".next_power_of_two(), 4);", $EndFeature, "
40424041
```"),
40434042
#[stable(feature = "rust1", since = "1.0.0")]
40444043
#[inline]
4044+
#[rustc_inherit_overflow_checks]
40454045
pub fn next_power_of_two(self) -> Self {
4046-
// Call the trait to get overflow checks
4047-
ops::Add::add(self.one_less_than_next_power_of_two(), 1)
4046+
self.one_less_than_next_power_of_two() + 1
40484047
}
40494048
}
40504049

0 commit comments

Comments
 (0)