Skip to content

Commit 4ba32c6

Browse files
committed
Auto merge of #130538 - ultrabear:ultrabear_const_from_ref, r=workingjubilee
Stabilize const `{slice,array}::from_mut` This PR stabilizes the following APIs as const stable as of rust `1.83`: ```rs // core::array pub const fn from_mut<T>(s: &mut T) -> &mut [T; 1]; // core::slice pub const fn from_mut<T>(s: &mut T) -> &mut [T]; ``` This is made possible by `const_mut_refs` being stabilized (yay). Tracking issue: #90206
2 parents a1eceec + 461b49d commit 4ba32c6

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

library/core/src/array/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ pub const fn from_ref<T>(s: &T) -> &[T; 1] {
146146

147147
/// Converts a mutable reference to `T` into a mutable reference to an array of length 1 (without copying).
148148
#[stable(feature = "array_from_ref", since = "1.53.0")]
149-
#[rustc_const_unstable(feature = "const_array_from_ref", issue = "90206")]
149+
#[rustc_const_stable(feature = "const_array_from_ref", since = "CURRENT_RUSTC_VERSION")]
150+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
150151
pub const fn from_mut<T>(s: &mut T) -> &mut [T; 1] {
151152
// SAFETY: Converting `&mut T` to `&mut [T; 1]` is sound.
152153
unsafe { &mut *(s as *mut T).cast::<[T; 1]>() }

library/core/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
#![feature(const_align_offset)]
115115
#![feature(const_alloc_layout)]
116116
#![feature(const_arguments_as_str)]
117-
#![feature(const_array_from_ref)]
118117
#![feature(const_array_into_iter_constructors)]
119118
#![feature(const_bigint_helper_methods)]
120119
#![feature(const_black_box)]
@@ -145,7 +144,6 @@
145144
#![feature(const_replace)]
146145
#![feature(const_size_of_val)]
147146
#![feature(const_size_of_val_raw)]
148-
#![feature(const_slice_from_ref)]
149147
#![feature(const_strict_overflow_ops)]
150148
#![feature(const_swap)]
151149
#![feature(const_try)]

library/core/src/slice/raw.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ pub const fn from_ref<T>(s: &T) -> &[T] {
204204

205205
/// Converts a reference to T into a slice of length 1 (without copying).
206206
#[stable(feature = "from_ref", since = "1.28.0")]
207-
#[rustc_const_unstable(feature = "const_slice_from_ref", issue = "90206")]
207+
#[rustc_const_stable(feature = "const_slice_from_ref", since = "CURRENT_RUSTC_VERSION")]
208+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
208209
#[must_use]
209210
pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
210211
array::from_mut(s)

library/core/tests/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(clone_to_uninit)]
1717
#![feature(const_align_of_val_raw)]
1818
#![feature(const_align_offset)]
19-
#![feature(const_array_from_ref)]
2019
#![feature(const_black_box)]
2120
#![feature(const_hash)]
2221
#![feature(const_heap)]
@@ -31,7 +30,6 @@
3130
#![feature(const_pointer_is_aligned)]
3231
#![feature(const_ptr_write)]
3332
#![feature(const_result)]
34-
#![feature(const_slice_from_ref)]
3533
#![feature(const_three_way_compare)]
3634
#![feature(const_trait_impl)]
3735
#![feature(core_intrinsics)]

0 commit comments

Comments
 (0)