Skip to content

Commit

Permalink
Fix awkward wording.
Browse files Browse the repository at this point in the history
  • Loading branch information
theemathas committed Sep 13, 2024
1 parent 6fa092a commit f604ed6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions library/core/src/mem/manually_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,21 @@ use crate::ptr;
/// # Safety hazards when storing `ManuallyDrop` in a struct or an enum.
///
/// Special care is needed when all of the conditions below are met:
/// * A field of a struct or enum is a `ManuallyDrop` or contains a
/// `ManuallyDrop`, without the `ManuallyDrop` being inside a `union`.
/// * A struct or enum contains a `ManuallyDrop`.
/// * The `ManuallyDrop` is not inside a `union`.
/// * The struct or enum is part of public API, or is stored in a struct or an
/// enum that is part of public API.
/// * There is code outside of a `Drop` implementation that calls
/// [`ManuallyDrop::drop`] or [`ManuallyDrop::take`] on the `ManuallyDrop`
/// field.
/// * There is code that drops the contents of the `ManuallyDrop` field, and
/// this code is outside the struct or enum's `Drop` implementation.
///
/// In particular, the following hazards can occur:
/// In particular, the following hazards may occur:
///
/// #### Storing generic types
///
/// If the `ManuallyDrop` contains a client-supplied generic type, the client
/// might provide a `Box`, causing undefined behavior when the struct / enum is
/// later moved, as mentioned above. For example, the following code causes
/// undefined behavior:
/// might provide a `Box` as that type. This would cause undefined behavior when
/// the struct or enum is later moved, as mentioned in the previous section. For
/// example, the following code causes undefined behavior:
///
/// ```no_run
/// use std::mem::ManuallyDrop;
Expand Down Expand Up @@ -114,7 +113,7 @@ use crate::ptr;
/// #### Deriving traits
///
/// Deriving `Debug`, `Clone`, `PartialEq`, `PartialOrd`, `Ord`, or `Hash` on
/// the struct / enum could be unsound, since the derived implementations of
/// the struct or enum could be unsound, since the derived implementations of
/// these traits would access the `ManuallyDrop` field. For example, the
/// following code causes undefined behavior:
///
Expand Down

0 comments on commit f604ed6

Please sign in to comment.