Skip to content

Commit 0bf75fb

Browse files
committed
Use better symbol names for the drop glue
1 parent 3f2088a commit 0bf75fb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

compiler/rustc_symbol_mangling/src/legacy.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ pub(super) fn mangle(
5555

5656
let hash = get_symbol_hash(tcx, instance, instance_ty, instantiating_crate);
5757

58+
if let ty::InstanceDef::DropGlue(_drop_in_place, ty) = instance.def {
59+
// Use `{{drop}}::<$TYPE>::$hash` as name for the drop glue instead of
60+
// `core::mem::drop_in_place::$hash`.
61+
let mut printer =
62+
SymbolPrinter { tcx, path: SymbolPath::new(), keep_within_component: false };
63+
printer.write_str("{{drop}}").unwrap();
64+
printer.path.finalize_pending_component();
65+
let printer = printer
66+
.generic_delimiters(|mut printer| {
67+
if let Some(ty) = ty {
68+
printer.print_type(ty)
69+
} else {
70+
printer.write_str("_")?;
71+
Ok(printer)
72+
}
73+
})
74+
.unwrap();
75+
return printer.path.finish(hash);
76+
}
77+
5878
let mut printer = SymbolPrinter { tcx, path: SymbolPath::new(), keep_within_component: false }
5979
.print_def_path(def_id, &[])
6080
.unwrap();

0 commit comments

Comments
 (0)