diff options
| author | bors <bors@rust-lang.org> | 2019-12-14 10:21:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-14 10:21:32 +0000 |
| commit | c8ea4ace9213ae045123fdfeb59d1ac887656d31 (patch) | |
| tree | 2a7d207294b6f2c99d1ddbe193b1d5af8ee46a09 /src/libcore | |
| parent | 12307b3b08edee543a78fb9d4a837fbd6d6ac0fa (diff) | |
| parent | 0b47ba7019adf06f6687a8c94040e63ae1ea4fba (diff) | |
| download | rust-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')
| -rw-r--r-- | src/libcore/alloc.rs | 1 | ||||
| -rw-r--r-- | src/libcore/any.rs | 9 | ||||
| -rw-r--r-- | src/libcore/cell.rs | 11 | ||||
| -rw-r--r-- | src/libcore/char/methods.rs | 4 | ||||
| -rw-r--r-- | src/libcore/convert/mod.rs | 1 | ||||
| -rw-r--r-- | src/libcore/intrinsics.rs | 6 | ||||
| -rw-r--r-- | src/libcore/iter/sources.rs | 1 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 2 | ||||
| -rw-r--r-- | src/libcore/mem/manually_drop.rs | 8 | ||||
| -rw-r--r-- | src/libcore/mem/maybe_uninit.rs | 8 | ||||
| -rw-r--r-- | src/libcore/mem/mod.rs | 3 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 342 | ||||
| -rw-r--r-- | src/libcore/num/wrapping.rs | 4 | ||||
| -rw-r--r-- | src/libcore/ops/range.rs | 9 | ||||
| -rw-r--r-- | src/libcore/ptr/mod.rs | 16 | ||||
| -rw-r--r-- | src/libcore/ptr/non_null.rs | 16 | ||||
| -rw-r--r-- | src/libcore/slice/mod.rs | 9 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 7 | ||||
| -rw-r--r-- | src/libcore/sync/atomic.rs | 16 | ||||
| -rw-r--r-- | src/libcore/task/wake.rs | 2 | ||||
| -rw-r--r-- | src/libcore/time.rs | 12 |
21 files changed, 463 insertions, 24 deletions
diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 5c24e3d8f5d..71517ffb006 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -100,6 +100,7 @@ impl Layout { /// This function is unsafe as it does not verify the preconditions from /// [`Layout::from_size_align`](#method.from_size_align). #[stable(feature = "alloc_layout", since = "1.28.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "alloc_layout", since = "1.28.0"))] #[inline] pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self { Layout { size_: size, align_: NonZeroUsize::new_unchecked(align) } diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 466750fc7d2..b0e3021e0bf 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -423,7 +423,8 @@ impl TypeId { /// assert_eq!(is_string(&"cookie monster".to_string()), true); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature="const_type_id")] + #[cfg_attr(bootstrap, rustc_const_unstable(feature="const_type_id"))] + #[cfg_attr(not(bootstrap), rustc_const_unstable(feature="const_type_id", issue = "41875"))] pub const fn of<T: ?Sized + 'static>() -> TypeId { TypeId { #[cfg(bootstrap)] @@ -461,7 +462,8 @@ impl TypeId { /// ); /// ``` #[stable(feature = "type_name", since = "1.38.0")] -#[rustc_const_unstable(feature = "const_type_name")] +#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_type_name"))] +#[cfg_attr(not(bootstrap), rustc_const_unstable(feature = "const_type_name", issue = "63084"))] pub const fn type_name<T: ?Sized>() -> &'static str { intrinsics::type_name::<T>() } @@ -499,7 +501,8 @@ pub const fn type_name<T: ?Sized>() -> &'static str { /// println!("{}", type_name_of_val(&y)); /// ``` #[unstable(feature = "type_name_of_val", issue = "66359")] -#[rustc_const_unstable(feature = "const_type_name")] +#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_type_name"))] +#[cfg_attr(not(bootstrap), rustc_const_unstable(feature = "const_type_name", issue = "63084"))] pub const fn type_name_of_val<T: ?Sized>(val: &T) -> &'static str { let _ = val; type_name::<T>() diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 03f32e72618..e4b4cd31c63 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -324,6 +324,7 @@ impl<T> Cell<T> { /// let c = Cell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_cell_new", since = "1.32.0"))] #[inline] pub const fn new(value: T) -> Cell<T> { Cell { @@ -469,6 +470,7 @@ impl<T: ?Sized> Cell<T> { /// ``` #[inline] #[stable(feature = "cell_as_ptr", since = "1.12.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_cell_as_ptr", since = "1.32.0"))] pub const fn as_ptr(&self) -> *mut T { self.value.get() } @@ -649,6 +651,7 @@ impl<T> RefCell<T> { /// let c = RefCell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_refcell_new", since = "1.32.0"))] #[inline] pub const fn new(value: T) -> RefCell<T> { RefCell { @@ -1501,6 +1504,10 @@ impl<T> UnsafeCell<T> { /// let uc = UnsafeCell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_unsafe_cell_new", since = "1.32.0"), + )] #[inline] pub const fn new(value: T) -> UnsafeCell<T> { UnsafeCell { value } @@ -1543,6 +1550,10 @@ impl<T: ?Sized> UnsafeCell<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_unsafecell_get", since = "1.32.0"), + )] pub const fn get(&self) -> *mut T { // We can just cast the pointer from `UnsafeCell<T>` to `T` because of // #[repr(transparent)]. This exploits libstd's special status, there is diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index 5c63eebf595..5cfb9583a86 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -911,6 +911,10 @@ impl char { /// assert!(!non_ascii.is_ascii()); /// ``` #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.32.0"), + )] #[inline] pub const fn is_ascii(&self) -> bool { *self as u32 <= 0x7F diff --git a/src/libcore/convert/mod.rs b/src/libcore/convert/mod.rs index b7db3e4197d..cdd994d5fc7 100644 --- a/src/libcore/convert/mod.rs +++ b/src/libcore/convert/mod.rs @@ -99,6 +99,7 @@ pub use num::FloatToInt; /// assert_eq!(vec![1, 3], filtered); /// ``` #[stable(feature = "convert_id", since = "1.33.0")] +#[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_identity", since = "1.33.0"))] #[inline] pub const fn identity<T>(x: T) -> T { x diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 18aae59573d..1f72b7ab090 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -939,7 +939,11 @@ extern "rust-intrinsic" { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_transmute")] + #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_transmute"))] + #[cfg_attr( + not(bootstrap), + rustc_const_unstable(feature = "const_transmute", issue = "53605"), + )] pub fn transmute<T, U>(e: T) -> U; /// Returns `true` if the actual type given as `T` requires drop diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs index ffac7d4e995..127b778e62e 100644 --- a/src/libcore/iter/sources.rs +++ b/src/libcore/iter/sources.rs @@ -281,6 +281,7 @@ impl<T> Default for Empty<T> { /// assert_eq!(None, nope.next()); /// ``` #[stable(feature = "iter_empty", since = "1.2.0")] +#[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_iter_empty", since = "1.32.0"))] pub const fn empty<T>() -> Empty<T> { Empty(marker::PhantomData) } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 8a514f1e78e..146d582eb7a 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -96,7 +96,7 @@ #![feature(prelude_import)] #![feature(repr_simd, platform_intrinsics)] #![feature(rustc_attrs)] -#![feature(rustc_const_unstable)] +#![cfg_attr(bootstrap, feature(rustc_const_unstable))] #![feature(simd_ffi)] #![feature(specialization)] #![feature(staged_api)] diff --git a/src/libcore/mem/manually_drop.rs b/src/libcore/mem/manually_drop.rs index 34fc0618ea2..6463668a03e 100644 --- a/src/libcore/mem/manually_drop.rs +++ b/src/libcore/mem/manually_drop.rs @@ -63,6 +63,10 @@ impl<T> ManuallyDrop<T> { /// ManuallyDrop::new(Box::new(())); /// ``` #[stable(feature = "manually_drop", since = "1.20.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_manually_drop", since = "1.36.0"), + )] #[inline(always)] pub const fn new(value: T) -> ManuallyDrop<T> { ManuallyDrop { value } @@ -80,6 +84,10 @@ impl<T> ManuallyDrop<T> { /// let _: Box<()> = ManuallyDrop::into_inner(x); // This drops the `Box`. /// ``` #[stable(feature = "manually_drop", since = "1.20.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_manually_drop", since = "1.36.0"), + )] #[inline(always)] pub const fn into_inner(slot: ManuallyDrop<T>) -> T { slot.value diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 6661df2ae0d..670a194e2d6 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -250,6 +250,10 @@ impl<T> MaybeUninit<T> { /// /// [`assume_init`]: #method.assume_init #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0"), + )] #[inline(always)] pub const fn new(val: T) -> MaybeUninit<T> { MaybeUninit { value: ManuallyDrop::new(val) } @@ -264,6 +268,10 @@ impl<T> MaybeUninit<T> { /// /// [type]: union.MaybeUninit.html #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0"), + )] #[inline(always)] #[cfg_attr(all(not(bootstrap)), rustc_diagnostic_item = "maybe_uninit_uninit")] pub const fn uninit() -> MaybeUninit<T> { diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index ec926aa6c23..00b32ad0b73 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -271,6 +271,7 @@ pub fn forget_unsized<T: ?Sized>(t: T) { #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_promotable] +#[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_size_of", since = "1.32.0"))] pub const fn size_of<T>() -> usize { intrinsics::size_of::<T>() } @@ -371,6 +372,7 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize { #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_promotable] +#[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_align_of", since = "1.32.0"))] pub const fn align_of<T>() -> usize { intrinsics::min_align_of::<T>() } @@ -453,6 +455,7 @@ pub fn align_of_val<T: ?Sized>(val: &T) -> usize { /// ``` #[inline] #[stable(feature = "needs_drop", since = "1.21.0")] +#[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_needs_drop", since = "1.36.0"))] pub const fn needs_drop<T>() -> bool { intrinsics::needs_drop::<T>() } 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 { diff --git a/src/libcore/ops/range.rs b/src/libcore/ops/range.rs index a2250337a4d..54ce2917a36 100644 --- a/src/libcore/ops/range.rs +++ b/src/libcore/ops/range.rs @@ -398,6 +398,7 @@ impl<Idx> RangeInclusive<Idx> { #[stable(feature = "inclusive_range_methods", since = "1.27.0")] #[inline] #[rustc_promotable] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_range_new", since = "1.32.0"))] pub const fn new(start: Idx, end: Idx) -> Self { Self { start, end, is_empty: None } } @@ -421,6 +422,10 @@ impl<Idx> RangeInclusive<Idx> { /// assert_eq!((3..=5).start(), &3); /// ``` #[stable(feature = "inclusive_range_methods", since = "1.27.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_inclusive_range_methods", since = "1.32.0"), + )] #[inline] pub const fn start(&self) -> &Idx { &self.start @@ -445,6 +450,10 @@ impl<Idx> RangeInclusive<Idx> { /// assert_eq!((3..=5).end(), &5); /// ``` #[stable(feature = "inclusive_range_methods", since = "1.27.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_inclusive_range_methods", since = "1.32.0"), + )] #[inline] pub const fn end(&self) -> &Idx { &self.end diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index 24ffa348329..33c23233fd1 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -198,6 +198,7 @@ unsafe fn real_drop_in_place<T: ?Sized>(to_drop: &mut T) { #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_promotable] +#[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_ptr_null", since = "1.32.0"))] pub const fn null<T>() -> *const T { 0 as *const T } @@ -215,6 +216,7 @@ pub const fn null<T>() -> *const T { #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_promotable] +#[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_ptr_null", since = "1.32.0"))] pub const fn null_mut<T>() -> *mut T { 0 as *mut T } @@ -1060,6 +1062,7 @@ impl<T: ?Sized> *const T { /// Casts to a pointer of another type. #[stable(feature = "ptr_cast", since = "1.38.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_ptr_cast", since = "1.38.0"))] #[inline] pub const fn cast<U>(self) -> *const U { self as _ @@ -1307,7 +1310,11 @@ impl<T: ?Sized> *const T { /// } /// ``` #[unstable(feature = "ptr_offset_from", issue = "41079")] - #[rustc_const_unstable(feature = "const_ptr_offset_from")] + #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_ptr_offset_from"))] + #[cfg_attr( + not(bootstrap), + rustc_const_unstable(feature = "const_ptr_offset_from", issue = "41079"), + )] #[inline] pub const unsafe fn offset_from(self, origin: *const T) -> isize where @@ -1763,6 +1770,7 @@ impl<T: ?Sized> *mut T { /// Casts to a pointer of another type. #[stable(feature = "ptr_cast", since = "1.38.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_ptr_cast", since = "1.38.0"))] #[inline] pub const fn cast<U>(self) -> *mut U { self as _ @@ -2049,7 +2057,11 @@ impl<T: ?Sized> *mut T { /// } /// ``` #[unstable(feature = "ptr_offset_from", issue = "41079")] - #[rustc_const_unstable(feature = "const_ptr_offset_from")] + #[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_ptr_offset_from"))] + #[cfg_attr( + not(bootstrap), + rustc_const_unstable(feature = "const_ptr_offset_from", issue = "41079"), + )] #[inline] pub const unsafe fn offset_from(self, origin: *const T) -> isize where diff --git a/src/libcore/ptr/non_null.rs b/src/libcore/ptr/non_null.rs index a121389bef3..d1d97d7b332 100644 --- a/src/libcore/ptr/non_null.rs +++ b/src/libcore/ptr/non_null.rs @@ -66,6 +66,10 @@ impl<T: Sized> NonNull<T> { /// sentinel value. Types that lazily allocate must track initialization by /// some other means. #[stable(feature = "nonnull", since = "1.25.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_nonnull_dangling", since = "1.32.0"), + )] #[inline] pub const fn dangling() -> Self { unsafe { @@ -82,6 +86,10 @@ impl<T: ?Sized> NonNull<T> { /// /// `ptr` must be non-null. #[stable(feature = "nonnull", since = "1.25.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_nonnull_new_unchecked", since = "1.32.0"), + )] #[inline] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { NonNull { pointer: ptr as _ } @@ -96,6 +104,10 @@ impl<T: ?Sized> NonNull<T> { /// Acquires the underlying `*mut` pointer. #[stable(feature = "nonnull", since = "1.25.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_nonnull_as_ptr", since = "1.32.0"), + )] #[inline] pub const fn as_ptr(self) -> *mut T { self.pointer as *mut T @@ -125,6 +137,10 @@ impl<T: ?Sized> NonNull<T> { /// Casts to a pointer of another type. #[stable(feature = "nonnull_cast", since = "1.27.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_nonnull_cast", since = "1.32.0"), + )] #[inline] pub const fn cast<U>(self) -> NonNull<U> { unsafe { NonNull::new_unchecked(self.as_ptr() as *mut U) } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index c8fe9f98613..a8e500d256f 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -62,6 +62,7 @@ impl<T> [T] { /// assert_eq!(a.len(), 3); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_slice_len", since = "1.32.0"))] #[inline] // SAFETY: const sound because we transmute out the length field as a usize (which it must be) #[allow(unused_attributes)] @@ -81,6 +82,10 @@ impl<T> [T] { /// assert!(!a.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_slice_is_empty", since = "1.32.0"), + )] #[inline] pub const fn is_empty(&self) -> bool { self.len() == 0 @@ -376,6 +381,10 @@ impl<T> [T] { /// /// [`as_mut_ptr`]: #method.as_mut_ptr #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_slice_as_ptr", since = "1.32.0"), + )] #[inline] pub const fn as_ptr(&self) -> *const T { self as *const [T] as *const T diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index b2a420f3c43..6d225a25f20 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -2090,6 +2090,7 @@ impl str { /// assert_eq!("ƒoo".chars().count(), 3); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_str_len", since = "1.32.0"))] #[inline] pub const fn len(&self) -> usize { self.as_bytes().len() @@ -2110,6 +2111,10 @@ impl str { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr( + not(bootstrap), + rustc_const_stable(feature = "const_str_is_empty", since = "1.32.0"), + )] pub const fn is_empty(&self) -> bool { self.len() == 0 } @@ -2166,6 +2171,7 @@ impl str { /// assert_eq!(b"bors", bytes); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "str_as_bytes", since = "1.32.0"))] #[inline(always)] // SAFETY: const sound because we transmute two types with the same layout #[allow(unused_attributes)] @@ -2239,6 +2245,7 @@ impl str { /// let ptr = s.as_ptr(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "rustc_str_as_ptr", since = "1.32.0"))] #[inline] pub const fn as_ptr(&self) -> *const u8 { self as *const str as *const u8 diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 6e1aac00c7b..7756335ee20 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -331,6 +331,7 @@ impl AtomicBool { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_atomic_new", since = "1.32.0"))] pub const fn new(v: bool) -> AtomicBool { AtomicBool { v: UnsafeCell::new(v as u8) } } @@ -855,6 +856,7 @@ impl<T> AtomicPtr<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "const_atomic_new", since = "1.32.0"))] pub const fn new(p: *mut T) -> AtomicPtr<T> { AtomicPtr { p: UnsafeCell::new(p) } } @@ -1183,6 +1185,7 @@ macro_rules! atomic_int { $stable_access:meta, $stable_from:meta, $stable_nand:meta, + $const_stable:meta, $stable_init_const:meta, $s_int_type:expr, $int_ref:expr, $extra_feature:expr, @@ -1258,6 +1261,7 @@ let atomic_forty_two = ", stringify!($atomic_type), "::new(42); ```"), #[inline] #[$stable] + #[cfg_attr(not(bootstrap), $const_stable)] pub const fn new(v: $int_type) -> Self { $atomic_type {v: UnsafeCell::new(v)} } @@ -1978,6 +1982,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "i8", "../../../std/primitive.i8.html", "", @@ -1995,6 +2000,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "u8", "../../../std/primitive.u8.html", "", @@ -2012,6 +2018,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "i16", "../../../std/primitive.i16.html", "", @@ -2029,6 +2036,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "u16", "../../../std/primitive.u16.html", "", @@ -2046,6 +2054,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "i32", "../../../std/primitive.i32.html", "", @@ -2063,6 +2072,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "u32", "../../../std/primitive.u32.html", "", @@ -2080,6 +2090,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "i64", "../../../std/primitive.i64.html", "", @@ -2097,6 +2108,7 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), stable(feature = "integer_atomics_stable", since = "1.34.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "u64", "../../../std/primitive.u64.html", "", @@ -2114,6 +2126,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "i128", "../../../std/primitive.i128.html", "#![feature(integer_atomics)]\n\n", @@ -2131,6 +2144,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), unstable(feature = "integer_atomics", issue = "32976"), "u128", "../../../std/primitive.u128.html", "#![feature(integer_atomics)]\n\n", @@ -2163,6 +2177,7 @@ atomic_int!{ stable(feature = "atomic_access", since = "1.15.0"), stable(feature = "atomic_from", since = "1.23.0"), stable(feature = "atomic_nand", since = "1.27.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), stable(feature = "rust1", since = "1.0.0"), "isize", "../../../std/primitive.isize.html", "", @@ -2180,6 +2195,7 @@ atomic_int!{ stable(feature = "atomic_access", since = "1.15.0"), stable(feature = "atomic_from", since = "1.23.0"), stable(feature = "atomic_nand", since = "1.27.0"), + rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), stable(feature = "rust1", since = "1.0.0"), "usize", "../../../std/primitive.usize.html", "", diff --git a/src/libcore/task/wake.rs b/src/libcore/task/wake.rs index 0759ff93ea8..c1e45f189b7 100644 --- a/src/libcore/task/wake.rs +++ b/src/libcore/task/wake.rs @@ -39,6 +39,7 @@ impl RawWaker { /// function in the `vtable` of the underlying `RawWaker` will be called. #[rustc_promotable] #[stable(feature = "futures_api", since = "1.36.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "futures_api", since = "1.36.0"))] pub const fn new(data: *const (), vtable: &'static RawWakerVTable) -> RawWaker { RawWaker { data, vtable } } @@ -151,6 +152,7 @@ impl RawWakerVTable { // FIXME: remove whenever we have a stable way to accept fn pointers from const fn // (see https://github.com/rust-rfcs/const-eval/issues/19#issuecomment-472799062) #[rustc_allow_const_fn_ptr] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "futures_api", since = "1.36.0"))] pub const fn new( clone: unsafe fn(*const ()) -> RawWaker, wake: unsafe fn(*const ()), diff --git a/src/libcore/time.rs b/src/libcore/time.rs index 70ec1e42fd7..7d04cfb5da5 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -130,6 +130,7 @@ impl Duration { /// ``` #[stable(feature = "duration", since = "1.3.0")] #[inline] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_consts", since = "1.32.0"))] pub fn new(secs: u64, nanos: u32) -> Duration { let secs = secs.checked_add((nanos / NANOS_PER_SEC) as u64).expect("overflow in Duration::new"); @@ -152,6 +153,7 @@ impl Duration { #[stable(feature = "duration", since = "1.3.0")] #[inline] #[rustc_promotable] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_consts", since = "1.32.0"))] pub const fn from_secs(secs: u64) -> Duration { Duration { secs, nanos: 0 } } @@ -171,6 +173,7 @@ impl Duration { #[stable(feature = "duration", since = "1.3.0")] #[inline] #[rustc_promotable] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_consts", since = "1.32.0"))] pub const fn from_millis(millis: u64) -> Duration { Duration { secs: millis / MILLIS_PER_SEC, @@ -193,6 +196,7 @@ impl Duration { #[stable(feature = "duration_from_micros", since = "1.27.0")] #[inline] #[rustc_promotable] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_consts", since = "1.32.0"))] pub const fn from_micros(micros: u64) -> Duration { Duration { secs: micros / MICROS_PER_SEC, @@ -215,6 +219,7 @@ impl Duration { #[stable(feature = "duration_extras", since = "1.27.0")] #[inline] #[rustc_promotable] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_consts", since = "1.32.0"))] pub const fn from_nanos(nanos: u64) -> Duration { Duration { secs: nanos / (NANOS_PER_SEC as u64), @@ -251,6 +256,7 @@ impl Duration { /// /// [`subsec_nanos`]: #method.subsec_nanos #[stable(feature = "duration", since = "1.3.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration", since = "1.32.0"))] #[inline] pub const fn as_secs(&self) -> u64 { self.secs @@ -272,6 +278,7 @@ impl Duration { /// assert_eq!(duration.subsec_millis(), 432); /// ``` #[stable(feature = "duration_extras", since = "1.27.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_extras", since = "1.32.0"))] #[inline] pub const fn subsec_millis(&self) -> u32 { self.nanos / NANOS_PER_MILLI @@ -293,6 +300,7 @@ impl Duration { /// assert_eq!(duration.subsec_micros(), 234_567); /// ``` #[stable(feature = "duration_extras", since = "1.27.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_extras", since = "1.32.0"))] #[inline] pub const fn subsec_micros(&self) -> u32 { self.nanos / NANOS_PER_MICRO @@ -314,6 +322,7 @@ impl Duration { /// assert_eq!(duration.subsec_nanos(), 10_000_000); /// ``` #[stable(feature = "duration", since = "1.3.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration", since = "1.32.0"))] #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos @@ -330,6 +339,7 @@ impl Duration { /// assert_eq!(duration.as_millis(), 5730); /// ``` #[stable(feature = "duration_as_u128", since = "1.33.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_as_u128", since = "1.33.0"))] #[inline] pub const fn as_millis(&self) -> u128 { self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128 @@ -346,6 +356,7 @@ impl Duration { /// assert_eq!(duration.as_micros(), 5730023); /// ``` #[stable(feature = "duration_as_u128", since = "1.33.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_as_u128", since = "1.33.0"))] #[inline] pub const fn as_micros(&self) -> u128 { self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128 @@ -362,6 +373,7 @@ impl Duration { /// assert_eq!(duration.as_nanos(), 5730023852); /// ``` #[stable(feature = "duration_as_u128", since = "1.33.0")] + #[cfg_attr(not(bootstrap), rustc_const_stable(feature = "duration_as_u128", since = "1.33.0"))] #[inline] pub const fn as_nanos(&self) -> u128 { self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128 |
