Skip to content

Commit e290eca

Browse files
committed
Simplified mangled name functions
1 parent f7e5d62 commit e290eca

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/printer.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,13 @@ pub fn has_attr(tcx: TyCtxt<'_>, item: &stable_mir::CrateItem, attr: symbol::Sym
223223
}
224224

225225
fn mono_item_name(tcx: TyCtxt<'_>, item: &MonoItem) -> String {
226-
if let MonoItem::GlobalAsm(data) = item {
227-
hash(data).to_string()
228-
} else {
229-
mono_item_name_int(tcx, &rustc_internal::internal(tcx, item))
226+
match item {
227+
MonoItem::Fn(instance) => todo!(), // <-- Demangle here
228+
MonoItem::Static(_static_def) => rustc_internal::internal(tcx, item).symbol_name(tcx).name.into(),
229+
MonoItem::GlobalAsm(opaque) => hash(opaque).to_string(),
230230
}
231231
}
232232

233-
fn mono_item_name_int<'a>(tcx: TyCtxt<'a>, item: &rustc_middle::mir::mono::MonoItem<'a>) -> String {
234-
item.symbol_name(tcx).name.into()
235-
}
236-
237233
fn fn_inst_for_ty(ty: stable_mir::ty::Ty, direct_call: bool) -> Option<Instance> {
238234
ty.kind().fn_def().and_then(|(fn_def, args)| {
239235
if direct_call {
@@ -886,7 +882,7 @@ impl MirVisitor for UnevaluatedConstCollector<'_, '_> {
886882
.flatten()
887883
.unwrap_or_else(|| panic!("Failed to resolve mono item for {:?}", uconst));
888884
let internal_mono_item = rustc_middle::mir::mono::MonoItem::Fn(inst);
889-
let item_name = mono_item_name_int(self.tcx, &internal_mono_item);
885+
let item_name = mono_item_name(self.tcx, &MonoItem::Fn(rustc_internal::stable(inst)));
890886
if !(self.processed_items.contains_key(&item_name)
891887
|| self.pending_items.contains_key(&item_name)
892888
|| self.current_item == hash(&item_name))

0 commit comments

Comments
 (0)