Skip to content

Commit 40e1bb2

Browse files
committed
make NonNull::drop_in_place call drop_glue directly
1 parent b6528a1 commit 40e1bb2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

library/core/src/ptr/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ where
822822

823823
/// Helper function for `drop_in_place`. The compiler replaces this by the actual drop glue.
824824
#[lang = "drop_glue"]
825-
const unsafe fn drop_glue<T: PointeeSized>(_: &mut T)
825+
pub(crate) const unsafe fn drop_glue<T: PointeeSized>(_: &mut T)
826826
where
827827
T: [const] Destruct,
828828
{

library/core/src/ptr/non_null.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,12 +1116,12 @@ impl<T: PointeeSized> NonNull<T> {
11161116
#[inline(always)]
11171117
#[stable(feature = "non_null_convenience", since = "1.80.0")]
11181118
#[rustc_const_unstable(feature = "const_drop_in_place", issue = "109342")]
1119-
pub const unsafe fn drop_in_place(self)
1119+
pub const unsafe fn drop_in_place(mut self)
11201120
where
11211121
T: [const] Destruct,
11221122
{
11231123
// SAFETY: the caller must uphold the safety contract for `drop_in_place`.
1124-
unsafe { ptr::drop_in_place(self.as_ptr()) }
1124+
unsafe { ptr::drop_glue(self.as_mut()) }
11251125
}
11261126

11271127
/// Overwrites a memory location with the given value without reading or

0 commit comments

Comments
 (0)