From 1ed32c51fb2fc571c67b1303721ea772a9c468d6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 14 Oct 2024 18:32:54 -0400 Subject: [PATCH] Stabilize `const_maybe_uninit_write` Mark the following API const stable: impl MaybeUninit { pub const fn write(&mut self, val: T) -> &mut T; } This depends on `const_mut_refs` and `const_maybe_uninit_assume_init`, both of which have recently been stabilized. Tracking issue: --- library/alloc/src/lib.rs | 1 - library/core/src/mem/maybe_uninit.rs | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 50bf385d671e3..043c00d79edca 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -110,7 +110,6 @@ #![feature(const_box)] #![feature(const_eval_select)] #![feature(const_heap)] -#![feature(const_maybe_uninit_write)] #![feature(const_pin)] #![feature(const_size_of_val)] #![feature(const_vec_string_slice)] diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index f992785c43bb7..b3398ca59e185 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -485,9 +485,10 @@ impl MaybeUninit { /// } /// } /// ``` - #[stable(feature = "maybe_uninit_write", since = "1.55.0")] - #[rustc_const_unstable(feature = "const_maybe_uninit_write", issue = "63567")] #[inline(always)] + #[stable(feature = "maybe_uninit_write", since = "1.55.0")] + #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))] + #[rustc_const_stable(feature = "const_maybe_uninit_write", since = "CURRENT_RUSTC_VERSION")] pub const fn write(&mut self, val: T) -> &mut T { *self = MaybeUninit::new(val); // SAFETY: We just initialized this value.