diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-23 15:16:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-23 15:16:32 +0100 |
| commit | 68a9a2d64888be73fda2d00ea1f5c121bc08164b (patch) | |
| tree | 94ea2d34cd99239633126bd50f0f0a5663e233b3 /src/libcore | |
| parent | 7eb025febf48c294e376cedd4b57865792cefa99 (diff) | |
| parent | a08df28a6fdb5a2c781f01082e630faa2d7ccde9 (diff) | |
| download | rust-68a9a2d64888be73fda2d00ea1f5c121bc08164b.tar.gz rust-68a9a2d64888be73fda2d00ea1f5c121bc08164b.zip | |
Rollup merge of #67559 - Mark-Simulacrum:drop-doc, r=RalfJung
Document that calling Drop, even after it panics, is UB Fixes #60822. r? @gnzlbg
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ops/drop.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libcore/ops/drop.rs b/src/libcore/ops/drop.rs index eae63ea2390..5233b475c46 100644 --- a/src/libcore/ops/drop.rs +++ b/src/libcore/ops/drop.rs @@ -99,9 +99,15 @@ pub trait Drop { /// Given that a [`panic!`] will call `drop` as it unwinds, any [`panic!`] /// in a `drop` implementation will likely abort. /// + /// Note that even if this panics, the value is considered to be dropped; + /// you must not cause `drop` to be called again. This is normally automatically + /// handled by the compiler, but when using unsafe code, can sometimes occur + /// unintentionally, particularly when using [`std::ptr::drop_in_place`]. + /// /// [E0040]: ../../error-index.html#E0040 /// [`panic!`]: ../macro.panic.html /// [`std::mem::drop`]: ../../std/mem/fn.drop.html + /// [`std::ptr::drop_in_place`]: ../../std/ptr/fn.drop_in_place.html #[stable(feature = "rust1", since = "1.0.0")] fn drop(&mut self); } |
