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