about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCAD97 <cad97@cad97.com>2020-07-02 16:53:56 -0400
committerCAD97 <cad97@cad97.com>2020-07-02 17:08:37 -0400
commit1b5ac57bfd4b0cca3bcdd0fa75c0f0e044ebf01e (patch)
treec8fd016f80e2d7cb437c3eed50080895c57d09dd
parent7498cad0d8dacd51f0d18bdf985c15efe55b4e8a (diff)
downloadrust-1b5ac57bfd4b0cca3bcdd0fa75c0f0e044ebf01e.tar.gz
rust-1b5ac57bfd4b0cca3bcdd0fa75c0f0e044ebf01e.zip
Note Weak.ptr never dangles sooner
-rw-r--r--src/liballoc/rc.rs1
-rw-r--r--src/liballoc/sync.rs1
2 files changed, 2 insertions, 0 deletions
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<T: ?Sized> {
     // `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<RcBox<T>>,
 }
 
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<T: ?Sized> {
     // `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<ArcInner<T>>,
 }