Skip to content

Commit

Permalink
Rollup merge of #71607 - RalfJung:pin-drop-panic, r=nikomatsakis
Browse files Browse the repository at this point in the history
clarify interaction of pin drop guarantee and panics

Cc rust-lang/unsafe-code-guidelines#232
@Diggsey would this have helped?
  • Loading branch information
RalfJung committed May 22, 2020
2 parents 458a3e7 + 33541d5 commit a819f42
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@
//! otherwise invalidating the memory used to store the data is restricted, too.
//! Concretely, for pinned data you have to maintain the invariant
//! that *its memory will not get invalidated or repurposed from the moment it gets pinned until
//! when [`drop`] is called*. Memory can be invalidated by deallocation, but also by
//! when [`drop`] is called*. Only once [`drop`] returns or panics, the memory may be reused.
//!
//! Memory can be "invalidated" by deallocation, but also by
//! replacing a [`Some(v)`] by [`None`], or calling [`Vec::set_len`] to "kill" some elements
//! off of a vector. It can be repurposed by using [`ptr::write`] to overwrite it without
//! calling the destructor first.
//! calling the destructor first. None of this is allowed for pinned data without calling [`drop`].
//!
//! This is exactly the kind of guarantee that the intrusive linked list from the previous
//! section needs to function correctly.
Expand Down

0 comments on commit a819f42

Please sign in to comment.