@@ -5,12 +5,11 @@ use log::{debug, trace};
55use rustc_ast:: ast:: { self , Ident } ;
66use rustc_ast:: attr;
77use rustc_data_structures:: fingerprint:: Fingerprint ;
8- use rustc_data_structures:: fx:: FxHashMap ;
8+ use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
99use rustc_data_structures:: stable_hasher:: StableHasher ;
1010use rustc_data_structures:: sync:: { join, Lrc } ;
1111use rustc_hir as hir;
1212use rustc_hir:: def:: CtorKind ;
13- use rustc_hir:: def_id:: DefIdSet ;
1413use rustc_hir:: def_id:: { CrateNum , DefId , DefIndex , LocalDefId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
1514use rustc_hir:: definitions:: DefPathTable ;
1615use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
@@ -644,8 +643,8 @@ impl EncodeContext<'tcx> {
644643 self . encode_generics ( def_id) ;
645644 self . encode_explicit_predicates ( def_id) ;
646645 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 ( ) ) ;
649648 }
650649
651650 fn encode_enum_variant_ctor ( & mut self , def : & ty:: AdtDef , index : VariantIdx ) {
@@ -683,8 +682,8 @@ impl EncodeContext<'tcx> {
683682 self . encode_generics ( def_id) ;
684683 self . encode_explicit_predicates ( def_id) ;
685684 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 ( ) ) ;
688687 }
689688
690689 fn encode_info_for_mod (
@@ -786,8 +785,8 @@ impl EncodeContext<'tcx> {
786785 self . encode_generics ( def_id) ;
787786 self . encode_explicit_predicates ( def_id) ;
788787 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 ( ) ) ;
791790 }
792791
793792 fn encode_generics ( & mut self , def_id : DefId ) {
@@ -896,8 +895,8 @@ impl EncodeContext<'tcx> {
896895 self . encode_inferred_outlives ( def_id) ;
897896
898897 // 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 ( ) ) ;
901900 }
902901
903902 fn metadata_output_only ( & self ) -> bool {
@@ -985,8 +984,8 @@ impl EncodeContext<'tcx> {
985984 hir:: ImplItemKind :: OpaqueTy ( ..) | hir:: ImplItemKind :: TyAlias ( ..) => false ,
986985 } ;
987986 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 ( ) ) ;
990989 }
991990 }
992991
@@ -1004,17 +1003,17 @@ impl EncodeContext<'tcx> {
10041003 self . lazy ( param_names. iter ( ) . map ( |ident| ident. name ) )
10051004 }
10061005
1007- fn encode_optimized_mir ( & mut self , def_id : DefId ) {
1006+ fn encode_optimized_mir ( & mut self , def_id : LocalDefId ) {
10081007 debug ! ( "EntryBuilder::encode_mir({:?})" , def_id) ;
10091008 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) ) ;
10111010 }
10121011 }
10131012
1014- fn encode_promoted_mir ( & mut self , def_id : DefId ) {
1013+ fn encode_promoted_mir ( & mut self , def_id : LocalDefId ) {
10151014 debug ! ( "EncodeContext::encode_promoted_mir({:?})" , def_id) ;
10161015 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) ) ;
10181017 }
10191018 }
10201019
@@ -1282,8 +1281,8 @@ impl EncodeContext<'tcx> {
12821281 _ => false ,
12831282 } ;
12841283 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 ( ) ) ;
12871286 }
12881287 }
12891288
@@ -1316,8 +1315,7 @@ impl EncodeContext<'tcx> {
13161315 let hir_id = self . tcx . hir ( ) . as_local_hir_id ( def_id) ;
13171316 let ty = self . tcx . typeck_tables_of ( def_id) . node_type ( hir_id) ;
13181317
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 {
13211319 ty:: Generator ( ..) => {
13221320 let data = self . tcx. generator_kind( def_id) . unwrap( ) ;
13231321 EntryKind :: Generator ( data)
@@ -1327,14 +1325,14 @@ impl EncodeContext<'tcx> {
13271325
13281326 _ => bug!( "closure that is neither generator nor closure" ) ,
13291327 } ) ;
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 ( ) ) ;
13341332 if let ty:: Closure ( def_id, substs) = ty. kind {
13351333 record ! ( self . tables. fn_sig[ def_id] <- substs. as_closure( ) . sig( ) ) ;
13361334 }
1337- self . encode_generics ( def_id) ;
1335+ self . encode_generics ( def_id. to_def_id ( ) ) ;
13381336 self . encode_optimized_mir ( def_id) ;
13391337 self . encode_promoted_mir ( def_id) ;
13401338 }
@@ -1344,16 +1342,15 @@ impl EncodeContext<'tcx> {
13441342 let id = self . tcx . hir ( ) . as_local_hir_id ( def_id) ;
13451343 let body_id = self . tcx . hir ( ) . body_owned_by ( id) ;
13461344 let const_data = self . encode_rendered_const_for_body ( body_id) ;
1347- let def_id = def_id. to_def_id ( ) ;
13481345 let qualifs = self . tcx . mir_const_qualif ( def_id) ;
13491346
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 ( ) ) ;
13571354 self . encode_optimized_mir ( def_id) ;
13581355 self . encode_promoted_mir ( def_id) ;
13591356 }
@@ -1726,12 +1723,11 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
17261723/// Only a subset of the queries are actually prefetched to keep this code smaller.
17271724struct PrefetchVisitor < ' tcx > {
17281725 tcx : TyCtxt < ' tcx > ,
1729- mir_keys : & ' tcx DefIdSet ,
1726+ mir_keys : & ' tcx FxHashSet < LocalDefId > ,
17301727}
17311728
17321729impl < ' tcx > PrefetchVisitor < ' tcx > {
17331730 fn prefetch_mir ( & self , def_id : LocalDefId ) {
1734- let def_id = def_id. to_def_id ( ) ;
17351731 if self . mir_keys . contains ( & def_id) {
17361732 self . tcx . optimized_mir ( def_id) ;
17371733 self . tcx . promoted_mir ( def_id) ;
0 commit comments