Skip to content

Commit f83446b

Browse files
m-ou-sepetertodd
andcommitted
Reword safety guarantee of Pin::static_{ref,mut}.
Co-authored-by: Peter Todd <[email protected]>
1 parent 2c71f68 commit f83446b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

library/core/src/pin.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,12 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
784784
impl<T: ?Sized> Pin<&'static T> {
785785
/// Get a pinned reference from a static reference.
786786
///
787-
/// This is safe, because the `'static` lifetime guarantees the data will
788-
/// never be moved.
787+
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
788+
/// never ends.
789789
#[unstable(feature = "pin_static_ref", issue = "none")]
790790
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
791791
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
792-
// SAFETY: The 'static lifetime guarantees the data will not be
792+
// SAFETY: The 'static borrow guarantees the data will not be
793793
// moved/invalidated until it gets dropped (which is never).
794794
unsafe { Pin::new_unchecked(r) }
795795
}
@@ -798,12 +798,12 @@ impl<T: ?Sized> Pin<&'static T> {
798798
impl<T: ?Sized> Pin<&'static T> {
799799
/// Get a pinned mutable reference from a static mutable reference.
800800
///
801-
/// This is safe, because the `'static` lifetime guarantees the data will
802-
/// never be moved.
801+
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
802+
/// never ends.
803803
#[unstable(feature = "pin_static_ref", issue = "none")]
804804
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
805805
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
806-
// SAFETY: The 'static lifetime guarantees the data will not be
806+
// SAFETY: The 'static borrow guarantees the data will not be
807807
// moved/invalidated until it gets dropped (which is never).
808808
unsafe { Pin::new_unchecked(r) }
809809
}

0 commit comments

Comments
 (0)