diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-10-13 13:13:09 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2020-10-13 13:13:09 +0200 |
| commit | f83446b836900ce9afbaa0816a5b4feda654b51e (patch) | |
| tree | 2544e6cf2079d0b33010b76a117a828f6206b9f5 | |
| parent | 2c71f682d74d13ae6673dc701a9bb3a0562f57c0 (diff) | |
| download | rust-f83446b836900ce9afbaa0816a5b4feda654b51e.tar.gz rust-f83446b836900ce9afbaa0816a5b4feda654b51e.zip | |
Reword safety guarantee of Pin::static_{ref,mut}.
Co-authored-by: Peter Todd <pete@petertodd.org>
| -rw-r--r-- | library/core/src/pin.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index b27167a7e7c..633e96eb7d8 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -784,12 +784,12 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { impl<T: ?Sized> Pin<&'static T> { /// Get a pinned reference from a static reference. /// - /// This is safe, because the `'static` lifetime guarantees the data will - /// never be moved. + /// This is safe, because `T` is borrowed for the `'static` lifetime, which + /// never ends. #[unstable(feature = "pin_static_ref", issue = "none")] #[rustc_const_unstable(feature = "const_pin", issue = "76654")] pub const fn static_ref(r: &'static T) -> Pin<&'static T> { - // SAFETY: The 'static lifetime guarantees the data will not be + // SAFETY: The 'static borrow guarantees the data will not be // moved/invalidated until it gets dropped (which is never). unsafe { Pin::new_unchecked(r) } } @@ -798,12 +798,12 @@ impl<T: ?Sized> Pin<&'static T> { impl<T: ?Sized> Pin<&'static T> { /// Get a pinned mutable reference from a static mutable reference. /// - /// This is safe, because the `'static` lifetime guarantees the data will - /// never be moved. + /// This is safe, because `T` is borrowed for the `'static` lifetime, which + /// never ends. #[unstable(feature = "pin_static_ref", issue = "none")] #[rustc_const_unstable(feature = "const_pin", issue = "76654")] pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> { - // SAFETY: The 'static lifetime guarantees the data will not be + // SAFETY: The 'static borrow guarantees the data will not be // moved/invalidated until it gets dropped (which is never). unsafe { Pin::new_unchecked(r) } } |
