From 7498cad0d8dacd51f0d18bdf985c15efe55b4e8a Mon Sep 17 00:00:00 2001 From: CAD97 Date: Wed, 1 Jul 2020 16:01:34 -0400 Subject: Reclarify safety comments in Weak::as_ptr --- src/liballoc/rc.rs | 6 +++--- src/liballoc/sync.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/liballoc') diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 4d77779b209..835df66d55c 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1705,9 +1705,9 @@ impl Weak { let ptr: *mut RcBox = NonNull::as_ptr(self.ptr); // SAFETY: we must offset the pointer manually, and said pointer may be - // 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 + // a dangling weak (usize::MAX) if T is sized. data_offset is safe to call, + // because we know that a pointer to unsized T was derived from a real + // unsized T, as dangling weaks are only created for sized T. wrapping_offset // is used so that we can use the same code path for the non-dangling // unsized case and the potentially dangling sized case. unsafe { diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 160abe7210c..875bec5b203 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -1473,9 +1473,9 @@ impl Weak { let ptr: *mut ArcInner = NonNull::as_ptr(self.ptr); // SAFETY: we must offset the pointer manually, and said pointer may be - // 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 + // a dangling weak (usize::MAX) if T is sized. data_offset is safe to call, + // because we know that a pointer to unsized T was derived from a real + // unsized T, as dangling weaks are only created for sized T. wrapping_offset // is used so that we can use the same code path for the non-dangling // unsized case and the potentially dangling sized case. unsafe { -- cgit 1.4.1-3-g733a5