Reclarify safety comments in Weak::as_ptr

This commit is contained in:
CAD97 2020-07-01 16:01:34 -04:00
parent 98789ac75a
commit 7498cad0d8
2 changed files with 6 additions and 6 deletions

View file

@ -1705,9 +1705,9 @@ impl<T> Weak<T> {
let ptr: *mut RcBox<T> = NonNull::as_ptr(self.ptr);
// SAFETY: we must offset the pointer manually, and said pointer may be
// a dangling weak (usize::MAX). data_offset is safe to call, because we
// know a pointer to unsized T must be derived from a real unsized T,
// because dangling weaks are only created for sized T. wrapping_offset
// a dangling weak (usize::MAX) if T is sized. data_offset is safe to call,
// because we know that a pointer to unsized T was derived from a real
// unsized T, as dangling weaks are only created for sized T. wrapping_offset
// is used so that we can use the same code path for the non-dangling
// unsized case and the potentially dangling sized case.
unsafe {

View file

@ -1473,9 +1473,9 @@ impl<T> Weak<T> {
let ptr: *mut ArcInner<T> = NonNull::as_ptr(self.ptr);
// SAFETY: we must offset the pointer manually, and said pointer may be
// a dangling weak (usize::MAX). data_offset is safe to call, because we
// know a pointer to unsized T must be derived from a real unsized T,
// because dangling weaks are only created for sized T. wrapping_offset
// a dangling weak (usize::MAX) if T is sized. data_offset is safe to call,
// because we know that a pointer to unsized T was derived from a real
// unsized T, as dangling weaks are only created for sized T. wrapping_offset
// is used so that we can use the same code path for the non-dangling
// unsized case and the potentially dangling sized case.
unsafe {