Skip to content

Commit 02f2b31

Browse files
committed
Auto merge of #89769 - jkugelman:must-use-maybe-uninit-new, r=joshtriplett
Add #[must_use] to MaybeUninit::new As discussed in #89729 (comment). Parent issue: #89692 r? `@joshtriplett`
2 parents ffdf18d + b0b09f0 commit 02f2b31

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/core/src/mem/maybe_uninit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ impl<T> MaybeUninit<T> {
291291
/// [`assume_init`]: MaybeUninit::assume_init
292292
#[stable(feature = "maybe_uninit", since = "1.36.0")]
293293
#[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")]
294+
#[must_use = "use `forget` to avoid running Drop code"]
294295
#[inline(always)]
295296
pub const fn new(val: T) -> MaybeUninit<T> {
296297
MaybeUninit { value: ManuallyDrop::new(val) }

0 commit comments

Comments
 (0)