about summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-14 10:21:32 +0000
committerbors <bors@rust-lang.org>2019-12-14 10:21:32 +0000
commitc8ea4ace9213ae045123fdfeb59d1ac887656d31 (patch)
tree2a7d207294b6f2c99d1ddbe193b1d5af8ee46a09 /src/libcore/num
parent12307b3b08edee543a78fb9d4a837fbd6d6ac0fa (diff)
parent0b47ba7019adf06f6687a8c94040e63ae1ea4fba (diff)
downloadrust-c8ea4ace9213ae045123fdfeb59d1ac887656d31.tar.gz
rust-c8ea4ace9213ae045123fdfeb59d1ac887656d31.zip
Auto merge of #67136 - oli-obk:const_stability, r=Centril
Require stable/unstable annotations for the constness of all stable fns with a const modifier

r? @RalfJung @Centril

Every `#[stable]` const fn now needs either a `#[rustc_const_unstable]` attribute or a `#[rustc_const_stable]` attribute. You can't silently stabilize the constness of a function anymore.
Diffstat (limited to 'src/libcore/num')
-rw-r--r--src/libcore/num/mod.rs342
-rw-r--r--src/libcore/num/wrapping.rs4
2 files changed, 329 insertions, 17 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index d1f518d52dd..5a97aa4acfa 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -60,6 +60,10 @@ assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", s
                 ///
                 /// The value must not be zero.
                 #[$stability]
+                #[cfg_attr(
+                    not(bootstrap),
+                    rustc_const_stable(feature = "nonzero", since = "1.34.0"),
+                )]
                 #[inline]
                 pub const unsafe fn new_unchecked(n: $Int) -> Self {
                     $Ty(n)
@@ -80,6 +84,10 @@ assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", s
                 /// Returns the value as a primitive type.
                 #[$stability]
                 #[inline]
+                #[cfg_attr(
+                    not(bootstrap),
+                    rustc_const_stable(feature = "nonzero", since = "1.34.0"),
+                )]
                 pub const fn get(self) -> $Int {
                     self.0
                 }
@@ -255,6 +263,10 @@ $EndFeature, "
             #[stable(feature = "rust1", since = "1.0.0")]
             #[inline(always)]
             #[rustc_promotable]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_min_value", since = "1.32.0"),
+            )]
             pub const fn min_value() -> Self {
                 !0 ^ ((!0 as $UnsignedT) >> 1) as Self
             }
@@ -274,6 +286,10 @@ $EndFeature, "
             #[stable(feature = "rust1", since = "1.0.0")]
             #[inline(always)]
             #[rustc_promotable]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_max_value", since = "1.32.0"),
+            )]
             pub const fn max_value() -> Self {
                 !Self::min_value()
             }
