File tree 2 files changed +8
-6
lines changed
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> {
592
592
pub fn as_ptr ( this : & Self ) -> * const T {
593
593
let ptr: * mut RcBox < T > = NonNull :: as_ptr ( this. ptr ) ;
594
594
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
597
597
// write through the pointer after the Rc is recovered through `from_raw`.
598
598
unsafe { & raw const ( * ptr) . value }
599
599
}
@@ -1709,7 +1709,8 @@ impl<T> Weak<T> {
1709
1709
// a dangling weak (usize::MAX). data_offset is safe to call, because we
1710
1710
// know a pointer to unsized T must be derived from a real unsized T,
1711
1711
// 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.
1713
1714
unsafe {
1714
1715
let offset = data_offset ( fake_ptr) ;
1715
1716
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> {
591
591
pub fn as_ptr ( this : & Self ) -> * const T {
592
592
let ptr: * mut ArcInner < T > = NonNull :: as_ptr ( this. ptr ) ;
593
593
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
596
596
// write through the pointer after the Rc is recovered through `from_raw`.
597
597
unsafe { & raw const ( * ptr) . data }
598
598
}
@@ -1477,7 +1477,8 @@ impl<T> Weak<T> {
1477
1477
// a dangling weak (usize::MAX). data_offset is safe to call, because we
1478
1478
// know a pointer to unsized T must be derived from a real unsized T,
1479
1479
// 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.
1481
1482
unsafe {
1482
1483
let offset = data_offset ( fake_ptr) ;
1483
1484
set_data_ptr ( fake_ptr, ( ptr as * mut u8 ) . wrapping_offset ( offset) )
You can’t perform that action at this time.
0 commit comments