From bcc78bdc29ed8183f60b3275ce8ac292bd771ab4 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` --- library/core/src/lib.rs | 1 - library/core/src/str/converts.rs | 1 + library/core/src/str/mod.rs | 6 ++++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 9edc1a8c1f5..ba30c4eab11 100644 --- a/library/core/src/lib.rs +++ b/library/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/library/core/src/str/converts.rs b/library/core/src/str/converts.rs index e932b652e2d..194db56fdaf 100644 --- a/library/core/src/str/converts.rs +++ b/library/core/src/str/converts.rs @@ -195,6 +195,7 @@ pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { #[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/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 3d535214637..e93c52f2799 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -339,7 +339,8 @@ pub const fn as_bytes(&self) -> &[u8] { /// 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 @@ pub const fn as_ptr(&self) -> *const u8 { /// 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)]