File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1899,7 +1899,7 @@ impl<T: ?Sized> Weak<T> {
18991899 // a valid pointer, so that `from_raw` can reverse this transformation.
19001900 ( ptr as * mut T ) . set_ptr_value ( ptr:: null_mut ( ) )
19011901 } else {
1902- // SAFETY: If the pointer is not dangling, it references a valid allocation .
1902+ // SAFETY: if is_dangling returns false, then the pointer is dereferencable .
19031903 // The payload may be dropped at this point, and we have to maintain provenance,
19041904 // so use raw pointer manipulation.
19051905 unsafe { & raw mut ( * ptr) . value }
@@ -1991,7 +1991,7 @@ impl<T: ?Sized> Weak<T> {
19911991 // SAFETY: this is the same sentinel as used in Weak::new and is_dangling
19921992 ( ptr as * mut RcBox < T > ) . set_ptr_value ( usize:: MAX as * mut _ )
19931993 } else {
1994- // Otherwise, this references a real allocation .
1994+ // Otherwise, we're guaranteed the pointer came from a nondangling Weak .
19951995 // SAFETY: data_offset is safe to call, as ptr references a real (potentially dropped) T.
19961996 let offset = unsafe { data_offset ( ptr) } ;
19971997 // Thus, we reverse the offset to get the whole RcBox.
Original file line number Diff line number Diff line change @@ -1685,7 +1685,7 @@ impl<T: ?Sized> Weak<T> {
16851685 // a valid pointer, so that `from_raw` can reverse this transformation.
16861686 ( ptr as * mut T ) . set_ptr_value ( ptr:: null_mut ( ) )
16871687 } else {
1688- // SAFETY: If the pointer is not dangling, it references a valid allocation .
1688+ // SAFETY: if is_dangling returns false, then the pointer is dereferencable .
16891689 // The payload may be dropped at this point, and we have to maintain provenance,
16901690 // so use raw pointer manipulation.
16911691 unsafe { & raw mut ( * ptr) . data }
@@ -1777,7 +1777,7 @@ impl<T: ?Sized> Weak<T> {
17771777 // SAFETY: this is the same sentinel as used in Weak::new and is_dangling
17781778 ( ptr as * mut ArcInner < T > ) . set_ptr_value ( usize:: MAX as * mut _ )
17791779 } else {
1780- // Otherwise, this references a real allocation .
1780+ // Otherwise, we're guaranteed the pointer came from a nondangling Weak .
17811781 // SAFETY: data_offset is safe to call, as ptr references a real (potentially dropped) T.
17821782 let offset = unsafe { data_offset ( ptr) } ;
17831783 // Thus, we reverse the offset to get the whole RcBox.
You can’t perform that action at this time.
0 commit comments