Skip to content

Commit 8f73dfa

Browse files
committed
Use find_ancestor_not_from_macro
1 parent a2f317a commit 8f73dfa

File tree

1 file changed

+6
-9
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+6
-9
lines changed

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -533,13 +533,10 @@ impl<'tcx> CodegenUnit<'tcx> {
533533
// We only want to take HirIds of user-defines instances into account.
534534
// The others don't matter for the codegen tests and can even make item
535535
// order unstable.
536-
fn local_item_query<'tcx, T>(
537-
item: MonoItem<'tcx>,
538-
op: impl FnOnce(DefId) -> T,
539-
) -> Option<T> {
536+
fn local_item_id<'tcx>(item: MonoItem<'tcx>) -> Option<DefId> {
540537
match item {
541538
MonoItem::Fn(ref instance) => match instance.def {
542-
InstanceKind::Item(def) => def.as_local().map(|_| op(def)),
539+
InstanceKind::Item(def) => def.as_local().map(|_| def),
543540
InstanceKind::VTableShim(..)
544541
| InstanceKind::ReifyShim(..)
545542
| InstanceKind::Intrinsic(..)
@@ -555,14 +552,14 @@ impl<'tcx> CodegenUnit<'tcx> {
555552
| InstanceKind::FutureDropPollShim(..)
556553
| InstanceKind::AsyncDropGlueCtorShim(..) => None,
557554
},
558-
MonoItem::Static(def_id) => def_id.as_local().map(|_| op(def_id)),
559-
MonoItem::GlobalAsm(item_id) => Some(op(item_id.owner_id.def_id.to_def_id())),
555+
MonoItem::Static(def_id) => def_id.as_local().map(|_| def_id),
556+
MonoItem::GlobalAsm(item_id) => Some(item_id.owner_id.def_id.to_def_id()),
560557
}
561558
}
562559
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<'tcx> {
563560
ItemSortKey(
564-
local_item_query(item, |def_id| tcx.def_span(def_id)),
565-
local_item_query(item, |def_id| tcx.def_path(def_id).to_string_no_crate_verbose()),
561+
local_item_id(item).map(|def_id| tcx.def_span(def_id).find_ancestor_not_from_macro()).flatten(),
562+
local_item_id(item).map(|def_id| tcx.def_path(def_id).to_string_no_crate_verbose()),
566563
item.symbol_name(tcx),
567564
)
568565
}

0 commit comments

Comments
 (0)