From 2a5a6680fcff4a1d429ac3c67764dab813afef40 Mon Sep 17 00:00:00 2001 From: woppopo Date: Mon, 13 Dec 2021 14:17:35 +0900 Subject: [PATCH] Make `MaybeUninit::zeroed` `const` --- library/core/src/mem/maybe_uninit.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 9a29094b52c46..783a4b08ec19f 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -394,10 +394,11 @@ impl MaybeUninit { /// // This is undefined behavior. ⚠️ /// ``` #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[rustc_const_unstable(feature = "const_maybe_uninit_zeroed", issue = "91850")] #[must_use] #[inline] #[rustc_diagnostic_item = "maybe_uninit_zeroed"] - pub fn zeroed() -> MaybeUninit { + pub const fn zeroed() -> MaybeUninit { let mut u = MaybeUninit::::uninit(); // SAFETY: `u.as_mut_ptr()` points to allocated memory. unsafe {