about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-05-17 01:31:15 +0000
committerbors <bors@rust-lang.org>2020-05-17 01:31:15 +0000
commit09739c22db948a7a2ed13e8f466cb22adb1d7818 (patch)
treedbb130c9403855e3f8e224690f1f9d1960c57be9 /src/libcore
parent0ec4b065243f38f711a55563bff7d0c66eea1b4a (diff)
parent1d09a7b693323a3cd4d7d32f6102f58854830f72 (diff)
Auto merge of #72286 - Dylan-DPC:rollup-n3rk6df, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #72233 (Fix {:#?} representation of proc_macro::Literal)
 - #72277 (emphasize that ManuallyDrop is safe-to-access and unsafe-to-drop)
 - #72281 (Fix whitespace in `?Sized` structured suggestion)
 - #72282 (Fix issue number typo in note)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/mem/manually_drop.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libcore/mem/manually_drop.rs b/src/libcore/mem/manually_drop.rs
index 17863dd38af..18767c482c7 100644
--- a/src/libcore/mem/manually_drop.rs
+++ b/src/libcore/mem/manually_drop.rs
@@ -2,7 +2,6 @@ use crate::ops::{Deref, DerefMut};
 use crate::ptr;
 
 /// A wrapper to inhibit compiler from automatically calling `T`’s destructor.
-///
 /// This wrapper is 0-cost.
 ///
 /// `ManuallyDrop<T>` is subject to the same layout optimizations as `T`.
@@ -11,6 +10,11 @@ use crate::ptr;
 /// with [`mem::zeroed`] is undefined behavior.
 /// If you need to handle uninitialized data, use [`MaybeUninit<T>`] instead.
 ///
+/// Note that accessing the value inside a `ManuallyDrop<T>` is safe.
+/// This means that a `ManuallyDrop<T>` whose content has been dropped must not
+/// be exposed through a public safe API.
+/// Correspondingly, `ManuallyDrop::drop` is unsafe.
+///
 /// # Examples
 ///
 /// This wrapper can be used to enforce a particular drop order on fields, regardless