diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-28 21:19:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-28 21:19:52 +0200 |
| commit | fbfd542277e8f0e9703dd7f2696b86c633629c79 (patch) | |
| tree | 3c4c95aba8cc8170d20be603b5758c2d32a477ea /src/libcore/mem | |
| parent | a4cd2ecab2240007e877759421fe0929ad74301b (diff) | |
| parent | a93f4abe24019e2dbe1e8f9bffae01d91d5079e0 (diff) | |
Rollup merge of #62360 - Aaron1011:patch-2, r=RalfJung
Document that ManuallyDrop::drop should not called more than once Double dropping is unsound (e.g. https://github.com/rust-lang/rust/issues/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.
Diffstat (limited to 'src/libcore/mem')
| -rw-r--r-- | src/libcore/mem/manually_drop.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libcore/mem/manually_drop.rs b/src/libcore/mem/manually_drop.rs index 3ad1223e331..bb353993236 100644 --- a/src/libcore/mem/manually_drop.rs +++ b/src/libcore/mem/manually_drop.rs @@ -119,6 +119,8 @@ impl<T: ?Sized> ManuallyDrop<T> { /// This function runs the destructor of the contained value and thus the wrapped value /// now represents uninitialized data. It is up to the user of this method to ensure the /// uninitialized data is not actually used. + /// In particular, this function can only be called called at most once + /// for a given instance of `ManuallyDrop<T>`. /// /// [`ManuallyDrop::into_inner`]: #method.into_inner #[stable(feature = "manually_drop", since = "1.20.0")] |
