1
Fork 0

Rollup merge of #67559 - Mark-Simulacrum:drop-doc, r=RalfJung

Document that calling Drop, even after it panics, is UB

Fixes #60822.

r? @gnzlbg
This commit is contained in:
Mazdak Farrokhzad 2019-12-23 15:16:32 +01:00 committed by GitHub
commit 68a9a2d648
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}