@@ -528,37 +528,42 @@ impl<'tcx> CodegenUnit<'tcx> {
528
528
// The codegen tests rely on items being process in the same order as
529
529
// they appear in the file, so for local items, we sort by node_id first
530
530
#[ derive( PartialEq , Eq , PartialOrd , Ord ) ]
531
- struct ItemSortKey < ' tcx > ( Option < usize > , SymbolName < ' tcx > ) ;
532
-
531
+ struct ItemSortKey < ' tcx > ( Option < Span > , Option < String > , SymbolName < ' tcx > ) ;
532
+
533
+ // We only want to take HirIds of user-defined
534
+ // instances into account. The others don't matter for
535
+ // the codegen tests and can even make item order
536
+ // unstable.
537
+ fn local_item_query < ' tcx , T > (
538
+ item : MonoItem < ' tcx > ,
539
+ op : impl FnOnce ( DefId ) -> T ,
540
+ ) -> Option < T > {
541
+ match item {
542
+ MonoItem :: Fn ( ref instance) => match instance. def {
543
+ InstanceKind :: Item ( def) => def. as_local ( ) . map ( op) ,
544
+ InstanceKind :: VTableShim ( ..)
545
+ | InstanceKind :: ReifyShim ( ..)
546
+ | InstanceKind :: Intrinsic ( ..)
547
+ | InstanceKind :: FnPtrShim ( ..)
548
+ | InstanceKind :: Virtual ( ..)
549
+ | InstanceKind :: ClosureOnceShim { .. }
550
+ | InstanceKind :: ConstructCoroutineInClosureShim { .. }
551
+ | InstanceKind :: DropGlue ( ..)
552
+ | InstanceKind :: CloneShim ( ..)
553
+ | InstanceKind :: ThreadLocalShim ( ..)
554
+ | InstanceKind :: FnPtrAddrShim ( ..)
555
+ | InstanceKind :: AsyncDropGlue ( ..)
556
+ | InstanceKind :: FutureDropPollShim ( ..)
557
+ | InstanceKind :: AsyncDropGlueCtorShim ( ..) => None ,
558
+ } ,
559
+ MonoItem :: Static ( def_id) => def_id. as_local ( ) . map ( op) ,
560
+ MonoItem :: GlobalAsm ( item_id) => Some ( op ( item_id. owner_id . def_id ) ) ,
561
+ }
562
+ }
533
563
fn item_sort_key < ' tcx > ( tcx : TyCtxt < ' tcx > , item : MonoItem < ' tcx > ) -> ItemSortKey < ' tcx > {
534
564
ItemSortKey (
535
- match item {
536
- MonoItem :: Fn ( ref instance) => {
537
- match instance. def {
538
- // We only want to take HirIds of user-defined
539
- // instances into account. The others don't matter for
540
- // the codegen tests and can even make item order
541
- // unstable.
542
- InstanceKind :: Item ( def) => def. as_local ( ) . map ( Idx :: index) ,
543
- InstanceKind :: VTableShim ( ..)
544
- | InstanceKind :: ReifyShim ( ..)
545
- | InstanceKind :: Intrinsic ( ..)
546
- | InstanceKind :: FnPtrShim ( ..)
547
- | InstanceKind :: Virtual ( ..)
548
- | InstanceKind :: ClosureOnceShim { .. }
549
- | InstanceKind :: ConstructCoroutineInClosureShim { .. }
550
- | InstanceKind :: DropGlue ( ..)
551
- | InstanceKind :: CloneShim ( ..)
552
- | InstanceKind :: ThreadLocalShim ( ..)
553
- | InstanceKind :: FnPtrAddrShim ( ..)
554
- | InstanceKind :: AsyncDropGlue ( ..)
555
- | InstanceKind :: FutureDropPollShim ( ..)
556
- | InstanceKind :: AsyncDropGlueCtorShim ( ..) => None ,
557
- }
558
- }
559
- MonoItem :: Static ( def_id) => def_id. as_local ( ) . map ( Idx :: index) ,
560
- MonoItem :: GlobalAsm ( item_id) => Some ( item_id. owner_id . def_id . index ( ) ) ,
561
- } ,
565
+ local_item_query ( item, |def_id| tcx. def_span ( def_id) ) ,
566
+ local_item_query ( item, |def_id| tcx. def_path ( id) . to_string_no_crate_verbose ( ) ) ,
562
567
item. symbol_name ( tcx) ,
563
568
)
564
569
}
0 commit comments