Make unchecked_{add,sub,mul} inherent methods unstably const
This commit is contained in:
@@ -412,12 +412,13 @@ macro_rules! int_impl {
|
||||
#[unstable(
|
||||
feature = "unchecked_math",
|
||||
reason = "niche optimization path",
|
||||
issue = "none",
|
||||
issue = "85122",
|
||||
)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
|
||||
#[inline(always)]
|
||||
pub unsafe fn unchecked_add(self, rhs: Self) -> Self {
|
||||
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for
|
||||
// `unchecked_add`.
|
||||
unsafe { intrinsics::unchecked_add(self, rhs) }
|
||||
@@ -450,12 +451,13 @@ macro_rules! int_impl {
|
||||
#[unstable(
|
||||
feature = "unchecked_math",
|
||||
reason = "niche optimization path",
|
||||
issue = "none",
|
||||
issue = "85122",
|
||||
)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
|
||||
#[inline(always)]
|
||||
pub unsafe fn unchecked_sub(self, rhs: Self) -> Self {
|
||||
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for
|
||||
// `unchecked_sub`.
|
||||
unsafe { intrinsics::unchecked_sub(self, rhs) }
|
||||
@@ -488,12 +490,13 @@ macro_rules! int_impl {
|
||||
#[unstable(
|
||||
feature = "unchecked_math",
|
||||
reason = "niche optimization path",
|
||||
issue = "none",
|
||||
issue = "85122",
|
||||
)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
|
||||
#[inline(always)]
|
||||
pub unsafe fn unchecked_mul(self, rhs: Self) -> Self {
|
||||
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for
|
||||
// `unchecked_mul`.
|
||||
unsafe { intrinsics::unchecked_mul(self, rhs) }
|
||||
|
||||
Reference in New Issue
Block a user