Auto merge of #89769 - jkugelman:must-use-maybe-uninit-new, r=joshtriplett

Add #[must_use] to MaybeUninit::new

As discussed in https://github.com/rust-lang/rust/pull/89729#issuecomment-939775659.

Parent issue: #89692

r? `@joshtriplett`
This commit is contained in:
bors 2021-10-12 07:02:53 +00:00
commit 02f2b31e61

View File

@ -291,6 +291,7 @@ impl<T> MaybeUninit<T> {
/// [`assume_init`]: MaybeUninit::assume_init /// [`assume_init`]: MaybeUninit::assume_init
#[stable(feature = "maybe_uninit", since = "1.36.0")] #[stable(feature = "maybe_uninit", since = "1.36.0")]
#[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")] #[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")]
#[must_use = "use `forget` to avoid running Drop code"]
#[inline(always)] #[inline(always)]
pub const fn new(val: T) -> MaybeUninit<T> { pub const fn new(val: T) -> MaybeUninit<T> {
MaybeUninit { value: ManuallyDrop::new(val) } MaybeUninit { value: ManuallyDrop::new(val) }