From f38f4421f49942dc8c94785550dcd231e9fb5abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Bj=C3=B8rnager=20Jensen?= Date: Thu, 9 Oct 2025 22:30:16 +0200 Subject: [PATCH] Stabilise 'as_array' in '[_]' and '*const [_]'; Stabilise 'as_mut_array' in '[_]' and '*mut [_]'; --- compiler/rustc_codegen_llvm/src/lib.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 ++++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 807049f08d367..e6736dd9128a4 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(try_blocks)] // tidy-alphabetical-end diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 54adf97f10020..e2519e159f667 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -119,7 +119,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 ba78afc7ea114..77f72acf45de2 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1708,7 +1708,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 f7f5ee819b2e4..8a66fec1d1de7 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]> {