Skip to content

Commit

Permalink
now that some intrisics are safe, use that fact.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Dec 31, 2018
1 parent fedfb61 commit 50152d2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/libcore/num/mod.rs
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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! {
Expand Down

0 comments on commit 50152d2

Please sign in to comment.