Skip to content

Commit

Permalink
Document that calling Drop, even after it panics, is UB
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Dec 23, 2019
1 parent a916ac2 commit a08df28
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libcore/ops/drop.rs
Expand Up @@ -99,9 +99,15 @@ pub trait Drop {
/// Given that a [`panic!`] will call `drop` as it unwinds, any [`panic!`] /// Given that a [`panic!`] will call `drop` as it unwinds, any [`panic!`]
/// in a `drop` implementation will likely abort. /// 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 /// [E0040]: ../../error-index.html#E0040
/// [`panic!`]: ../macro.panic.html /// [`panic!`]: ../macro.panic.html
/// [`std::mem::drop`]: ../../std/mem/fn.drop.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")] #[stable(feature = "rust1", since = "1.0.0")]
fn drop(&mut self); fn drop(&mut self);
} }

0 comments on commit a08df28

Please sign in to comment.