diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index de086085c4cb2..9fba8fab1509f 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -10,6 +10,7 @@ #![allow(internal_features)] #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] +#![cfg_attr(bootstrap, feature(ptr_alignment_type))] #![cfg_attr(test, feature(test))] #![deny(unsafe_op_in_unsafe_fn)] #![feature(allocator_api)] @@ -27,7 +28,6 @@ #![feature(never_type)] #![feature(pattern_type_macro)] #![feature(pattern_types)] -#![feature(ptr_alignment_type)] #![feature(rustc_attrs)] #![feature(sized_hierarchy)] #![feature(thread_id_value)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index c8702c42c47f6..3ffe606114acd 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -27,6 +27,7 @@ // tidy-alphabetical-start #![allow(internal_features)] #![allow(rustc::direct_use_of_rustc_type_ir)] +#![cfg_attr(bootstrap, feature(ptr_alignment_type))] #![cfg_attr(doc, feature(intra_doc_pointers))] #![feature(allocator_api)] #![feature(associated_type_defaults)] @@ -45,7 +46,6 @@ #![feature(min_specialization)] #![feature(negative_impls)] #![feature(never_type)] -#![feature(ptr_alignment_type)] #![feature(range_bounds_is_empty)] #![feature(rustc_attrs)] #![feature(sized_hierarchy)] diff --git a/library/core/src/mem/alignment.rs b/library/core/src/mem/alignment.rs index a8c4c8ea78ff7..c9e6eaa866fbf 100644 --- a/library/core/src/mem/alignment.rs +++ b/library/core/src/mem/alignment.rs @@ -10,7 +10,7 @@ use crate::{cmp, fmt, hash, mem, num}; /// /// Note that particularly large alignments, while representable in this type, /// are likely not to be supported by actual allocators and linkers. -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[derive(Copy)] #[derive_const(Clone, PartialEq, Eq)] #[repr(transparent)] @@ -37,19 +37,19 @@ impl Alignment { /// # Examples /// /// ``` - /// #![feature(ptr_alignment_type)] /// use std::mem::Alignment; /// /// assert_eq!(Alignment::MIN.as_usize(), 1); /// ``` - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] pub const MIN: Self = Self::new(1).unwrap(); /// Returns the alignment for a type. /// /// This provides the same numerical value as [`align_of`], /// but in an `Alignment` instead of a `usize`. - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[inline] #[must_use] pub const fn of() -> Self { @@ -65,14 +65,14 @@ impl Alignment { /// # Examples /// /// ``` - /// #![feature(ptr_alignment_type)] /// use std::mem::Alignment; /// /// assert_eq!(Alignment::of_val(&5i32).as_usize(), 4); /// ``` #[inline] #[must_use] - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] pub const fn of_val(val: &T) -> Self { let align = mem::align_of_val(val); // SAFETY: `align_of_val` returns valid alignment @@ -112,14 +112,14 @@ impl Alignment { /// # Examples /// /// ``` - /// #![feature(ptr_alignment_type)] + /// #![feature(layout_for_ptr)] /// use std::mem::Alignment; /// /// assert_eq!(unsafe { Alignment::of_val_raw(&5i32) }.as_usize(), 4); /// ``` #[inline] #[must_use] - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[unstable(feature = "layout_for_ptr", issue = "69835")] pub const unsafe fn of_val_raw(val: *const T) -> Self { // SAFETY: precondition propagated to the caller let align = unsafe { mem::align_of_val_raw(val) }; @@ -131,7 +131,8 @@ impl Alignment { /// not a power of two. /// /// Note that `0` is not a power of two, nor a valid alignment. - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn new(align: usize) -> Option { if align.is_power_of_two() { @@ -150,7 +151,8 @@ impl Alignment { /// /// Equivalently, it must be `1 << exp` for some `exp` in `0..usize::BITS`. /// It must *not* be zero. - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[inline] #[track_caller] pub const unsafe fn new_unchecked(align: usize) -> Self { @@ -166,7 +168,8 @@ impl Alignment { } /// Returns the alignment as a [`usize`]. - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn as_usize(self) -> usize { // Going through `as_nonzero_usize` helps this be more clearly the inverse of @@ -188,7 +191,8 @@ impl Alignment { } /// Returns the alignment as a [NonZero]<[usize]>. - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn as_nonzero_usize(self) -> NonZero { // This transmutes directly to avoid the UbCheck in `NonZero::new_unchecked` @@ -227,7 +231,6 @@ impl Alignment { /// /// ``` /// #![feature(ptr_mask)] - /// #![feature(ptr_alignment_type)] /// use std::mem::Alignment; /// use std::ptr::NonNull; /// @@ -243,7 +246,7 @@ impl Alignment { /// assert_eq!(four.mask(Alignment::of::().mask()), four); /// assert_ne!(one.mask(Alignment::of::().mask()), one); /// ``` - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[unstable(feature = "ptr_mask", issue = "98290")] #[inline] pub const fn mask(self) -> usize { // SAFETY: The alignment is always nonzero, and therefore decrementing won't overflow. @@ -256,14 +259,14 @@ impl Alignment { } } -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for Alignment { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?} (1 << {:?})", self.as_nonzero_usize(), self.log2()) } } -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] impl const TryFrom> for Alignment { type Error = num::TryFromIntError; @@ -274,7 +277,7 @@ impl const TryFrom> for Alignment { } } -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] impl const TryFrom for Alignment { type Error = num::TryFromIntError; @@ -285,7 +288,7 @@ impl const TryFrom for Alignment { } } -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] impl const From for NonZero { #[inline] @@ -294,7 +297,7 @@ impl const From for NonZero { } } -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] impl const From for usize { #[inline] @@ -303,7 +306,7 @@ impl const From for usize { } } -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] impl const cmp::Ord for Alignment { #[inline] @@ -312,7 +315,7 @@ impl const cmp::Ord for Alignment { } } -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] impl const cmp::PartialOrd for Alignment { #[inline] @@ -321,7 +324,7 @@ impl const cmp::PartialOrd for Alignment { } } -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] impl hash::Hash for Alignment { #[inline] fn hash(&self, state: &mut H) { @@ -330,7 +333,7 @@ impl hash::Hash for Alignment { } /// Returns [`Alignment::MIN`], which is valid for any type. -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_default", issue = "143894")] impl const Default for Alignment { fn default() -> Alignment { diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index a987970c9bcc3..a459a8529ea8e 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -37,7 +37,7 @@ use crate::panic::const_assert; use crate::{clone, cmp, fmt, hash, intrinsics, ptr}; mod alignment; -#[unstable(feature = "ptr_alignment_type", issue = "102070")] +#[stable(feature = "alignment_type", since = "CURRENT_RUSTC_VERSION")] pub use alignment::Alignment; mod manually_drop; @@ -1287,7 +1287,7 @@ pub trait SizedTypeProperties: Sized { const ALIGN: usize = intrinsics::align_of::(); #[doc(hidden)] - #[unstable(feature = "ptr_alignment_type", issue = "102070")] + #[unstable(feature = "sized_type_properties", issue = "none")] const ALIGNMENT: Alignment = { // This can't panic since type alignment is always a power of two. Alignment::new(Self::ALIGN).unwrap() diff --git a/tests/ui/precondition-checks/alignment.rs b/tests/ui/precondition-checks/alignment.rs index 3f0eae47a157a..3903b7b7b040b 100644 --- a/tests/ui/precondition-checks/alignment.rs +++ b/tests/ui/precondition-checks/alignment.rs @@ -2,8 +2,6 @@ //@ compile-flags: -Copt-level=3 -Cdebug-assertions=no -Zub-checks=yes //@ error-pattern: unsafe precondition(s) violated: Alignment::new_unchecked requires -#![feature(ptr_alignment_type)] - fn main() { unsafe { std::mem::Alignment::new_unchecked(0); diff --git a/tests/ui/traits/const-traits/const-traits-core.rs b/tests/ui/traits/const-traits/const-traits-core.rs index ed244c230006a..d4fcc1c10a792 100644 --- a/tests/ui/traits/const-traits/const-traits-core.rs +++ b/tests/ui/traits/const-traits/const-traits-core.rs @@ -3,7 +3,6 @@ const_clone, const_default, const_trait_impl, - ptr_alignment_type, ascii_char, f16, f128,