From 644469e9613253321d09887ffe0fb2c98528ee21 Mon Sep 17 00:00:00 2001 From: "Tim (Theemathas) Chirananthavat" Date: Thu, 19 Jun 2025 12:04:24 +0700 Subject: [PATCH] Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in . As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee. --- library/alloc/src/rc.rs | 1 - library/alloc/src/sync.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 4b8ea708e7e57..010d17f74762c 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -3004,7 +3004,6 @@ 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 RcInner has alignment at least 2. - // This is only possible when `T: Sized`; unsized `T` never dangle. ptr: NonNull>, alloc: A, } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 17090925cfa0c..1e3c03977bd75 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -342,7 +342,6 @@ 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 RcInner has alignment at least 2. - // This is only possible when `T: Sized`; unsized `T` never dangle. ptr: NonNull>, alloc: A, }