@@ -5,12 +5,11 @@ use log::{debug, trace};
5
5
use rustc_ast:: ast:: { self , Ident } ;
6
6
use rustc_ast:: attr;
7
7
use rustc_data_structures:: fingerprint:: Fingerprint ;
8
- use rustc_data_structures:: fx:: FxHashMap ;
8
+ use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
9
9
use rustc_data_structures:: stable_hasher:: StableHasher ;
10
10
use rustc_data_structures:: sync:: { join, Lrc } ;
11
11
use rustc_hir as hir;
12
12
use rustc_hir:: def:: CtorKind ;
13
- use rustc_hir:: def_id:: DefIdSet ;
14
13
use rustc_hir:: def_id:: { CrateNum , DefId , DefIndex , LocalDefId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
15
14
use rustc_hir:: definitions:: DefPathTable ;
16
15
use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
@@ -644,8 +643,8 @@ impl EncodeContext<'tcx> {
644
643
self . encode_generics ( def_id) ;
645
644
self . encode_explicit_predicates ( def_id) ;
646
645
self . encode_inferred_outlives ( def_id) ;
647
- self . encode_optimized_mir ( def_id) ;
648
- self . encode_promoted_mir ( def_id) ;
646
+ self . encode_optimized_mir ( def_id. expect_local ( ) ) ;
647
+ self . encode_promoted_mir ( def_id. expect_local ( ) ) ;
649
648
}
650
649
651
650
fn encode_enum_variant_ctor ( & mut self , def : & ty:: AdtDef , index : VariantIdx ) {
@@ -683,8 +682,8 @@ impl EncodeContext<'tcx> {
683
682
self . encode_generics ( def_id) ;
684
683
self . encode_explicit_predicates ( def_id) ;
685
684
self . encode_inferred_outlives ( def_id) ;
686
- self . encode_optimized_mir ( def_id) ;
687
- self . encode_promoted_mir ( def_id) ;
685
+ self . encode_optimized_mir ( def_id. expect_local ( ) ) ;
686
+ self . encode_promoted_mir ( def_id. expect_local ( ) ) ;
688
687
}
689
688
690
689
fn encode_info_for_mod (
@@ -786,8 +785,8 @@ impl EncodeContext<'tcx> {
786
785
self . encode_generics ( def_id) ;
787
786
self . encode_explicit_predicates ( def_id) ;
788
787
self . encode_inferred_outlives ( def_id) ;
789
- self . encode_optimized_mir ( def_id) ;
790
- self . encode_promoted_mir ( def_id) ;
788
+ self . encode_optimized_mir ( def_id. expect_local ( ) ) ;
789
+ self . encode_promoted_mir ( def_id. expect_local ( ) ) ;
791
790
}
792
791
793
792
fn encode_generics ( & mut self , def_id : DefId ) {
@@ -896,8 +895,8 @@ impl EncodeContext<'tcx> {
896
895
self . encode_inferred_outlives ( def_id) ;
897
896
898
897
// This should be kept in sync with `PrefetchVisitor.visit_trait_item`.
899
- self . encode_optimized_mir ( def_id) ;
900
- self . encode_promoted_mir ( def_id) ;
898
+ self . encode_optimized_mir ( def_id. expect_local ( ) ) ;
899
+ self . encode_promoted_mir ( def_id. expect_local ( ) ) ;
901
900
}
902
901
903
902
fn metadata_output_only ( & self ) -> bool {
@@ -985,8 +984,8 @@ impl EncodeContext<'tcx> {
985
984
hir:: ImplItemKind :: OpaqueTy ( ..) | hir:: ImplItemKind :: TyAlias ( ..) => false ,
986
985
} ;
987
986
if mir {
988
- self . encode_optimized_mir ( def_id) ;
989
- self . encode_promoted_mir ( def_id) ;
987
+ self . encode_optimized_mir ( def_id. expect_local ( ) ) ;
988
+ self . encode_promoted_mir ( def_id. expect_local ( ) ) ;
990
989
}
991
990
}
992
991
@@ -1004,17 +1003,17 @@ impl EncodeContext<'tcx> {
1004
1003
self . lazy ( param_names. iter ( ) . map ( |ident| ident. name ) )
1005
1004
}
1006
1005
1007
- fn encode_optimized_mir ( & mut self , def_id : DefId ) {
1006
+ fn encode_optimized_mir ( & mut self , def_id : LocalDefId ) {
1008
1007
debug ! ( "EntryBuilder::encode_mir({:?})" , def_id) ;
1009
1008
if self . tcx . mir_keys ( LOCAL_CRATE ) . contains ( & def_id) {
1010
- record ! ( self . tables. mir[ def_id] <- self . tcx. optimized_mir( def_id) ) ;
1009
+ record ! ( self . tables. mir[ def_id. to_def_id ( ) ] <- self . tcx. optimized_mir( def_id) ) ;
1011
1010
}
1012
1011
}
1013
1012
1014
- fn encode_promoted_mir ( & mut self , def_id : DefId ) {
1013
+ fn encode_promoted_mir ( & mut self , def_id : LocalDefId ) {
1015
1014
debug ! ( "EncodeContext::encode_promoted_mir({:?})" , def_id) ;
1016
1015
if self . tcx . mir_keys ( LOCAL_CRATE ) . contains ( & def_id) {
1017
- record ! ( self . tables. promoted_mir[ def_id] <- self . tcx. promoted_mir( def_id) ) ;
1016
+ record ! ( self . tables. promoted_mir[ def_id. to_def_id ( ) ] <- self . tcx. promoted_mir( def_id) ) ;
1018
1017
}
1019
1018
}
1020
1019
@@ -1282,8 +1281,8 @@ impl EncodeContext<'tcx> {
1282
1281
_ => false ,
1283
1282
} ;
1284
1283
if mir {
1285
- self . encode_optimized_mir ( def_id) ;
1286
- self . encode_promoted_mir ( def_id) ;
1284
+ self . encode_optimized_mir ( def_id. expect_local ( ) ) ;
1285
+ self . encode_promoted_mir ( def_id. expect_local ( ) ) ;
1287
1286
}
1288
1287
}
1289
1288
@@ -1316,8 +1315,7 @@ impl EncodeContext<'tcx> {
1316
1315
let hir_id = self . tcx . hir ( ) . as_local_hir_id ( def_id) ;
1317
1316
let ty = self . tcx . typeck_tables_of ( def_id) . node_type ( hir_id) ;
1318
1317
1319
- let def_id = def_id. to_def_id ( ) ;
1320
- record ! ( self . tables. kind[ def_id] <- match ty. kind {
1318
+ record ! ( self . tables. kind[ def_id. to_def_id( ) ] <- match ty. kind {
1321
1319
ty:: Generator ( ..) => {
1322
1320
let data = self . tcx. generator_kind( def_id) . unwrap( ) ;
1323
1321
EntryKind :: Generator ( data)
@@ -1327,14 +1325,14 @@ impl EncodeContext<'tcx> {
1327
1325
1328
1326
_ => bug!( "closure that is neither generator nor closure" ) ,
1329
1327
} ) ;
1330
- record ! ( self . tables. visibility[ def_id] <- ty:: Visibility :: Public ) ;
1331
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
1332
- record ! ( self . tables. attributes[ def_id] <- & self . tcx. get_attrs( def_id) [ ..] ) ;
1333
- self . encode_item_type ( def_id) ;
1328
+ record ! ( self . tables. visibility[ def_id. to_def_id ( ) ] <- ty:: Visibility :: Public ) ;
1329
+ record ! ( self . tables. span[ def_id. to_def_id ( ) ] <- self . tcx. def_span( def_id) ) ;
1330
+ record ! ( self . tables. attributes[ def_id. to_def_id ( ) ] <- & self . tcx. get_attrs( def_id. to_def_id ( ) ) [ ..] ) ;
1331
+ self . encode_item_type ( def_id. to_def_id ( ) ) ;
1334
1332
if let ty:: Closure ( def_id, substs) = ty. kind {
1335
1333
record ! ( self . tables. fn_sig[ def_id] <- substs. as_closure( ) . sig( ) ) ;
1336
1334
}
1337
- self . encode_generics ( def_id) ;
1335
+ self . encode_generics ( def_id. to_def_id ( ) ) ;
1338
1336
self . encode_optimized_mir ( def_id) ;
1339
1337
self . encode_promoted_mir ( def_id) ;
1340
1338
}
@@ -1344,16 +1342,15 @@ impl EncodeContext<'tcx> {
1344
1342
let id = self . tcx . hir ( ) . as_local_hir_id ( def_id) ;
1345
1343
let body_id = self . tcx . hir ( ) . body_owned_by ( id) ;
1346
1344
let const_data = self . encode_rendered_const_for_body ( body_id) ;
1347
- let def_id = def_id. to_def_id ( ) ;
1348
1345
let qualifs = self . tcx . mir_const_qualif ( def_id) ;
1349
1346
1350
- record ! ( self . tables. kind[ def_id] <- EntryKind :: Const ( qualifs, const_data) ) ;
1351
- record ! ( self . tables. visibility[ def_id] <- ty:: Visibility :: Public ) ;
1352
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
1353
- self . encode_item_type ( def_id) ;
1354
- self . encode_generics ( def_id) ;
1355
- self . encode_explicit_predicates ( def_id) ;
1356
- self . encode_inferred_outlives ( def_id) ;
1347
+ record ! ( self . tables. kind[ def_id. to_def_id ( ) ] <- EntryKind :: Const ( qualifs, const_data) ) ;
1348
+ record ! ( self . tables. visibility[ def_id. to_def_id ( ) ] <- ty:: Visibility :: Public ) ;
1349
+ record ! ( self . tables. span[ def_id. to_def_id ( ) ] <- self . tcx. def_span( def_id) ) ;
1350
+ self . encode_item_type ( def_id. to_def_id ( ) ) ;
1351
+ self . encode_generics ( def_id. to_def_id ( ) ) ;
1352
+ self . encode_explicit_predicates ( def_id. to_def_id ( ) ) ;
1353
+ self . encode_inferred_outlives ( def_id. to_def_id ( ) ) ;
1357
1354
self . encode_optimized_mir ( def_id) ;
1358
1355
self . encode_promoted_mir ( def_id) ;
1359
1356
}
@@ -1726,12 +1723,11 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
1726
1723
/// Only a subset of the queries are actually prefetched to keep this code smaller.
1727
1724
struct PrefetchVisitor < ' tcx > {
1728
1725
tcx : TyCtxt < ' tcx > ,
1729
- mir_keys : & ' tcx DefIdSet ,
1726
+ mir_keys : & ' tcx FxHashSet < LocalDefId > ,
1730
1727
}
1731
1728
1732
1729
impl < ' tcx > PrefetchVisitor < ' tcx > {
1733
1730
fn prefetch_mir ( & self , def_id : LocalDefId ) {
1734
- let def_id = def_id. to_def_id ( ) ;
1735
1731
if self . mir_keys . contains ( & def_id) {
1736
1732
self . tcx . optimized_mir ( def_id) ;
1737
1733
self . tcx . promoted_mir ( def_id) ;
0 commit comments