Skip to content

Commit

Permalink
Apply documentation review suggestions
Browse files Browse the repository at this point in the history
Co-Authored-By: Ralf Jung <post@ralfj.de>
  • Loading branch information
CAD97 and RalfJung committed Jul 1, 2020
1 parent aed88e1 commit ac40d1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ impl<T: ?Sized> Rc<T> {
pub fn as_ptr(this: &Self) -> *const T {
let ptr: *mut RcBox<T> = NonNull::as_ptr(this.ptr);

// SAFETY: This cannot go through Deref::deref or Rc::inner.
// This is required to retain raw/mut provenance such that e.g. `get_mut` can
// SAFETY: This cannot go through Deref::deref or Rc::inner because
// this is required to retain raw/mut provenance such that e.g. `get_mut` can
// write through the pointer after the Rc is recovered through `from_raw`.
unsafe { &raw const (*ptr).value }
}
Expand Down Expand Up @@ -1709,7 +1709,8 @@ impl<T> Weak<T> {
// 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
// is used so that we can use the same code path for dangling weak refs.
// is used so that we can use the same code path for the non-dangling
// unsized case and the potentially dangling sized case.
unsafe {
let offset = data_offset(fake_ptr);
set_data_ptr(fake_ptr, (ptr as *mut u8).wrapping_offset(offset))
Expand Down
7 changes: 4 additions & 3 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ impl<T: ?Sized> Arc<T> {
pub fn as_ptr(this: &Self) -> *const T {
let ptr: *mut ArcInner<T> = NonNull::as_ptr(this.ptr);

// SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner.
// This is required to retain raw/mut provenance such that e.g. `get_mut` can
// SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner because
// this is required to retain raw/mut provenance such that e.g. `get_mut` can
// write through the pointer after the Rc is recovered through `from_raw`.
unsafe { &raw const (*ptr).data }
}
Expand Down Expand Up @@ -1477,7 +1477,8 @@ impl<T> Weak<T> {
// 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
// is used so that we can use the same code path for dangling weak refs.
// is used so that we can use the same code path for the non-dangling
// unsized case and the potentially dangling sized case.
unsafe {
let offset = data_offset(fake_ptr);
set_data_ptr(fake_ptr, (ptr as *mut u8).wrapping_offset(offset))
Expand Down

0 comments on commit ac40d1e

Please sign in to comment.