Skip to content

Commit fbfd542

Browse files
authored
Rollup merge of rust-lang#62360 - Aaron1011:patch-2, r=RalfJung
Document that ManuallyDrop::drop should not called more than once Double dropping is unsound (e.g. rust-lang#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.
2 parents a4cd2ec + a93f4ab commit fbfd542

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libcore/mem/manually_drop.rs

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ impl<T: ?Sized> ManuallyDrop<T> {
119119
/// This function runs the destructor of the contained value and thus the wrapped value
120120
/// now represents uninitialized data. It is up to the user of this method to ensure the
121121
/// uninitialized data is not actually used.
122+
/// In particular, this function can only be called called at most once
123+
/// for a given instance of `ManuallyDrop<T>`.
122124
///
123125
/// [`ManuallyDrop::into_inner`]: #method.into_inner
124126
#[stable(feature = "manually_drop", since = "1.20.0")]

0 commit comments

Comments
 (0)