diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2018-12-31 04:11:46 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2018-12-31 04:11:46 +0100 |
| commit | 50152d24ca09e80e8bf9314b3b7864d3bdfb9a16 (patch) | |
| tree | 6a7f4c868301fb1273a10e499ed003cfa9b92b26 /src/libcore | |
| parent | fedfb61f266cf1a5e8339552745a74edbe22f428 (diff) | |
| download | rust-50152d24ca09e80e8bf9314b3b7864d3bdfb9a16.tar.gz rust-50152d24ca09e80e8bf9314b3b7864d3bdfb9a16.zip | |
now that some intrisics are safe, use that fact.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/num/mod.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 23db3188005..7f087532e8b 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! { |
