Skip to content

Commit

Permalink
Reword safety guarantee of Pin::static_{ref,mut}.
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Todd <pete@petertodd.org>
  • Loading branch information
m-ou-se and petertodd committed Oct 13, 2020
1 parent 2c71f68 commit f83446b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand All @@ -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) }
}
Expand Down

0 comments on commit f83446b

Please sign in to comment.