Skip to content

Commit 496b2b1

Browse files
committed
Auto merge of #154327 - WaffleLapkin:drop_in_place_ref, r=RalfJung,scottmcm,saethlin
change the type of the argument of `drop_in_place` lang item to `&mut _` We used to special case `core::ptr::drop_in_place` when computing LLVM argument attributes with this hack: https://github.com/rust-lang/rust/blob/db5e2dc248fe5bb26f70d7baec46a3bca9fa3e1d/compiler/rustc_ty_utils/src/abi.rs#L383-L392 This is because even though `drop_in_place` takes a `*mut T` it is semantically a `&mut T` (remember how `&mut Self` is passed to `Drop::drop`). This is apparently relevant for perf. This PR replaces this hack with a simpler solution -- it makes `drop_in_place` a thin wrapper around newly added `core::ptr::drop_glue`, which is the actual lang item and takes a `&mut T`: https://github.com/rust-lang/rust/blob/d2563d5003bbecff1efc40c1f5673ceec603825b/library/core/src/ptr/mod.rs#L810-L833 ------ The rest of the PR is blessing tests and cleaning up things which are not necessary after this change. One thing that is a bit awkward is that now that `drop_glue` is the actual lang item, a lot of the comments referring to `drop_in_place` are outdated. Should I try fixing that? I've also changed `async_drop_in_place` to take a `&mut T`, and it simplified the code handling it a bit. (since it's unstable we don't need to introduce a wrapper) ------- cc @RalfJung Closes rust-lang/rust#154274
2 parents 84b6675 + 43cdceb commit 496b2b1

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

example/mini_core.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,10 @@ fn eh_personality() -> ! {
577577
loop {}
578578
}
579579

580-
#[lang = "drop_in_place"]
581-
#[allow(unconditional_recursion)]
582-
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
580+
#[lang = "drop_glue"]
581+
pub unsafe fn drop_glue<T: ?Sized>(_to_drop: &mut T) {
583582
// Code here does not matter - this is replaced by the
584583
// real drop glue by the compiler.
585-
drop_in_place(to_drop);
586584
}
587585

588586
#[lang = "unpin"]

0 commit comments

Comments
 (0)