From f8a12c6311429ea9734873dc70ab1e2349ba717e Mon Sep 17 00:00:00 2001 From: AngelicosPhosphoros Date: Sat, 10 Apr 2021 18:48:10 +0300 Subject: [PATCH] Add some #[inline(always)] to arithmetic methods of integers I tried to add it only to methods which return results of intrinsics and don't have any branching. Branching could made performance of debug builds (`-Copt-level=0`) worse. Main goal of changes is allowing wider optimizations in `-Copt-level=1`. Closes: https://github.com/rust-lang/rust/issues/75598 --- library/core/src/num/int_macros.rs | 54 +++++++++---------- library/core/src/num/uint_macros.rs | 82 ++++++++++++++--------------- library/core/src/ptr/const_ptr.rs | 8 +-- library/core/src/ptr/mut_ptr.rs | 8 +-- 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 9632e64f180..608deb49a9d 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -79,7 +79,7 @@ pub fn from_str_radix(src: &str, radix: u32) -> Result { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[doc(alias = "popcount")] #[doc(alias = "popcnt")] - #[inline] + #[inline(always)] pub const fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() } /// Returns the number of zeros in the binary representation of `self`. @@ -93,7 +93,7 @@ pub const fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() } /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn count_zeros(self) -> u32 { (!self).count_ones() } @@ -111,7 +111,7 @@ pub const fn count_zeros(self) -> u32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn leading_zeros(self) -> u32 { (self as $UnsignedT).leading_zeros() } @@ -129,7 +129,7 @@ pub const fn leading_zeros(self) -> u32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn trailing_zeros(self) -> u32 { (self as $UnsignedT).trailing_zeros() } @@ -147,7 +147,7 @@ pub const fn trailing_zeros(self) -> u32 { /// ``` #[stable(feature = "leading_trailing_ones", since = "1.46.0")] #[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")] - #[inline] + #[inline(always)] pub const fn leading_ones(self) -> u32 { (self as $UnsignedT).leading_ones() } @@ -165,7 +165,7 @@ pub const fn leading_ones(self) -> u32 { /// ``` #[stable(feature = "leading_trailing_ones", since = "1.46.0")] #[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")] - #[inline] + #[inline(always)] pub const fn trailing_ones(self) -> u32 { (self as $UnsignedT).trailing_ones() } @@ -189,7 +189,7 @@ pub const fn trailing_ones(self) -> u32 { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn rotate_left(self, n: u32) -> Self { (self as $UnsignedT).rotate_left(n) as Self } @@ -214,7 +214,7 @@ pub const fn rotate_left(self, n: u32) -> Self { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn rotate_right(self, n: u32) -> Self { (self as $UnsignedT).rotate_right(n) as Self } @@ -234,7 +234,7 @@ pub const fn rotate_right(self, n: u32) -> Self { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn swap_bytes(self) -> Self { (self as $UnsignedT).swap_bytes() as Self } @@ -255,7 +255,7 @@ pub const fn swap_bytes(self) -> Self { /// ``` #[stable(feature = "reverse_bits", since = "1.37.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] - #[inline] + #[inline(always)] #[must_use] pub const fn reverse_bits(self) -> Self { (self as $UnsignedT).reverse_bits() as Self @@ -416,7 +416,7 @@ pub const fn checked_add(self, rhs: Self) -> Option { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub unsafe fn unchecked_add(self, rhs: Self) -> Self { // SAFETY: the caller must uphold the safety contract for // `unchecked_add`. @@ -454,7 +454,7 @@ pub const fn checked_sub(self, rhs: Self) -> Option { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub unsafe fn unchecked_sub(self, rhs: Self) -> Self { // SAFETY: the caller must uphold the safety contract for // `unchecked_sub`. @@ -492,7 +492,7 @@ pub const fn checked_mul(self, rhs: Self) -> Option { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub unsafe fn unchecked_mul(self, rhs: Self) -> Self { // SAFETY: the caller must uphold the safety contract for // `unchecked_mul`. @@ -741,7 +741,7 @@ pub const fn checked_pow(self, mut exp: u32) -> Option { #[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn saturating_add(self, rhs: Self) -> Self { intrinsics::saturating_add(self, rhs) } @@ -762,7 +762,7 @@ pub const fn saturating_add(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn saturating_sub(self, rhs: Self) -> Self { intrinsics::saturating_sub(self, rhs) } @@ -783,7 +783,7 @@ pub const fn saturating_sub(self, rhs: Self) -> Self { #[stable(feature = "saturating_neg", since = "1.45.0")] #[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")] - #[inline] + #[inline(always)] pub const fn saturating_neg(self) -> Self { intrinsics::saturating_sub(0, self) } @@ -883,7 +883,7 @@ pub const fn saturating_pow(self, exp: u32) -> Self { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_add(self, rhs: Self) -> Self { intrinsics::wrapping_add(self, rhs) } @@ -903,7 +903,7 @@ pub const fn wrapping_add(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_sub(self, rhs: Self) -> Self { intrinsics::wrapping_sub(self, rhs) } @@ -923,7 +923,7 @@ pub const fn wrapping_sub(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_mul(self, rhs: Self) -> Self { intrinsics::wrapping_mul(self, rhs) } @@ -1081,7 +1081,7 @@ pub const fn wrapping_neg(self) -> Self { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_shl(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -1110,7 +1110,7 @@ pub const fn wrapping_shl(self, rhs: u32) -> Self { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_shr(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -1225,7 +1225,7 @@ pub const fn wrapping_pow(self, mut exp: u32) -> Self { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::add_with_overflow(self as $ActualT, rhs as $ActualT); (a as Self, b) @@ -1249,7 +1249,7 @@ pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::sub_with_overflow(self as $ActualT, rhs as $ActualT); (a as Self, b) @@ -1272,7 +1272,7 @@ pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::mul_with_overflow(self as $ActualT, rhs as $ActualT); (a as Self, b) @@ -1725,7 +1725,7 @@ pub const fn abs(self) -> Self { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_sign", since = "1.47.0")] - #[inline] + #[inline(always)] pub const fn signum(self) -> Self { match self { n if n > 0 => 1, @@ -1747,7 +1747,7 @@ pub const fn signum(self) -> Self { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn is_positive(self) -> bool { self > 0 } /// Returns `true` if `self` is negative and `false` if the number is zero or @@ -1763,7 +1763,7 @@ pub const fn is_positive(self) -> bool { self > 0 } /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn is_negative(self) -> bool { self < 0 } /// Return the memory representation of this integer as a byte array in diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 62d539b96c3..46638ea4463 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -79,7 +79,7 @@ pub fn from_str_radix(src: &str, radix: u32) -> Result { #[rustc_const_stable(feature = "const_math", since = "1.32.0")] #[doc(alias = "popcount")] #[doc(alias = "popcnt")] - #[inline] + #[inline(always)] pub const fn count_ones(self) -> u32 { intrinsics::ctpop(self as $ActualT) as u32 } @@ -95,7 +95,7 @@ pub const fn count_ones(self) -> u32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn count_zeros(self) -> u32 { (!self).count_ones() } @@ -113,7 +113,7 @@ pub const fn count_zeros(self) -> u32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn leading_zeros(self) -> u32 { intrinsics::ctlz(self as $ActualT) as u32 } @@ -132,7 +132,7 @@ pub const fn leading_zeros(self) -> u32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn trailing_zeros(self) -> u32 { intrinsics::cttz(self) as u32 } @@ -150,7 +150,7 @@ pub const fn trailing_zeros(self) -> u32 { /// ``` #[stable(feature = "leading_trailing_ones", since = "1.46.0")] #[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")] - #[inline] + #[inline(always)] pub const fn leading_ones(self) -> u32 { (!self).leading_zeros() } @@ -169,7 +169,7 @@ pub const fn leading_ones(self) -> u32 { /// ``` #[stable(feature = "leading_trailing_ones", since = "1.46.0")] #[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")] - #[inline] + #[inline(always)] pub const fn trailing_ones(self) -> u32 { (!self).trailing_zeros() } @@ -193,7 +193,7 @@ pub const fn trailing_ones(self) -> u32 { #[rustc_const_stable(feature = "const_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn rotate_left(self, n: u32) -> Self { intrinsics::rotate_left(self, n as $SelfT) } @@ -218,7 +218,7 @@ pub const fn rotate_left(self, n: u32) -> Self { #[rustc_const_stable(feature = "const_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn rotate_right(self, n: u32) -> Self { intrinsics::rotate_right(self, n as $SelfT) } @@ -237,7 +237,7 @@ pub const fn rotate_right(self, n: u32) -> Self { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn swap_bytes(self) -> Self { intrinsics::bswap(self as $ActualT) as Self } @@ -258,7 +258,7 @@ pub const fn swap_bytes(self) -> Self { /// ``` #[stable(feature = "reverse_bits", since = "1.37.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] #[must_use] pub const fn reverse_bits(self) -> Self { intrinsics::bitreverse(self as $ActualT) as Self @@ -284,7 +284,7 @@ pub const fn reverse_bits(self) -> Self { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn from_be(x: Self) -> Self { #[cfg(target_endian = "big")] { @@ -316,7 +316,7 @@ pub const fn from_be(x: Self) -> Self { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn from_le(x: Self) -> Self { #[cfg(target_endian = "little")] { @@ -348,7 +348,7 @@ pub const fn from_le(x: Self) -> Self { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn to_be(self) -> Self { // or not to be? #[cfg(target_endian = "big")] { @@ -380,7 +380,7 @@ pub const fn to_be(self) -> Self { // or not to be? /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn to_le(self) -> Self { #[cfg(target_endian = "little")] { @@ -426,7 +426,7 @@ pub const fn checked_add(self, rhs: Self) -> Option { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub unsafe fn unchecked_add(self, rhs: Self) -> Self { // SAFETY: the caller must uphold the safety contract for // `unchecked_add`. @@ -464,7 +464,7 @@ pub const fn checked_sub(self, rhs: Self) -> Option { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub unsafe fn unchecked_sub(self, rhs: Self) -> Self { // SAFETY: the caller must uphold the safety contract for // `unchecked_sub`. @@ -502,7 +502,7 @@ pub const fn checked_mul(self, rhs: Self) -> Option { )] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub unsafe fn unchecked_mul(self, rhs: Self) -> Self { // SAFETY: the caller must uphold the safety contract for // `unchecked_mul`. @@ -727,7 +727,7 @@ pub const fn checked_pow(self, mut exp: u32) -> Option { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")] - #[inline] + #[inline(always)] pub const fn saturating_add(self, rhs: Self) -> Self { intrinsics::saturating_add(self, rhs) } @@ -747,7 +747,7 @@ pub const fn saturating_add(self, rhs: Self) -> Self { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")] - #[inline] + #[inline(always)] pub const fn saturating_sub(self, rhs: Self) -> Self { intrinsics::saturating_sub(self, rhs) } @@ -813,7 +813,7 @@ pub const fn saturating_pow(self, exp: u32) -> Self { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_add(self, rhs: Self) -> Self { intrinsics::wrapping_add(self, rhs) } @@ -833,7 +833,7 @@ pub const fn wrapping_add(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_sub(self, rhs: Self) -> Self { intrinsics::wrapping_sub(self, rhs) } @@ -856,7 +856,7 @@ pub const fn wrapping_sub(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_mul(self, rhs: Self) -> Self { intrinsics::wrapping_mul(self, rhs) } @@ -878,7 +878,7 @@ pub const fn wrapping_mul(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_div(self, rhs: Self) -> Self { self / rhs } @@ -903,7 +903,7 @@ pub const fn wrapping_div(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_div_euclid(self, rhs: Self) -> Self { self / rhs } @@ -926,7 +926,7 @@ pub const fn wrapping_div_euclid(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_rem(self, rhs: Self) -> Self { self % rhs } @@ -952,7 +952,7 @@ pub const fn wrapping_rem(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self { self % rhs } @@ -1008,7 +1008,7 @@ pub const fn wrapping_neg(self) -> Self { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_shl(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -1040,7 +1040,7 @@ pub const fn wrapping_shl(self, rhs: u32) -> Self { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn wrapping_shr(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds @@ -1106,7 +1106,7 @@ pub const fn wrapping_pow(self, mut exp: u32) -> Self { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::add_with_overflow(self as $ActualT, rhs as $ActualT); (a as Self, b) @@ -1131,7 +1131,7 @@ pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::sub_with_overflow(self as $ActualT, rhs as $ActualT); (a as Self, b) @@ -1158,7 +1158,7 @@ pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::mul_with_overflow(self as $ActualT, rhs as $ActualT); (a as Self, b) @@ -1182,7 +1182,7 @@ pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) { /// ``` #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_div(2), (2, false));")] /// ``` - #[inline] + #[inline(always)] #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ @@ -1212,7 +1212,7 @@ pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) { /// ``` #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_div_euclid(2), (2, false));")] /// ``` - #[inline] + #[inline(always)] #[stable(feature = "euclidean_division", since = "1.38.0")] #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ @@ -1239,7 +1239,7 @@ pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) { /// ``` #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_rem(2), (1, false));")] /// ``` - #[inline] + #[inline(always)] #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ @@ -1269,7 +1269,7 @@ pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) { /// ``` #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false));")] /// ``` - #[inline] + #[inline(always)] #[stable(feature = "euclidean_division", since = "1.38.0")] #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ @@ -1293,7 +1293,7 @@ pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) { #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".overflowing_neg(), (0, false));")] #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".overflowing_neg(), (-2i32 as ", stringify!($SelfT), ", true));")] /// ``` - #[inline] + #[inline(always)] #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] pub const fn overflowing_neg(self) -> (Self, bool) { @@ -1320,7 +1320,7 @@ pub const fn overflowing_neg(self) -> (Self, bool) { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool) { (self.wrapping_shl(rhs), (rhs > ($BITS - 1))) } @@ -1345,7 +1345,7 @@ pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool) { #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool) { (self.wrapping_shr(rhs), (rhs > ($BITS - 1))) } @@ -1458,7 +1458,7 @@ pub const fn pow(self, mut exp: u32) -> Self { #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] pub const fn div_euclid(self, rhs: Self) -> Self { self / rhs @@ -1486,7 +1486,7 @@ pub const fn div_euclid(self, rhs: Self) -> Self { #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.52.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] pub const fn rem_euclid(self, rhs: Self) -> Self { self % rhs @@ -1504,7 +1504,7 @@ pub const fn rem_euclid(self, rhs: Self) -> Self { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_is_power_of_two", since = "1.32.0")] - #[inline] + #[inline(always)] pub const fn is_power_of_two(self) -> bool { self.count_ones() == 1 } diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index f18387d020d..def98f4b37b 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -226,7 +226,7 @@ pub unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit> #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] - #[inline] + #[inline(always)] pub const unsafe fn offset(self, count: isize) -> *const T where T: Sized, @@ -288,7 +288,7 @@ pub unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit> #[stable(feature = "ptr_wrapping_offset", since = "1.16.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] - #[inline] + #[inline(always)] pub const fn wrapping_offset(self, count: isize) -> *const T where T: Sized, @@ -507,7 +507,7 @@ pub const fn guaranteed_ne(self, other: *const T) -> bool #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] - #[inline] + #[inline(always)] pub const unsafe fn add(self, count: usize) -> Self where T: Sized, @@ -634,7 +634,7 @@ pub const fn guaranteed_ne(self, other: *const T) -> bool #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] - #[inline] + #[inline(always)] pub const fn wrapping_add(self, count: usize) -> Self where T: Sized, diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 3c6f1978283..dbb8a873186 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -231,7 +231,7 @@ pub unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit> #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] - #[inline] + #[inline(always)] pub const unsafe fn offset(self, count: isize) -> *mut T where T: Sized, @@ -294,7 +294,7 @@ pub unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit> #[stable(feature = "ptr_wrapping_offset", since = "1.16.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] - #[inline] + #[inline(always)] pub const fn wrapping_offset(self, count: isize) -> *mut T where T: Sized, @@ -613,7 +613,7 @@ pub const fn guaranteed_eq(self, other: *mut T) -> bool #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] - #[inline] + #[inline(always)] pub const unsafe fn add(self, count: usize) -> Self where T: Sized, @@ -740,7 +740,7 @@ pub const fn guaranteed_eq(self, other: *mut T) -> bool #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] - #[inline] + #[inline(always)] pub const fn wrapping_add(self, count: usize) -> Self where T: Sized, -- 2.44.0