@@ -323,6 +339,10 @@ $EndFeature, "
 ```
 "),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() }
         }
@@ -338,6 +358,10 @@ Basic usage:
 ", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 1);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn count_zeros(self) -> u32 {
                 (!self).count_ones()
@@ -358,6 +382,10 @@ assert_eq!(n.leading_zeros(), 0);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn leading_zeros(self) -> u32 {
                 (self as $UnsignedT).leading_zeros()
@@ -378,6 +406,10 @@ assert_eq!(n.trailing_zeros(), 2);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn trailing_zeros(self) -> u32 {
                 (self as $UnsignedT).trailing_zeros()
@@ -401,6 +433,10 @@ let m = ", $rot_result, ";
 assert_eq!(n.rotate_left(", $rot, "), m);
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -427,6 +463,10 @@ let m = ", $rot_op, ";
 assert_eq!(n.rotate_right(", $rot, "), m);
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -450,6 +490,10 @@ let m = n.swap_bytes();
 assert_eq!(m, ", $swapped, ");
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn swap_bytes(self) -> Self {
                 (self as $UnsignedT).swap_bytes() as Self
@@ -470,6 +514,10 @@ let m = n.reverse_bits();
 assert_eq!(m, ", $reversed, ");
 ```"),
             #[stable(feature = "reverse_bits", since = "1.37.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             #[must_use]
             pub const fn reverse_bits(self) -> Self {
@@ -497,6 +545,10 @@ if cfg!(target_endian = \"big\") {
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_conversions", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn from_be(x: Self) -> Self {
                 #[cfg(target_endian = "big")]
@@ -530,6 +582,10 @@ if cfg!(target_endian = \"little\") {
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_conversions", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn from_le(x: Self) -> Self {
                 #[cfg(target_endian = "little")]
@@ -563,6 +619,10 @@ if cfg!(target_endian = \"big\") {
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_conversions", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn to_be(self) -> Self { // or not to be?
                 #[cfg(target_endian = "big")]
@@ -596,6 +656,10 @@ if cfg!(target_endian = \"little\") {
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_conversions", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn to_le(self) -> Self {
                 #[cfg(target_endian = "little")]
@@ -948,7 +1012,11 @@ $EndFeature, "
 ```"),
 
             #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_const_unstable(feature = "const_saturating_int_methods")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_saturating_int_methods"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718"),
+            )]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
             #[inline]
@@ -974,7 +1042,11 @@ assert_eq!(", stringify!($SelfT), "::max_value().saturating_sub(-1), ", stringif
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_const_unstable(feature = "const_saturating_int_methods")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_saturating_int_methods"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718"),
+            )]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
             #[inline]
@@ -1114,6 +1186,10 @@ assert_eq!(", stringify!($SelfT), "::max_value().wrapping_add(2), ", stringify!(
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1137,6 +1213,10 @@ stringify!($SelfT), "::max_value());",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1159,6 +1239,10 @@ assert_eq!(11i8.wrapping_mul(12), -124);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1303,6 +1387,10 @@ assert_eq!(", stringify!($SelfT), "::min_value().wrapping_neg(), ", stringify!($
 $EndFeature, "
 ```"),
             #[stable(feature = "num_wrapping", since = "1.2.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn wrapping_neg(self) -> Self {
                 self.overflowing_neg().0
@@ -1328,6 +1416,10 @@ assert_eq!((-1", stringify!($SelfT), ").wrapping_shl(128), -1);",
 $EndFeature, "
 ```"),
             #[stable(feature = "num_wrapping", since = "1.2.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1359,6 +1451,10 @@ assert_eq!((-128i16).wrapping_shr(64), -128);",
 $EndFeature, "
 ```"),
             #[stable(feature = "num_wrapping", since = "1.2.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1392,6 +1488,10 @@ assert_eq!((-128i8).wrapping_abs() as u8, 128);",
 $EndFeature, "
 ```"),
             #[stable(feature = "no_panic_abs", since = "1.13.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn wrapping_abs(self) -> Self {
                 // sign is -1 (all ones) for negative numbers, 0 otherwise.
@@ -1466,6 +1566,10 @@ assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (", stringify!($Sel
 "::MIN, true));", $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1493,6 +1597,10 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_sub(1), (", stringify!($Sel
 "::MAX, true));", $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1518,6 +1626,10 @@ assert_eq!(1_000_000_000i32.overflowing_mul(10), (1410065408, true));",
 $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1685,6 +1797,10 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
 ```"),
             #[inline]
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             pub const fn overflowing_neg(self) -> (Self, bool) {
                 ((!self).wrapping_add(1), self == Self::min_value())
             }
@@ -1707,6 +1823,10 @@ assert_eq!(0x1i32.overflowing_shl(36), (0x10, true));",
 $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1732,6 +1852,10 @@ assert_eq!(0x10i32.overflowing_shr(36), (0x1, true));",
 $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -1760,6 +1884,10 @@ assert_eq!((", stringify!($SelfT), "::min_value()).overflowing_abs(), (", string
 $EndFeature, "
 ```"),
             #[stable(feature = "no_panic_abs", since = "1.13.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn overflowing_abs(self) -> (Self, bool) {
                 (self.wrapping_abs(), self == Self::min_value())
@@ -1964,6 +2092,10 @@ assert_eq!((-10", stringify!($SelfT), ").abs(), 10);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             #[rustc_inherit_overflow_checks]
             pub const fn abs(self) -> Self {
@@ -2006,7 +2138,11 @@ assert_eq!((-10", stringify!($SelfT), ").signum(), -1);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_const_unstable(feature = "const_int_sign")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_sign"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_sign", issue = "53718"),
+            )]
             #[inline]
             pub const fn signum(self) -> Self {
                 (self > 0) as Self - (self < 0) as Self
@@ -2027,6 +2163,10 @@ assert!(!(-10", stringify!($SelfT), ").is_positive());",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn is_positive(self) -> bool { self > 0 }
         }
@@ -2045,6 +2185,10 @@ assert!(!10", stringify!($SelfT), ".is_negative());",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_int_methods", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn is_negative(self) -> bool { self < 0 }
         }
@@ -2062,7 +2206,11 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
 assert_eq!(bytes, ", $be_bytes, ");
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
                 self.to_be().to_ne_bytes()
@@ -2082,7 +2230,11 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
 assert_eq!(bytes, ", $le_bytes, ");
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
                 self.to_le().to_ne_bytes()
@@ -2117,7 +2269,11 @@ assert_eq!(
 );
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
                 // SAFETY: integers are plain old datatypes so we can always transmute them to
@@ -2151,7 +2307,11 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
 }
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
                 Self::from_be(Self::from_ne_bytes(bytes))
@@ -2184,7 +2344,11 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
 }
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
                 Self::from_le(Self::from_ne_bytes(bytes))
@@ -2227,7 +2391,11 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
 }
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
                 // SAFETY: integers are plain old datatypes so we can always transmute to them
@@ -2321,6 +2489,10 @@ Basic usage:
             #[stable(feature = "rust1", since = "1.0.0")]
             #[rustc_promotable]
             #[inline(always)]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_min_value", since = "1.32.0"),
+            )]
             pub const fn min_value() -> Self { 0 }
         }
 
@@ -2338,6 +2510,10 @@ stringify!($MaxV), ");", $EndFeature, "
             #[stable(feature = "rust1", since = "1.0.0")]
             #[rustc_promotable]
             #[inline(always)]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_max_value", since = "1.32.0"),
+            )]
             pub const fn max_value() -> Self { !0 }
         }
 
@@ -2384,6 +2560,10 @@ Basic usage:
 assert_eq!(n.count_ones(), 3);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn count_ones(self) -> u32 {
                 intrinsics::ctpop(self as $ActualT) as u32
@@ -2401,6 +2581,10 @@ Basic usage:
 ", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 0);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn count_zeros(self) -> u32 {
                 (!self).count_ones()
@@ -2420,6 +2604,10 @@ Basic usage:
 assert_eq!(n.leading_zeros(), 2);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn leading_zeros(self) -> u32 {
                 intrinsics::ctlz(self as $ActualT) as u32
@@ -2440,6 +2628,10 @@ Basic usage:
 assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn trailing_zeros(self) -> u32 {
                 intrinsics::cttz(self) as u32
@@ -2463,6 +2655,10 @@ let m = ", $rot_result, ";
 assert_eq!(n.rotate_left(", $rot, "), m);
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
             #[inline]
@@ -2489,6 +2685,10 @@ let m = ", $rot_op, ";
 assert_eq!(n.rotate_right(", $rot, "), m);
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
             #[inline]
@@ -2512,6 +2712,10 @@ let m = n.swap_bytes();
 assert_eq!(m, ", $swapped, ");
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn swap_bytes(self) -> Self {
                 intrinsics::bswap(self as $ActualT) as Self
@@ -2532,6 +2736,10 @@ let m = n.reverse_bits();
 assert_eq!(m, ", $reversed, ");
 ```"),
             #[stable(feature = "reverse_bits", since = "1.37.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             #[must_use]
             pub const fn reverse_bits(self) -> Self {
@@ -2559,6 +2767,10 @@ if cfg!(target_endian = \"big\") {
 }", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn from_be(x: Self) -> Self {
                 #[cfg(target_endian = "big")]
@@ -2592,6 +2804,10 @@ if cfg!(target_endian = \"little\") {
 }", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn from_le(x: Self) -> Self {
                 #[cfg(target_endian = "little")]
@@ -2625,6 +2841,10 @@ if cfg!(target_endian = \"big\") {
 }", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn to_be(self) -> Self { // or not to be?
                 #[cfg(target_endian = "big")]
@@ -2658,6 +2878,10 @@ if cfg!(target_endian = \"little\") {
 }", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_math", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn to_le(self) -> Self {
                 #[cfg(target_endian = "little")]
@@ -2963,7 +3187,11 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, "
             #[stable(feature = "rust1", since = "1.0.0")]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
-            #[rustc_const_unstable(feature = "const_saturating_int_methods")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_saturating_int_methods"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718"),
+            )]
             #[inline]
             pub const fn saturating_add(self, rhs: Self) -> Self {
                 intrinsics::saturating_add(self, rhs)
@@ -2985,7 +3213,11 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, "
             #[stable(feature = "rust1", since = "1.0.0")]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
-            #[rustc_const_unstable(feature = "const_saturating_int_methods")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_saturating_int_methods"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718"),
+            )]
             #[inline]
             pub const fn saturating_sub(self, rhs: Self) -> Self {
                 intrinsics::saturating_sub(self, rhs)
@@ -3057,6 +3289,10 @@ assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::ma
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -3079,6 +3315,10 @@ assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::ma
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -3102,6 +3342,10 @@ $EndFeature, "
         /// assert_eq!(25u8.wrapping_mul(12), 44);
         /// ```
         #[stable(feature = "rust1", since = "1.0.0")]
+        #[cfg_attr(
+            not(bootstrap),
+            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]
@@ -3231,6 +3475,10 @@ assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0);
         /// assert_eq!((-128i8).wrapping_neg(), -128);
         /// ```
         #[stable(feature = "num_wrapping", since = "1.2.0")]
+        #[cfg_attr(
+            not(bootstrap),
+            rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0"),
+        )]
         #[inline]
         pub const fn wrapping_neg(self) -> Self {
             self.overflowing_neg().0
@@ -3257,6 +3505,10 @@ Basic usage:
 assert_eq!(1", stringify!($SelfT), ".wrapping_shl(128), 1);", $EndFeature, "
 ```"),
             #[stable(feature = "num_wrapping", since = "1.2.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -3290,6 +3542,10 @@ Basic usage:
 assert_eq!(128", stringify!($SelfT), ".wrapping_shr(128), 128);", $EndFeature, "
 ```"),
             #[stable(feature = "num_wrapping", since = "1.2.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -3359,6 +3615,10 @@ assert_eq!(5", stringify!($SelfT), ".overflowing_add(2), (7, false));
 assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (0, true));", $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -3387,6 +3647,10 @@ assert_eq!(0", stringify!($SelfT), ".overflowing_sub(1), (", stringify!($SelfT),
 $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -3414,6 +3678,10 @@ $EndFeature, "
         /// assert_eq!(1_000_000_000u32.overflowing_mul(10), (1410065408, true));
         /// ```
         #[stable(feature = "wrapping", since = "1.7.0")]
+        #[cfg_attr(
+            not(bootstrap),
+            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]
@@ -3559,6 +3827,10 @@ assert_eq!(2", stringify!($SelfT), ".overflowing_neg(), (-2i32 as ", stringify!(
 ```"),
             #[inline]
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0"),
+            )]
             pub const fn overflowing_neg(self) -> (Self, bool) {
                 ((!self).wrapping_add(1), self != 0)
             }
@@ -3582,6 +3854,10 @@ Basic usage
 assert_eq!(0x1", stringify!($SelfT), ".overflowing_shl(132), (0x10, true));", $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -3608,6 +3884,10 @@ Basic usage
 assert_eq!(0x10", stringify!($SelfT), ".overflowing_shr(132), (0x1, true));", $EndFeature, "
 ```"),
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                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]
@@ -3773,6 +4053,10 @@ Basic usage:
 assert!(!10", stringify!($SelfT), ".is_power_of_two());", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_is_power_of_two", since = "1.32.0"),
+            )]
             #[inline]
             pub const fn is_power_of_two(self) -> bool {
                 self.count_ones() == 1
@@ -3884,7 +4168,11 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
 assert_eq!(bytes, ", $be_bytes, ");
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
                 self.to_be().to_ne_bytes()
@@ -3904,7 +4192,11 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
 assert_eq!(bytes, ", $le_bytes, ");
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
                 self.to_le().to_ne_bytes()
@@ -3939,7 +4231,11 @@ assert_eq!(
 );
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
                 // SAFETY: integers are plain old datatypes so we can always transmute them to
@@ -3973,7 +4269,11 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
 }
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
                 Self::from_be(Self::from_ne_bytes(bytes))
@@ -4006,7 +4306,11 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
 }
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
                 Self::from_le(Self::from_ne_bytes(bytes))
@@ -4049,7 +4353,11 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
 }
 ```"),
             #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
-            #[rustc_const_unstable(feature = "const_int_conversion")]
+            #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_int_conversion"))]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_unstable(feature = "const_int_conversion", issue = "53718"),
+            )]
             #[inline]
             pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
                 // SAFETY: integers are plain old datatypes so we can always transmute to them
diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs
index 0ddfbd02aa5..46398dd2f82 100644
--- a/src/libcore/num/wrapping.rs
+++ b/src/libcore/num/wrapping.rs
@@ -530,6 +530,10 @@ assert_eq!(n.trailing_zeros(), 3);
             /// assert_eq!(m, Wrapping(-22016));
             /// ```
             #[stable(feature = "reverse_bits", since = "1.37.0")]
+            #[cfg_attr(
+                not(bootstrap),
+                rustc_const_stable(feature = "const_reverse_bits", since = "1.37.0"),
+            )]
             #[inline]
             #[must_use]
             pub const fn reverse_bits(self) -> Self {