Skip to content

Commit 0d745af

Browse files
committed
Use Add::add for overflow checks instead of [rustc_inherit_overflow_checks]
1 parent 1b19e64 commit 0d745af

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libcore/num/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use convert::{Infallible, TryFrom};
1616
use fmt;
1717
use intrinsics;
18+
use ops;
1819
use str::FromStr;
1920

2021
/// Provides intentionally-wrapped arithmetic on `T`.
@@ -2222,9 +2223,9 @@ macro_rules! uint_impl {
22222223
/// ```
22232224
#[stable(feature = "rust1", since = "1.0.0")]
22242225
#[inline]
2225-
#[rustc_inherit_overflow_checks]
22262226
pub fn next_power_of_two(self) -> Self {
2227-
self.one_less_than_next_power_of_two() + 1
2227+
// Call the trait to get overflow checks
2228+
ops::Add::add(self.one_less_than_next_power_of_two(), 1)
22282229
}
22292230

22302231
/// Returns the smallest power of two greater than or equal to `n`. If

0 commit comments

Comments
 (0)