From ecb0f03e4e280b159db0c057f3da6f2a3be8e994 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 27 Sep 2024 13:30:21 -0700 Subject: [PATCH] library: Stabilize `const_str_as_mut` Const-stabilizes: - `str::as_bytes_mut` - `str::as_mut_ptr` --- core/src/lib.rs | 1 - core/src/str/converts.rs | 1 + core/src/str/mod.rs | 6 ++++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/lib.rs b/core/src/lib.rs index 9edc1a8c1f588..ba30c4eab1180 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -151,7 +151,6 @@ #![feature(const_slice_from_raw_parts_mut)] #![feature(const_slice_from_ref)] #![feature(const_slice_split_at_mut)] -#![feature(const_str_as_mut)] #![feature(const_strict_overflow_ops)] #![feature(const_swap)] #![feature(const_try)] diff --git a/core/src/str/converts.rs b/core/src/str/converts.rs index e932b652e2dcc..194db56fdafda 100644 --- a/core/src/str/converts.rs +++ b/core/src/str/converts.rs @@ -195,6 +195,7 @@ pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str { #[inline] #[must_use] #[stable(feature = "str_mut_extras", since = "1.20.0")] +#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))] #[rustc_const_stable( feature = "const_str_from_utf8_unchecked_mut", since = "CURRENT_RUSTC_VERSION" diff --git a/core/src/str/mod.rs b/core/src/str/mod.rs index 3d535214637f6..e93c52f27999e 100644 --- a/core/src/str/mod.rs +++ b/core/src/str/mod.rs @@ -339,7 +339,8 @@ impl str { /// assert_eq!("🍔∈🌏", s); /// ``` #[stable(feature = "str_mut_extras", since = "1.20.0")] - #[rustc_const_unstable(feature = "const_str_as_mut", issue = "130086")] + #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))] + #[rustc_const_stable(feature = "const_str_as_mut", since = "CURRENT_RUSTC_VERSION")] #[must_use] #[inline(always)] pub const unsafe fn as_bytes_mut(&mut self) -> &mut [u8] { @@ -385,7 +386,8 @@ impl str { /// It is your responsibility to make sure that the string slice only gets /// modified in a way that it remains valid UTF-8. #[stable(feature = "str_as_mut_ptr", since = "1.36.0")] - #[rustc_const_unstable(feature = "const_str_as_mut", issue = "130086")] + #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))] + #[rustc_const_stable(feature = "const_str_as_mut", since = "CURRENT_RUSTC_VERSION")] #[rustc_never_returns_null_ptr] #[must_use] #[inline(always)]