about summary refs log tree commit diff
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2017-11-04 17:10:51 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2017-11-04 17:10:51 -0700
commit0d745af29a7566538277bd7a3b16faf09df7fe63 (patch)
treeaeb405ec46f8815bd19c2bec368c52f6dcb197cf
parent1b19e643244ab71a0842ee502d7ca7d8aa705209 (diff)
downloadrust-0d745af29a7566538277bd7a3b16faf09df7fe63.tar.gz
rust-0d745af29a7566538277bd7a3b16faf09df7fe63.zip
Use Add::add for overflow checks instead of [rustc_inherit_overflow_checks]
-rw-r--r--src/libcore/num/mod.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 914b3762d80..a50779bedfd 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -15,6 +15,7 @@
 use convert::{Infallible, TryFrom};
 use fmt;
 use intrinsics;
+use ops;
 use str::FromStr;
 
 /// Provides intentionally-wrapped arithmetic on `T`.
@@ -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