Skip to content

Commit 3a6df92

Browse files
Rollup merge of rust-lang#142700 - theemathas:remove-weak-comment, r=ibraheemdev
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 <rust-lang#73845>. 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.
2 parents c96bf8b + 644469e commit 3a6df92

File tree

2 files changed

+0
-2
lines changed

2 files changed

+0
-2
lines changed

library/alloc/src/rc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3004,7 +3004,6 @@ pub struct Weak<
30043004
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
30053005
// to allocate space on the heap. That's not a value a real pointer
30063006
// will ever have because RcInner has alignment at least 2.
3007-
// This is only possible when `T: Sized`; unsized `T` never dangle.
30083007
ptr: NonNull<RcInner<T>>,
30093008
alloc: A,
30103009
}

library/alloc/src/sync.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ pub struct Weak<
342342
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
343343
// to allocate space on the heap. That's not a value a real pointer
344344
// will ever have because RcInner has alignment at least 2.
345-
// This is only possible when `T: Sized`; unsized `T` never dangle.
346345
ptr: NonNull<ArcInner<T>>,
347346
alloc: A,
348347
}

0 commit comments

Comments
 (0)