@@ -12,7 +12,6 @@ use rustc_data_structures::unord::UnordMap;
1212use rustc_hashes:: Hash128 ;
1313use rustc_hir:: ItemId ;
1414use rustc_hir:: def_id:: { CrateNum , DefId , DefIdSet , LOCAL_CRATE } ;
15- use rustc_index:: Idx ;
1615use rustc_macros:: { HashStable , TyDecodable , TyEncodable } ;
1716use rustc_query_system:: ich:: StableHashingContext ;
1817use rustc_session:: config:: OptLevel ;
@@ -527,8 +526,8 @@ impl<'tcx> CodegenUnit<'tcx> {
527526 ) -> Vec < ( MonoItem < ' tcx > , MonoItemData ) > {
528527 // The codegen tests rely on items being process in the same order as
529528 // they appear in the file, so for local items, we sort by node_id first
530- #[ derive( PartialEq , Eq , PartialOrd , Ord ) ]
531- struct ItemSortKey < ' tcx > ( Option < usize > , SymbolName < ' tcx > ) ;
529+ #[ derive( PartialEq , Eq , PartialOrd , Ord , Debug ) ]
530+ struct ItemSortKey < ' tcx > ( Option < Span > , SymbolName < ' tcx > ) ;
532531
533532 fn item_sort_key < ' tcx > ( tcx : TyCtxt < ' tcx > , item : MonoItem < ' tcx > ) -> ItemSortKey < ' tcx > {
534533 ItemSortKey (
@@ -539,7 +538,9 @@ impl<'tcx> CodegenUnit<'tcx> {
539538 // instances into account. The others don't matter for
540539 // the codegen tests and can even make item order
541540 // unstable.
542- InstanceKind :: Item ( def) => def. as_local ( ) . map ( Idx :: index) ,
541+ InstanceKind :: Item ( def) => {
542+ def. as_local ( ) . map ( |def_id|tcx. def_span ( def_id) )
543+ } ,
543544 InstanceKind :: VTableShim ( ..)
544545 | InstanceKind :: ReifyShim ( ..)
545546 | InstanceKind :: Intrinsic ( ..)
@@ -556,8 +557,8 @@ impl<'tcx> CodegenUnit<'tcx> {
556557 | InstanceKind :: AsyncDropGlueCtorShim ( ..) => None ,
557558 }
558559 }
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 ( ) ) ,
560+ MonoItem :: Static ( def_id) => def_id. as_local ( ) . map ( |def_id|tcx . def_span ( def_id ) ) ,
561+ MonoItem :: GlobalAsm ( item_id) => Some ( tcx . def_span ( item_id. owner_id . def_id ) ) ,
561562 } ,
562563 item. symbol_name ( tcx) ,
563564 )
0 commit comments