Reword safety guarantee of Pin::static_{ref,mut}.

Co-authored-by: Peter Todd <pete@petertodd.org>
This commit is contained in:
Mara Bos 2020-10-13 13:13:09 +02:00
parent 2c71f682d7
commit f83446b836
1 changed files with 6 additions and 6 deletions

View File

@ -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) }
}