@@ -533,13 +533,10 @@ impl<'tcx> CodegenUnit<'tcx> {
533
533
// We only want to take HirIds of user-defines instances into account.
534
534
// The others don't matter for the codegen tests and can even make item
535
535
// 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 > {
540
537
match item {
541
538
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) ,
543
540
InstanceKind :: VTableShim ( ..)
544
541
| InstanceKind :: ReifyShim ( ..)
545
542
| InstanceKind :: Intrinsic ( ..)
@@ -555,14 +552,14 @@ impl<'tcx> CodegenUnit<'tcx> {
555
552
| InstanceKind :: FutureDropPollShim ( ..)
556
553
| InstanceKind :: AsyncDropGlueCtorShim ( ..) => None ,
557
554
} ,
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 ( ) ) ,
560
557
}
561
558
}
562
559
fn item_sort_key < ' tcx > ( tcx : TyCtxt < ' tcx > , item : MonoItem < ' tcx > ) -> ItemSortKey < ' tcx > {
563
560
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 ( ) ) ,
566
563
item. symbol_name ( tcx) ,
567
564
)
568
565
}
0 commit comments