@@ -63,22 +63,21 @@ use crate::ptr;
63
63
/// # Safety hazards when storing `ManuallyDrop` in a struct or an enum.
64
64
///
65
65
/// Special care is needed when all of the conditions below are met:
66
- /// * A field of a struct or enum is a `ManuallyDrop` or contains a
67
- /// `ManuallyDrop`, without the `ManuallyDrop` being inside a `union`.
66
+ /// * A struct or enum contains a `ManuallyDrop`.
67
+ /// * The `ManuallyDrop` is not inside a `union`.
68
68
/// * The struct or enum is part of public API, or is stored in a struct or an
69
69
/// enum that is part of public API.
70
- /// * There is code outside of a `Drop` implementation that calls
71
- /// [`ManuallyDrop::drop`] or [`ManuallyDrop::take`] on the `ManuallyDrop`
72
- /// field.
70
+ /// * There is code that drops the contents of the `ManuallyDrop` field, and
71
+ /// this code is outside the struct or enum's `Drop` implementation.
73
72
///
74
- /// In particular, the following hazards can occur:
73
+ /// In particular, the following hazards may occur:
75
74
///
76
75
/// #### Storing generic types
77
76
///
78
77
/// If the `ManuallyDrop` contains a client-supplied generic type, the client
79
- /// might provide a `Box`, causing undefined behavior when the struct / enum is
80
- /// later moved, as mentioned above. For example, the following code causes
81
- /// undefined behavior:
78
+ /// might provide a `Box` as that type. This would cause undefined behavior when
79
+ /// the struct or enum is later moved, as mentioned in the previous section. For
80
+ /// example, the following code causes undefined behavior:
82
81
///
83
82
/// ```no_run
84
83
/// use std::mem::ManuallyDrop;
@@ -114,7 +113,7 @@ use crate::ptr;
114
113
/// #### Deriving traits
115
114
///
116
115
/// Deriving `Debug`, `Clone`, `PartialEq`, `PartialOrd`, `Ord`, or `Hash` on
117
- /// the struct / enum could be unsound, since the derived implementations of
116
+ /// the struct or enum could be unsound, since the derived implementations of
118
117
/// these traits would access the `ManuallyDrop` field. For example, the
119
118
/// following code causes undefined behavior:
120
119
///
0 commit comments