From 50152d24ca09e80e8bf9314b3b7864d3bdfb9a16 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 31 Dec 2018 04:11:46 +0100 Subject: [PATCH] now that some intrisics are safe, use that fact. --- src/libcore/num/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 23db318800508..7f087532e8b3b 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -997,9 +997,12 @@ $EndFeature, " #[cfg_attr(stage0, rustc_const_unstable(feature = "const_int_wrapping"))] #[inline] pub const fn wrapping_add(self, rhs: Self) -> Self { + #[cfg(stage0)] unsafe { intrinsics::overflowing_add(self, rhs) } + #[cfg(not(stage0))] + intrinsics::overflowing_add(self, rhs) } } @@ -1021,9 +1024,12 @@ $EndFeature, " #[cfg_attr(stage0, rustc_const_unstable(feature = "const_int_wrapping"))] #[inline] pub const fn wrapping_sub(self, rhs: Self) -> Self { + #[cfg(stage0)] unsafe { intrinsics::overflowing_sub(self, rhs) } + #[cfg(not(stage0))] + intrinsics::overflowing_sub(self, rhs) } } @@ -1044,9 +1050,12 @@ $EndFeature, " #[cfg_attr(stage0, rustc_const_unstable(feature = "const_int_wrapping"))] #[inline] pub const fn wrapping_mul(self, rhs: Self) -> Self { + #[cfg(stage0)] unsafe { intrinsics::overflowing_mul(self, rhs) } + #[cfg(not(stage0))] + intrinsics::overflowing_mul(self, rhs) } } @@ -2311,7 +2320,10 @@ assert_eq!(n.rotate_left(", $rot, "), m); #[cfg_attr(stage0, rustc_const_unstable(feature = "const_int_rotate"))] #[inline] pub const fn rotate_left(self, n: u32) -> Self { + #[cfg(stage0)] unsafe { intrinsics::rotate_left(self, n as $SelfT) } + #[cfg(not(stage0))] + intrinsics::rotate_left(self, n as $SelfT) } } @@ -2336,7 +2348,10 @@ assert_eq!(n.rotate_right(", $rot, "), m); #[cfg_attr(stage0, rustc_const_unstable(feature = "const_int_rotate"))] #[inline] pub const fn rotate_right(self, n: u32) -> Self { + #[cfg(stage0)] unsafe { intrinsics::rotate_right(self, n as $SelfT) } + #[cfg(not(stage0))] + intrinsics::rotate_right(self, n as $SelfT) } } @@ -2885,9 +2900,12 @@ $EndFeature, " #[cfg_attr(stage0, rustc_const_unstable(feature = "const_int_wrapping"))] #[inline] pub const fn wrapping_add(self, rhs: Self) -> Self { + #[cfg(stage0)] unsafe { intrinsics::overflowing_add(self, rhs) } + #[cfg(not(stage0))] + intrinsics::overflowing_add(self, rhs) } } @@ -2908,9 +2926,12 @@ $EndFeature, " #[cfg_attr(stage0, rustc_const_unstable(feature = "const_int_wrapping"))] #[inline] pub const fn wrapping_sub(self, rhs: Self) -> Self { + #[cfg(stage0)] unsafe { intrinsics::overflowing_sub(self, rhs) } + #[cfg(not(stage0))] + intrinsics::overflowing_sub(self, rhs) } } @@ -2932,9 +2953,12 @@ $EndFeature, " #[cfg_attr(stage0, rustc_const_unstable(feature = "const_int_wrapping"))] #[inline] pub const fn wrapping_mul(self, rhs: Self) -> Self { + #[cfg(stage0)] unsafe { intrinsics::overflowing_mul(self, rhs) } + #[cfg(not(stage0))] + intrinsics::overflowing_mul(self, rhs) } doc_comment! {