From 1b5ac57bfd4b0cca3bcdd0fa75c0f0e044ebf01e Mon Sep 17 00:00:00 2001 From: CAD97 Date: Thu, 2 Jul 2020 16:53:56 -0400 Subject: Note Weak.ptr never dangles sooner --- src/liballoc/rc.rs | 1 + src/liballoc/sync.rs | 1 + 2 files changed, 2 insertions(+) (limited to 'src/liballoc') diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 835df66d55c..fccdfa0dca9 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1641,6 +1641,7 @@ pub struct Weak { // `Weak::new` sets this to `usize::MAX` so that it doesn’t need // to allocate space on the heap. That's not a value a real pointer // will ever have because RcBox has alignment at least 2. + // This is only possible when `T: Sized`; unsized `T` never dangle. ptr: NonNull>, } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 875bec5b203..ac3ce2255c8 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -267,6 +267,7 @@ pub struct Weak { // `Weak::new` sets this to `usize::MAX` so that it doesn’t need // to allocate space on the heap. That's not a value a real pointer // will ever have because RcBox has alignment at least 2. + // This is only possible when `T: Sized`; unsized `T` never dangle. ptr: NonNull>, } -- cgit 1.4.1-3-g733a5