From 79df977263f2ea9d46865d11824149b3a133aadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Bj=C3=B8rnager=20Jensen?= Date: Wed, 5 Nov 2025 13:08:06 +0100 Subject: [PATCH] Stabilise 'as_array' in '[_]' and '*const [_]'; Stabilise 'as_mut_array' in '[_]' and '*mut [_]'; Update feature gate and tracking issue for 'alloc_slice_into_array' items; --- compiler/rustc_codegen_llvm/src/lib.rs | 2 +- library/alloc/src/boxed.rs | 2 +- library/alloc/src/rc.rs | 2 +- library/alloc/src/sync.rs | 2 +- library/core/src/lib.rs | 1 - library/core/src/ptr/const_ptr.rs | 3 ++- library/core/src/ptr/mut_ptr.rs | 3 ++- library/core/src/slice/mod.rs | 6 ++++-- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index c8ad8f0c10d0d..4b45307c4699c 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -6,6 +6,7 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(slice_as_array))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] @@ -16,7 +17,6 @@ #![feature(iter_intersperse)] #![feature(macro_derive)] #![feature(rustdoc_internals)] -#![feature(slice_as_array)] #![feature(trim_prefix_suffix)] #![feature(try_blocks)] // tidy-alphabetical-end diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 7ad1679b1c822..381eaeb809f27 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -850,7 +850,7 @@ impl Box<[T]> { /// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[unstable(feature = "slice_as_array", issue = "133508")] + #[unstable(feature = "alloc_slice_into_array", issue = "148082")] #[inline] #[must_use] pub fn into_array(self) -> Option> { diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index a24ea6e526c4b..f0ce6aa03a8ba 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1166,7 +1166,7 @@ impl Rc<[T]> { /// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[unstable(feature = "slice_as_array", issue = "133508")] + #[unstable(feature = "alloc_slice_into_array", issue = "148082")] #[inline] #[must_use] pub fn into_array(self) -> Option> { diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 13b5cf23e72d8..b85293973fd5c 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1314,7 +1314,7 @@ impl Arc<[T]> { /// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[unstable(feature = "slice_as_array", issue = "133508")] + #[unstable(feature = "alloc_slice_into_array", issue = "148082")] #[inline] #[must_use] pub fn into_array(self) -> Option> { diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index f1948fc778ce2..1f66c43c73dbe 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -121,7 +121,6 @@ #![feature(ptr_alignment_type)] #![feature(ptr_metadata)] #![feature(set_ptr_value)] -#![feature(slice_as_array)] #![feature(slice_ptr_get)] #![feature(str_internals)] #![feature(str_split_inclusive_remainder)] diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 451092709443b..84a6982d56805 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1462,7 +1462,8 @@ impl *const [T] { /// Gets a raw pointer to the underlying array. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[unstable(feature = "slice_as_array", issue = "133508")] + #[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] #[inline] #[must_use] pub const fn as_array(self) -> Option<*const [T; N]> { diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 24ee92bdd6e1b..85d54b4d3b9b3 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1712,7 +1712,8 @@ impl *mut [T] { /// Gets a raw, mutable pointer to the underlying array. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[unstable(feature = "slice_as_array", issue = "133508")] + #[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] #[inline] #[must_use] pub const fn as_mut_array(self) -> Option<*mut [T; N]> { diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 96c1034f9735f..1d88eb33dce10 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -841,7 +841,8 @@ impl [T] { /// Gets a reference to the underlying array. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[unstable(feature = "slice_as_array", issue = "133508")] + #[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] #[inline] #[must_use] pub const fn as_array(&self) -> Option<&[T; N]> { @@ -859,7 +860,8 @@ impl [T] { /// Gets a mutable reference to the slice's underlying array. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[unstable(feature = "slice_as_array", issue = "133508")] + #[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] #[inline] #[must_use] pub const fn as_mut_array(&mut self) -> Option<&mut [T; N]> {