From af96b1df1da916561547dd30b3187b30308d6843 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 3 Jul 2019 21:45:17 -0400 Subject: [PATCH] Document that ManuallyDrop::drop should not called more than once Double dropping is unsound (e.g. https://github.com/rust-lang/rust/issues/60977). This commit documents the fact that `ManuallyDrop::drop` should not be called multiple times on the same instance, as it might not be immediately obvious that this counts as a use of uninitialized data. --- src/libcore/mem/manually_drop.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcore/mem/manually_drop.rs b/src/libcore/mem/manually_drop.rs index 3ad1223e331e..5d4309025080 100644 --- a/src/libcore/mem/manually_drop.rs +++ b/src/libcore/mem/manually_drop.rs @@ -118,7 +118,8 @@ impl ManuallyDrop { /// /// This function runs the destructor of the contained value and thus the wrapped value /// now represents uninitialized data. It is up to the user of this method to ensure the - /// uninitialized data is not actually used. + /// uninitialized data is not actually used, and that this function is called at most once + /// for a given instance of ManuallyDrop /// /// [`ManuallyDrop::into_inner`]: #method.into_inner #[stable(feature = "manually_drop", since = "1.20.0")]