Skip to content

Commit

Permalink
Use Add::add for overflow checks instead of [rustc_inherit_overflow_c…
Browse files Browse the repository at this point in the history
…hecks]
  • Loading branch information
scottmcm committed Nov 5, 2017
1 parent 1b19e64 commit 0d745af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libcore/num/mod.rs
Expand Up @@ -15,6 +15,7 @@
use convert::{Infallible, TryFrom};
use fmt;
use intrinsics;
use ops;
use str::FromStr;

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

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

0 comments on commit 0d745af

Please sign in to comment.