From: Ralf Jung Date: Tue, 19 Feb 2019 20:23:53 +0000 (+0100) Subject: improve linked list -> drop transition X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=2c6981a315df920fa83607bc3f858e39af5abfde;p=rust.git improve linked list -> drop transition --- diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index 5056005bcd7..68213ab0153 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -124,8 +124,11 @@ //! list element will patch the pointers of its predecessor and successor to remove itself //! from the list. //! -//! To make this work, it is crucial that we can actually rely on `drop` being called. -//! And, in fact, this is a guarantee that `Pin` provides. +//! Crucially, we have to be able to rely on `drop` being called. If an element +//! could be deallocated or otherwise invalidated without calling `drop`, the pointers into it +//! from its neighbouring elements would become invalid, which would break the data structure. +//! +//! This is why pinning also comes with a `drop`-related guarantee. //! //! # `Drop` guarantee //! @@ -139,9 +142,7 @@ //! off of a vector. //! //! This is exactly the kind of guarantee that the intrusive linked list from the previous -//! section needs to function correctly. Clearly, if an element -//! could be deallocated or otherwise invalidated without calling `drop`, the pointers into it -//! from its neighbouring elements would become invalid, which would break the data structure. +//! section needs to function correctly. //! //! Notice that this guarantee does *not* mean that memory does not leak! It is still //! completely okay not to ever call `drop` on a pinned element (e.g., you can still