diff options
| author | CAD97 <cad97@cad97.com> | 2020-07-01 14:51:08 -0400 |
|---|---|---|
| committer | CAD97 <cad97@cad97.com> | 2020-07-01 15:05:37 -0400 |
| commit | ac40d1eff33cc6789d3c02f4a21477368574cf5e (patch) | |
| tree | dc528056ed2c9825d76833c4b41c4d92d3bbdeae /src/liballoc | |
| parent | aed88e18049f6be7d3c3b37683d05d777adb3c86 (diff) | |
| download | rust-ac40d1eff33cc6789d3c02f4a21477368574cf5e.tar.gz rust-ac40d1eff33cc6789d3c02f4a21477368574cf5e.zip | |
Apply documentation review suggestions
Co-Authored-By: Ralf Jung <post@ralfj.de>
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/rc.rs | 7 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 24e7d5da7a6..29e0979b0ed 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -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 } } @@ -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)) diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 53ce47d023b..005821980fe 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -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 } } @@ -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)) |
