From 3ac0ae21d5c1a8222ad466e3c7c761199e547f1c Mon Sep 17 00:00:00 2001 From: John Kugelman Date: Mon, 11 Oct 2021 10:03:55 -0400 Subject: [PATCH 1/2] Add #[must_use] to MaybeUninit::new --- library/core/src/mem/maybe_uninit.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 9c88a62336161..6c5fc331837c0 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -291,6 +291,7 @@ impl MaybeUninit { /// [`assume_init`]: MaybeUninit::assume_init #[stable(feature = "maybe_uninit", since = "1.36.0")] #[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")] + #[must_use = "use `ManuallyDrop` or `forget` to avoid running drop code"] #[inline(always)] pub const fn new(val: T) -> MaybeUninit { MaybeUninit { value: ManuallyDrop::new(val) } From b0b09f0842734b6594dbe3aa24cf4e01edcb9f49 Mon Sep 17 00:00:00 2001 From: John Kugelman Date: Mon, 11 Oct 2021 14:46:08 -0400 Subject: [PATCH 2/2] Update library/core/src/mem/maybe_uninit.rs Co-authored-by: Josh Triplett --- library/core/src/mem/maybe_uninit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 6c5fc331837c0..98c6f99abdee6 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -291,7 +291,7 @@ impl MaybeUninit { /// [`assume_init`]: MaybeUninit::assume_init #[stable(feature = "maybe_uninit", since = "1.36.0")] #[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")] - #[must_use = "use `ManuallyDrop` or `forget` to avoid running drop code"] + #[must_use = "use `forget` to avoid running Drop code"] #[inline(always)] pub const fn new(val: T) -> MaybeUninit { MaybeUninit { value: ManuallyDrop::new(val) }