Skip to content

Commit a79f9af

Browse files
authored
Rollup merge of #75780 - matklad:unconfuseunpindocs, r=KodrAus
Unconfuse Unpin docs a bit * Don't say that Unpin is used to prevent moves, because it is used to *allow* moves * Be more precise about kindedness of things, it is `Pin<Pointer<Data>>`, rather than just `Pin<Pointer>`.
2 parents 730449d + daa6620 commit a79f9af

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

library/core/src/marker.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -728,23 +728,23 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
728728

729729
/// Types that can be safely moved after being pinned.
730730
///
731-
/// Since Rust itself has no notion of immovable types, and considers moves
732-
/// (e.g., through assignment or [`mem::replace`]) to always be safe,
733-
/// this trait cannot prevent types from moving by itself.
731+
/// Rust itself has no notion of immovable types, and considers moves (e.g.,
732+
/// through assignment or [`mem::replace`]) to always be safe.
734733
///
735-
/// Instead it is used to prevent moves through the type system,
736-
/// by controlling the behavior of pointers `P` wrapped in the [`Pin<P>`] wrapper,
737-
/// which "pin" the type in place by not allowing it to be moved out of them.
738-
/// See the [`pin module`] documentation for more information on pinning.
734+
/// The [`Pin`][Pin] type is used instead to prevent moves through the type
735+
/// system. Pointers `P<T>` wrapped in the [`Pin<P<T>>`][Pin] wrapper can't be
736+
/// moved out of. See the [`pin module`] documentation for more information on
737+
/// pinning.
739738
///
740-
/// Implementing this trait lifts the restrictions of pinning off a type,
741-
/// which then allows it to move out with functions such as [`mem::replace`].
739+
/// Implementing the `Unpin` trait for `T` lifts the restrictions of pinning off
740+
/// the type, which then allows moving `T` out of [`Pin<P<T>>`][Pin] with
741+
/// functions such as [`mem::replace`].
742742
///
743743
/// `Unpin` has no consequence at all for non-pinned data. In particular,
744744
/// [`mem::replace`] happily moves `!Unpin` data (it works for any `&mut T`, not
745-
/// just when `T: Unpin`). However, you cannot use
746-
/// [`mem::replace`] on data wrapped inside a [`Pin<P>`] because you cannot get the
747-
/// `&mut T` you need for that, and *that* is what makes this system work.
745+
/// just when `T: Unpin`). However, you cannot use [`mem::replace`] on data
746+
/// wrapped inside a [`Pin<P<T>>`][Pin] because you cannot get the `&mut T` you
747+
/// need for that, and *that* is what makes this system work.
748748
///
749749
/// So this, for example, can only be done on types implementing `Unpin`:
750750
///
@@ -765,8 +765,8 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
765765
/// This trait is automatically implemented for almost every type.
766766
///
767767
/// [`mem::replace`]: ../../std/mem/fn.replace.html
768-
/// [`Pin<P>`]: ../pin/struct.Pin.html
769-
/// [`pin module`]: ../../std/pin/index.html
768+
/// [Pin]: crate::pin::Pin
769+
/// [`pin module`]: crate::pin
770770
#[stable(feature = "pin", since = "1.33.0")]
771771
#[rustc_on_unimplemented(
772772
on(_Self = "std::future::Future", note = "consider using `Box::pin`",),

0 commit comments

Comments
 (0)