Skip to content

Commit 4a48d68

Browse files
committed
Simplify based on eddyb's comment
1 parent 0bf75fb commit 4a48d68

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

compiler/rustc_symbol_mangling/src/legacy.rs

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,16 @@ 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-
7858
let mut printer = SymbolPrinter { tcx, path: SymbolPath::new(), keep_within_component: false }
79-
.print_def_path(def_id, &[])
59+
.print_def_path(
60+
def_id,
61+
if let ty::InstanceDef::DropGlue(_, _) = instance.def {
62+
// Add the name of the dropped type to the symbol name
63+
&*instance.substs
64+
} else {
65+
&[]
66+
},
67+
)
8068
.unwrap();
8169

8270
if let ty::InstanceDef::VtableShim(..) = instance.def {

0 commit comments

Comments
 (0)