diff options
| author | woppopo <woppopo@protonmail.com> | 2021-12-13 14:17:35 +0900 |
|---|---|---|
| committer | woppopo <woppopo@protonmail.com> | 2021-12-13 14:17:35 +0900 |
| commit | 2a5a6680fcff4a1d429ac3c67764dab813afef40 (patch) | |
| tree | 8c6a5af4b852c356eadd2530944592b6deec65dc | |
| parent | f7fd79ac1d485ab47b62146f6dafed4aad5d9c6d (diff) | |
| download | rust-2a5a6680fcff4a1d429ac3c67764dab813afef40.tar.gz rust-2a5a6680fcff4a1d429ac3c67764dab813afef40.zip | |
Make `MaybeUninit::zeroed` `const`
| -rw-r--r-- | library/core/src/mem/maybe_uninit.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 9a29094b52c..783a4b08ec1 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -394,10 +394,11 @@ impl<T> MaybeUninit<T> { /// // 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<T> { + pub const fn zeroed() -> MaybeUninit<T> { let mut u = MaybeUninit::<T>::uninit(); // SAFETY: `u.as_mut_ptr()` points to allocated memory. unsafe { |
