Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stablilize const_int_{rotate,wrapping,sign} #57105

Closed
wants to merge 9 commits into from
24 changes: 24 additions & 0 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
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))]
Centril marked this conversation as resolved.
Show resolved Hide resolved
intrinsics::overflowing_mul(self, rhs)
}

doc_comment! {
Expand Down