Skip to content

Commit af96b1d

Browse files
authored
Document that ManuallyDrop::drop should not called more than once
Double dropping is unsound (e.g. #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.
1 parent 088b987 commit af96b1d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libcore/mem/manually_drop.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ impl<T: ?Sized> ManuallyDrop<T> {
118118
///
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
121-
/// uninitialized data is not actually used.
121+
/// uninitialized data is not actually used, and that this function is called at most once
122+
/// for a given instance of ManuallyDrop
122123
///
123124
/// [`ManuallyDrop::into_inner`]: #method.into_inner
124125
#[stable(feature = "manually_drop", since = "1.20.0")]

0 commit comments

Comments
 (0)