From 94e4ddf127cb59f554da19bf0d2bd7b63e0df32f Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Wed, 8 Apr 2026 14:59:29 +0200 Subject: [PATCH] make `NonNull::drop_in_place` call `drop_glue` directly --- library/core/src/ptr/mod.rs | 2 +- library/core/src/ptr/non_null.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 93cc3e2a8c0c..15fc36332bac 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -822,7 +822,7 @@ /// Helper function for `drop_in_place`. The compiler replaces this by the actual drop glue. #[lang = "drop_glue"] -const unsafe fn drop_glue(_: &mut T) +pub(crate) const unsafe fn drop_glue(_: &mut T) where T: [const] Destruct, { diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 262e1781629f..b9b42c1efe05 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -1116,12 +1116,12 @@ pub unsafe fn read_volatile(self) -> T #[inline(always)] #[stable(feature = "non_null_convenience", since = "1.80.0")] #[rustc_const_unstable(feature = "const_drop_in_place", issue = "109342")] - pub const unsafe fn drop_in_place(self) + pub const unsafe fn drop_in_place(mut self) where T: [const] Destruct, { // SAFETY: the caller must uphold the safety contract for `drop_in_place`. - unsafe { ptr::drop_in_place(self.as_ptr()) } + unsafe { ptr::drop_glue(self.as_mut()) } } /// Overwrites a memory location with the given value without reading or