@@ -7,7 +7,6 @@ use rustc_data_structures::fx::FxHashMap;
7
7
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
8
8
use rustc_hir:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
9
9
use rustc_hir:: ItemId ;
10
- use rustc_index:: vec:: Idx ;
11
10
use rustc_query_system:: ich:: StableHashingContext ;
12
11
use rustc_session:: config:: OptLevel ;
13
12
use rustc_span:: source_map:: Span ;
@@ -348,35 +347,33 @@ impl<'tcx> CodegenUnit<'tcx> {
348
347
tcx : TyCtxt < ' tcx > ,
349
348
) -> Vec < ( MonoItem < ' tcx > , ( Linkage , Visibility ) ) > {
350
349
// The codegen tests rely on items being process in the same order as
351
- // they appear in the file, so for local items, we sort by node_id first
350
+ // they appear in the file, so for local items, we sort by span first
352
351
#[ derive( PartialEq , Eq , PartialOrd , Ord ) ]
353
- pub struct ItemSortKey < ' tcx > ( Option < usize > , SymbolName < ' tcx > ) ;
352
+ pub struct ItemSortKey < ' tcx > ( Option < Span > , SymbolName < ' tcx > ) ;
354
353
355
354
fn item_sort_key < ' tcx > ( tcx : TyCtxt < ' tcx > , item : MonoItem < ' tcx > ) -> ItemSortKey < ' tcx > {
356
- ItemSortKey (
357
- match item {
358
- MonoItem :: Fn ( ref instance) => {
359
- match instance. def {
360
- // We only want to take HirIds of user-defined
361
- // instances into account. The others don't matter for
362
- // the codegen tests and can even make item order
363
- // unstable.
364
- InstanceDef :: Item ( def) => def. did . as_local ( ) . map ( Idx :: index) ,
365
- InstanceDef :: VTableShim ( ..)
366
- | InstanceDef :: ReifyShim ( ..)
367
- | InstanceDef :: Intrinsic ( ..)
368
- | InstanceDef :: FnPtrShim ( ..)
369
- | InstanceDef :: Virtual ( ..)
370
- | InstanceDef :: ClosureOnceShim { .. }
371
- | InstanceDef :: DropGlue ( ..)
372
- | InstanceDef :: CloneShim ( ..) => None ,
373
- }
355
+ let span = match item {
356
+ MonoItem :: Fn ( ref instance) => {
357
+ match instance. def {
358
+ // We only want to take HirIds of user-defined
359
+ // instances into account. The others don't matter for
360
+ // the codegen tests and can even make item order
361
+ // unstable.
362
+ InstanceDef :: Item ( def) => tcx. hir ( ) . span_if_local ( def. did ) ,
363
+ InstanceDef :: VTableShim ( ..)
364
+ | InstanceDef :: ReifyShim ( ..)
365
+ | InstanceDef :: Intrinsic ( ..)
366
+ | InstanceDef :: FnPtrShim ( ..)
367
+ | InstanceDef :: Virtual ( ..)
368
+ | InstanceDef :: ClosureOnceShim { .. }
369
+ | InstanceDef :: DropGlue ( ..)
370
+ | InstanceDef :: CloneShim ( ..) => None ,
374
371
}
375
- MonoItem :: Static ( def_id ) => def_id . as_local ( ) . map ( Idx :: index ) ,
376
- MonoItem :: GlobalAsm ( item_id ) => Some ( item_id . def_id . index ( ) ) ,
377
- } ,
378
- item . symbol_name ( tcx ) ,
379
- )
372
+ }
373
+ MonoItem :: Static ( def_id ) => tcx . hir ( ) . span_if_local ( def_id ) ,
374
+ MonoItem :: GlobalAsm ( item_id ) => Some ( tcx . def_span ( item_id . def_id ) ) ,
375
+ } ;
376
+ ItemSortKey ( span , item . symbol_name ( tcx ) )
380
377
}
381
378
382
379
let mut items: Vec < _ > = self . items ( ) . iter ( ) . map ( |( & i, & l) | ( i, l) ) . collect ( ) ;
0 commit comments