Skip to content

Commit 75e8d65

Browse files
authored
Rollup merge of #91851 - woppopo:const_maybeuninit_zeroed, r=yaahc
Make `MaybeUninit::zeroed` `const` Tracking issue: #91850 ```rust // core::mem impl<T> MaybeUninit<T> { pub const fn zeroed() -> MaybeUninit<T>; } ```
2 parents dfec47f + 2a5a668 commit 75e8d65

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/core/src/mem/maybe_uninit.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,11 @@ impl<T> MaybeUninit<T> {
394394
/// // This is undefined behavior. ⚠️
395395
/// ```
396396
#[stable(feature = "maybe_uninit", since = "1.36.0")]
397+
#[rustc_const_unstable(feature = "const_maybe_uninit_zeroed", issue = "91850")]
397398
#[must_use]
398399
#[inline]
399400
#[rustc_diagnostic_item = "maybe_uninit_zeroed"]
400-
pub fn zeroed() -> MaybeUninit<T> {
401+
pub const fn zeroed() -> MaybeUninit<T> {
401402
let mut u = MaybeUninit::<T>::uninit();
402403
// SAFETY: `u.as_mut_ptr()` points to allocated memory.
403404
unsafe {

0 commit comments

Comments
 (0)