File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -217,8 +217,13 @@ pub trait Drop {
217217 ///
218218 /// # Panics
219219 ///
220- /// Given that a [`panic!`] will call `drop` as it unwinds, any [`panic!`]
221- /// in a `drop` implementation will likely abort.
220+ /// Implementations should generally avoid [`panic!`]ing, because `drop()` may itself be called
221+ /// during unwinding due to a panic, and if the `drop()` panics in that situation (a “double
222+ /// panic”), this will likely abort the program. It is possible to check [`panicking()`] first,
223+ /// which may be desirable for a `Drop` implementation that is reporting a bug of the kind
224+ /// “you didn't finish using this before it was dropped”; but most types should simply clean up
225+ /// their owned allocations or other resources and return normally from `drop()`, regardless of
226+ /// what state they are in.
222227 ///
223228 /// Note that even if this panics, the value is considered to be dropped;
224229 /// you must not cause `drop` to be called again. This is normally automatically
@@ -227,6 +232,7 @@ pub trait Drop {
227232 ///
228233 /// [E0040]: ../../error_codes/E0040.html
229234 /// [`panic!`]: crate::panic!
235+ /// [`panicking()`]: ../../std/thread/fn.panicking.html
230236 /// [`mem::drop`]: drop
231237 /// [`ptr::drop_in_place`]: crate::ptr::drop_in_place
232238 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments