@@ -15,7 +15,7 @@ use crate::ptr;
1515/// that a `ManuallyDrop<T>` whose content has been dropped must not be exposed
1616/// through a public safe API. Correspondingly, `ManuallyDrop::drop` is unsafe.
1717///
18- /// # `ManuallyDrop` and drop order.
18+ /// # `ManuallyDrop` and drop order
1919///
2020/// Rust has a well-defined [drop order] of values. To make sure that fields or
2121/// locals are dropped in a specific order, reorder the declarations such that
@@ -39,7 +39,7 @@ use crate::ptr;
3939/// }
4040/// ```
4141///
42- /// # Interaction with `Box`.
42+ /// # Interaction with `Box`
4343///
4444/// Currently, once the `Box<T>` inside a `ManuallyDrop<Box<T>>` is dropped,
4545/// moving the `ManuallyDrop<Box<T>>` is [considered to be undefined
@@ -56,16 +56,17 @@ use crate::ptr;
5656/// let y = x; // Undefined behavior!
5757/// ```
5858///
59- /// This may change in the future. In the meantime, consider using
60- /// [`MaybeUninit`] instead.
59+ /// This is [likely to change in the
60+ /// future](https://rust-lang.github.io/rfcs/3336-maybe-dangling.html). In the
61+ /// meantime, consider using [`MaybeUninit`] instead.
6162///
62- /// # Safety hazards when storing `ManuallyDrop` in a struct / enum.
63+ /// # Safety hazards when storing `ManuallyDrop` in a struct or an enum.
6364///
6465/// Special care is needed when all of the conditions below are met:
6566/// * A field of a struct or enum is a `ManuallyDrop` or contains a
6667/// `ManuallyDrop`, without the `ManuallyDrop` being inside a `union`.
67- /// * The struct or enum is part of public API, or is stored in a struct or enum
68- /// that is part of public API.
68+ /// * The struct or enum is part of public API, or is stored in a struct or an
69+ /// enum that is part of public API.
6970/// * There is code outside of a `Drop` implementation that calls
7071/// [`ManuallyDrop::drop`] or [`ManuallyDrop::take`] on the `ManuallyDrop`
7172/// field.
@@ -120,14 +121,15 @@ use crate::ptr;
120121/// ```no_run
121122/// use std::mem::ManuallyDrop;
122123///
123- /// #[derive(Debug)] // This is unsound!
124+ /// // This derive is unsound in combination with the `ManuallyDrop::drop` call.
125+ /// #[derive(Debug)]
124126/// pub struct Foo {
125127/// value: ManuallyDrop<String>,
126128/// }
127129/// impl Foo {
128130/// pub fn new() -> Self {
129131/// let mut temp = Self {
130- /// value: ManuallyDrop::new(String::from("Unsafe rust is hard"))
132+ /// value: ManuallyDrop::new(String::from("Unsafe rust is hard. "))
131133/// };
132134/// unsafe {
133135/// // SAFETY: `value` hasn't been dropped yet.
0 commit comments