File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -592,8 +592,8 @@ impl<T: ?Sized> Rc<T> {
592592 pub fn as_ptr ( this : & Self ) -> * const T {
593593 let ptr: * mut RcBox < T > = NonNull :: as_ptr ( this. ptr ) ;
594594
595- // SAFETY: This cannot go through Deref::deref or Rc::inner.
596- // This is required to retain raw/mut provenance such that e.g. `get_mut` can
595+ // SAFETY: This cannot go through Deref::deref or Rc::inner because
596+ // this is required to retain raw/mut provenance such that e.g. `get_mut` can
597597 // write through the pointer after the Rc is recovered through `from_raw`.
598598 unsafe { & raw const ( * ptr) . value }
599599 }
@@ -1709,7 +1709,8 @@ impl<T> Weak<T> {
17091709 // a dangling weak (usize::MAX). data_offset is safe to call, because we
17101710 // know a pointer to unsized T must be derived from a real unsized T,
17111711 // because dangling weaks are only created for sized T. wrapping_offset
1712- // is used so that we can use the same code path for dangling weak refs.
1712+ // is used so that we can use the same code path for the non-dangling
1713+ // unsized case and the potentially dangling sized case.
17131714 unsafe {
17141715 let offset = data_offset ( fake_ptr) ;
17151716 set_data_ptr ( fake_ptr, ( ptr as * mut u8 ) . wrapping_offset ( offset) )
Original file line number Diff line number Diff line change @@ -591,8 +591,8 @@ impl<T: ?Sized> Arc<T> {
591591 pub fn as_ptr ( this : & Self ) -> * const T {
592592 let ptr: * mut ArcInner < T > = NonNull :: as_ptr ( this. ptr ) ;
593593
594- // SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner.
595- // This is required to retain raw/mut provenance such that e.g. `get_mut` can
594+ // SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner because
595+ // this is required to retain raw/mut provenance such that e.g. `get_mut` can
596596 // write through the pointer after the Rc is recovered through `from_raw`.
597597 unsafe { & raw const ( * ptr) . data }
598598 }
@@ -1477,7 +1477,8 @@ impl<T> Weak<T> {
14771477 // a dangling weak (usize::MAX). data_offset is safe to call, because we
14781478 // know a pointer to unsized T must be derived from a real unsized T,
14791479 // because dangling weaks are only created for sized T. wrapping_offset
1480- // is used so that we can use the same code path for dangling weak refs.
1480+ // is used so that we can use the same code path for the non-dangling
1481+ // unsized case and the potentially dangling sized case.
14811482 unsafe {
14821483 let offset = data_offset ( fake_ptr) ;
14831484 set_data_ptr ( fake_ptr, ( ptr as * mut u8 ) . wrapping_offset ( offset) )
You can’t perform that action at this time.
0 commit comments