Skip to content

Commit 68a9a2d

Browse files
authored
Rollup merge of #67559 - Mark-Simulacrum:drop-doc, r=RalfJung
Document that calling Drop, even after it panics, is UB Fixes #60822. r? @gnzlbg
2 parents 7eb025f + a08df28 commit 68a9a2d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/libcore/ops/drop.rs

+6
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,15 @@ pub trait Drop {
9999
/// Given that a [`panic!`] will call `drop` as it unwinds, any [`panic!`]
100100
/// in a `drop` implementation will likely abort.
101101
///
102+
/// Note that even if this panics, the value is considered to be dropped;
103+
/// you must not cause `drop` to be called again. This is normally automatically
104+
/// handled by the compiler, but when using unsafe code, can sometimes occur
105+
/// unintentionally, particularly when using [`std::ptr::drop_in_place`].
106+
///
102107
/// [E0040]: ../../error-index.html#E0040
103108
/// [`panic!`]: ../macro.panic.html
104109
/// [`std::mem::drop`]: ../../std/mem/fn.drop.html
110+
/// [`std::ptr::drop_in_place`]: ../../std/ptr/fn.drop_in_place.html
105111
#[stable(feature = "rust1", since = "1.0.0")]
106112
fn drop(&mut self);
107113
}

0 commit comments

Comments
 (0)