diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 61d70a62dca..7f500af59a8 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1899,7 +1899,7 @@ impl Weak { // a valid pointer, so that `from_raw` can reverse this transformation. (ptr as *mut T).set_ptr_value(ptr::null_mut()) } else { - // SAFETY: If the pointer is not dangling, it describes to a valid allocation. + // SAFETY: If the pointer is not dangling, it references a valid allocation. // The payload may be dropped at this point, and we have to maintain provenance, // so use raw pointer manipulation. unsafe { &raw mut (*ptr).value } @@ -1991,8 +1991,8 @@ impl Weak { // SAFETY: this is the same sentinel as used in Weak::new and is_dangling (ptr as *mut RcBox).set_ptr_value(usize::MAX as *mut _) } else { - // Otherwise, this describes a real allocation. - // SAFETY: data_offset is safe to call, as ptr describes a real allocation. + // Otherwise, this references a real allocation. + // SAFETY: data_offset is safe to call, as ptr references a real (potentially dropped) T. let offset = unsafe { data_offset(ptr) }; // Thus, we reverse the offset to get the whole RcBox. // SAFETY: the pointer originated from a Weak, so this offset is safe. @@ -2320,8 +2320,7 @@ impl AsRef for Rc { #[stable(feature = "pin", since = "1.33.0")] impl Unpin for Rc {} -/// Get the offset within an `RcBox` for -/// a payload of type described by a pointer. +/// Get the offset within an `RcBox` for the payload behind a pointer. /// /// # Safety /// diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 1ca6b6d6335..e2811a5cd6c 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1685,7 +1685,7 @@ impl Weak { // a valid pointer, so that `from_raw` can reverse this transformation. (ptr as *mut T).set_ptr_value(ptr::null_mut()) } else { - // SAFETY: If the pointer is not dangling, it describes to a valid allocation. + // SAFETY: If the pointer is not dangling, it references a valid allocation. // The payload may be dropped at this point, and we have to maintain provenance, // so use raw pointer manipulation. unsafe { &raw mut (*ptr).data } @@ -1777,8 +1777,8 @@ impl Weak { // SAFETY: this is the same sentinel as used in Weak::new and is_dangling (ptr as *mut ArcInner).set_ptr_value(usize::MAX as *mut _) } else { - // Otherwise, this describes a real allocation. - // SAFETY: data_offset is safe to call, as ptr describes a real allocation. + // Otherwise, this references a real allocation. + // SAFETY: data_offset is safe to call, as ptr references a real (potentially dropped) T. let offset = unsafe { data_offset(ptr) }; // Thus, we reverse the offset to get the whole RcBox. // SAFETY: the pointer originated from a Weak, so this offset is safe. @@ -2471,8 +2471,7 @@ impl AsRef for Arc { #[stable(feature = "pin", since = "1.33.0")] impl Unpin for Arc {} -/// Get the offset within an `ArcInner` for -/// a payload of type described by a pointer. +/// Get the offset within an `ArcInner` for the payload behind a pointer. /// /// # Safety ///