Skip to content

Commit 09297c5

Browse files
authored
Unrolled build for #147540
Rollup merge of #147540 - bjoernager:slice-as-array, r=Amanieu Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`. Tracking issue: #133508 Closes: #133508 This PR stabilises the `as_array` and `as_mut_array` associated functions from the `core_slice_as_array` feature gate: ```rust // core::slice impl<T> [T] { pub const fn as_array<const N: usize>(&self) -> Option<&[T; N]>; pub const fn as_mut_array<const N: usize>(&mut self) -> Option<&mut [T; N]>; } // core::ptr impl<T> *const [T] { pub const fn as_array<const N: usize>(self) -> Option<*const [T; N]>; } impl<T> *mut [T] { pub const fn as_mut_array<const N: usize>(self) -> Option<*mut [T; N]>; } ``` It also updates the feature gates and tracking issues for all items associated with the previous `slice_as_array` tracking issue (including these four that are being stabilised). ~~FCP missing.~~
2 parents 72b21e1 + fa8e864 commit 09297c5

File tree

8 files changed

+12
-9
lines changed

8 files changed

+12
-9
lines changed

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
//! This API is completely unstable and subject to change.
66
77
// tidy-alphabetical-start
8+
#![cfg_attr(bootstrap, feature(slice_as_array))]
89
#![feature(assert_matches)]
910
#![feature(extern_types)]
1011
#![feature(file_buffered)]
1112
#![feature(if_let_guard)]
1213
#![feature(impl_trait_in_assoc_type)]
1314
#![feature(iter_intersperse)]
1415
#![feature(macro_derive)]
15-
#![feature(slice_as_array)]
1616
#![feature(trim_prefix_suffix)]
1717
#![feature(try_blocks)]
1818
// tidy-alphabetical-end

library/alloc/src/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ impl<T> Box<[T]> {
850850
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
851851
///
852852
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
853-
#[unstable(feature = "slice_as_array", issue = "133508")]
853+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
854854
#[inline]
855855
#[must_use]
856856
pub fn into_array<const N: usize>(self) -> Option<Box<[T; N]>> {

library/alloc/src/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ impl<T> Rc<[T]> {
11661166
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
11671167
///
11681168
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1169-
#[unstable(feature = "slice_as_array", issue = "133508")]
1169+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
11701170
#[inline]
11711171
#[must_use]
11721172
pub fn into_array<const N: usize>(self) -> Option<Rc<[T; N]>> {

library/alloc/src/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ impl<T> Arc<[T]> {
13141314
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
13151315
///
13161316
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1317-
#[unstable(feature = "slice_as_array", issue = "133508")]
1317+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
13181318
#[inline]
13191319
#[must_use]
13201320
pub fn into_array<const N: usize>(self) -> Option<Arc<[T; N]>> {

library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
#![feature(ptr_alignment_type)]
122122
#![feature(ptr_metadata)]
123123
#![feature(set_ptr_value)]
124-
#![feature(slice_as_array)]
125124
#![feature(slice_ptr_get)]
126125
#![feature(str_internals)]
127126
#![feature(str_split_inclusive_remainder)]

library/core/src/ptr/const_ptr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,8 @@ impl<T> *const [T] {
14621462
/// Gets a raw pointer to the underlying array.
14631463
///
14641464
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1465-
#[unstable(feature = "slice_as_array", issue = "133508")]
1465+
#[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")]
1466+
#[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")]
14661467
#[inline]
14671468
#[must_use]
14681469
pub const fn as_array<const N: usize>(self) -> Option<*const [T; N]> {

library/core/src/ptr/mut_ptr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,8 @@ impl<T> *mut [T] {
17121712
/// Gets a raw, mutable pointer to the underlying array.
17131713
///
17141714
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1715-
#[unstable(feature = "slice_as_array", issue = "133508")]
1715+
#[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")]
1716+
#[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")]
17161717
#[inline]
17171718
#[must_use]
17181719
pub const fn as_mut_array<const N: usize>(self) -> Option<*mut [T; N]> {

library/core/src/slice/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,8 @@ impl<T> [T] {
841841
/// Gets a reference to the underlying array.
842842
///
843843
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
844-
#[unstable(feature = "slice_as_array", issue = "133508")]
844+
#[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")]
845+
#[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")]
845846
#[inline]
846847
#[must_use]
847848
pub const fn as_array<const N: usize>(&self) -> Option<&[T; N]> {
@@ -859,7 +860,8 @@ impl<T> [T] {
859860
/// Gets a mutable reference to the slice's underlying array.
860861
///
861862
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
862-
#[unstable(feature = "slice_as_array", issue = "133508")]
863+
#[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")]
864+
#[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")]
863865
#[inline]
864866
#[must_use]
865867
pub const fn as_mut_array<const N: usize>(&mut self) -> Option<&mut [T; N]> {

0 commit comments

Comments
 (0)