From 23a4050f7dbc8675df6305b9968a3d5648518ff4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 20 May 2021 19:43:41 -0700 Subject: [PATCH] Weak's type parameter may dangle on drop --- library/alloc/src/rc.rs | 2 +- library/alloc/src/sync.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 800952f7a5ece..f19a13c8defef 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -2303,7 +2303,7 @@ impl Weak { } #[stable(feature = "rc_weak", since = "1.4.0")] -impl Drop for Weak { +unsafe impl<#[may_dangle] T: ?Sized> Drop for Weak { /// Drops the `Weak` pointer. /// /// # Examples diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 17927f5f5fdc4..02a739309cde0 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -2015,7 +2015,7 @@ impl Default for Weak { } #[stable(feature = "arc_weak", since = "1.4.0")] -impl Drop for Weak { +unsafe impl<#[may_dangle] T: ?Sized> Drop for Weak { /// Drops the `Weak` pointer. /// /// # Examples