Skip to content

Commit a573c7c

Browse files
committed
footnote on dropping futures
1 parent 6a54ed7 commit a573c7c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/core/src/pin.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
//! for such a type to be implemented soundly, the pointer which points into `self`'s data must be
127127
//! proven valid whenever it is accessed. But if that value is *moved*, the pointer will still
128128
//! point to the old address where the value was located and not into the new location of `self`,
129-
//! thus becoming invalid. A key example of such self-referrential types are the state machines
129+
//! thus becoming invalid. A key example of such self-referential types are the state machines
130130
//! generated by the compiler to implement [`Future`] for `async fn`s.
131131
//!
132132
//! Such types that have an *address-sensitive* state usually follow a lifecycle
@@ -141,7 +141,7 @@
141141
//! * e.g. subsequent calls to [`poll`]
142142
//! 4. Before the value is invalidated (e.g. deallocated), it is *dropped*, giving it a chance to
143143
//! notify anything with pointers to itself that those pointers will be invalidated
144-
//! * e.g. [`drop`]ping the [`Future`]
144+
//! * e.g. [`drop`]ping the [`Future`] [^pin-drop-future]
145145
//!
146146
//! There are two possible ways to ensure the invariants required for 2. and 3. above (which
147147
//! apply to any address-sensitive type, not just self-referrential types) do not get broken.
@@ -196,6 +196,9 @@
196196
//! discussed with the second option by building a *shared contractual language* around the
197197
//! guarantees of "pinning" data.
198198
//!
199+
//! [^pin-drop-future]: Futures themselves do not ever need to notify other bits of code that
200+
//! they are being dropped, however data structures like stack-based intrusive linked lists do.
201+
//!
199202
//! ## Using [`Pin<Ptr>`] to pin values
200203
//!
201204
//! In order to pin a value, we wrap a *pointer to that value* (of some type `Ptr`) in a

0 commit comments

Comments
 (0)