Skip to content

Commit ac40d1e

Browse files
CAD97RalfJung
andcommitted
Apply documentation review suggestions
Co-Authored-By: Ralf Jung <[email protected]>
1 parent aed88e1 commit ac40d1e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/liballoc/rc.rs

+4-3
Original file line numberDiff line numberDiff 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))

src/liballoc/sync.rs

+4-3
Original file line numberDiff line numberDiff 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))

0 commit comments

Comments
 (0)