Skip to content

Commit b83ac8a

Browse files
committed
src/printer: compute item name inside mk_item
1 parent e4eca26 commit b83ac8a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/printer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,16 @@ impl Ord for Item {
332332
}
333333
}
334334

335-
fn mk_item(tcx: TyCtxt<'_>, item: MonoItem, sym_name: String) -> Item {
335+
fn mk_item(tcx: TyCtxt<'_>, item: MonoItem) -> Item {
336+
let symbol_name = mono_item_name(tcx, &item).to_string();
336337
match item {
337338
MonoItem::Fn(inst) => {
338339
let id = inst.def.def_id();
339340
let name = inst.name();
340341
let internal_id = rustc_internal::internal(tcx, id);
341342
Item {
342343
mono_item: item,
343-
symbol_name: sym_name.clone(),
344+
symbol_name,
344345
mono_item_kind: MonoItemKind::MonoItemFn {
345346
name: name.clone(),
346347
id,
@@ -363,7 +364,7 @@ fn mk_item(tcx: TyCtxt<'_>, item: MonoItem, sym_name: String) -> Item {
363364
};
364365
Item {
365366
mono_item: item,
366-
symbol_name: sym_name,
367+
symbol_name,
367368
mono_item_kind: MonoItemKind::MonoItemStatic {
368369
name: static_def.name(),
369370
id: static_def.def_id(),
@@ -376,7 +377,7 @@ fn mk_item(tcx: TyCtxt<'_>, item: MonoItem, sym_name: String) -> Item {
376377
let asm = format!("{:#?}", asm);
377378
Item {
378379
mono_item: item,
379-
symbol_name: sym_name,
380+
symbol_name,
380381
mono_item_kind: MonoItemKind::MonoItemGlobalAsm { asm },
381382
details: None,
382383
}
@@ -900,7 +901,6 @@ impl MirVisitor for UnevaluatedConstCollector<'_, '_> {
900901
mk_item(
901902
self.tcx,
902903
rustc_internal::stable(internal_mono_item),
903-
item_name,
904904
),
905905
);
906906
}
@@ -970,7 +970,7 @@ fn collect_items(tcx: TyCtxt<'_>) -> HashMap<String, Item> {
970970
.iter()
971971
.map(|item| {
972972
let name = mono_item_name(tcx, item);
973-
(name.clone(), mk_item(tcx, item.clone(), name))
973+
(name.clone(), mk_item(tcx, item.clone()))
974974
})
975975
.collect::<HashMap<_, _>>()
976976
}
@@ -1122,7 +1122,7 @@ pub fn collect_smir(tcx: TyCtxt<'_>) -> SmirJson {
11221122
"Items missing static with id {:?} and name {:?}",
11231123
def, item_name
11241124
);
1125-
items.push(mk_item(tcx, mono_item, item_name.clone()));
1125+
items.push(mk_item(tcx, mono_item));
11261126
}
11271127
}
11281128
}

0 commit comments

Comments
 (0)