@@ -50,6 +50,7 @@ use rustc_middle::mir::FakeReadCause;
5050use rustc_query_system:: ich:: StableHashingContext ;
5151use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
5252use rustc_session:: config:: { BorrowckMode , CrateType , OutputFilenames } ;
53+ use rustc_session:: cstore:: CrateStoreDyn ;
5354use rustc_session:: lint:: { Level , Lint } ;
5455use rustc_session:: Limit ;
5556use rustc_session:: Session ;
@@ -150,7 +151,8 @@ impl<'tcx> CtxtInterners<'tcx> {
150151 & self ,
151152 kind : TyKind < ' tcx > ,
152153 sess : & Session ,
153- resolutions : & ty:: ResolverOutputs ,
154+ definitions : & rustc_hir:: definitions:: Definitions ,
155+ cstore : & CrateStoreDyn ,
154156 ) -> Ty < ' tcx > {
155157 Ty ( Interned :: new_unchecked (
156158 self . type_
@@ -165,11 +167,7 @@ impl<'tcx> CtxtInterners<'tcx> {
165167 Fingerprint :: ZERO
166168 } else {
167169 let mut hasher = StableHasher :: new ( ) ;
168- let mut hcx = StableHashingContext :: ignore_spans (
169- sess,
170- & resolutions. definitions ,
171- & * resolutions. cstore ,
172- ) ;
170+ let mut hcx = StableHashingContext :: ignore_spans ( sess, definitions, cstore) ;
173171 kind. hash_stable ( & mut hcx, & mut hasher) ;
174172 hasher. finish ( )
175173 } ;
@@ -900,9 +898,10 @@ impl<'tcx> CommonTypes<'tcx> {
900898 fn new (
901899 interners : & CtxtInterners < ' tcx > ,
902900 sess : & Session ,
903- resolutions : & ty:: ResolverOutputs ,
901+ definitions : & rustc_hir:: definitions:: Definitions ,
902+ cstore : & CrateStoreDyn ,
904903 ) -> CommonTypes < ' tcx > {
905- let mk = |ty| interners. intern_ty ( ty, sess, resolutions ) ;
904+ let mk = |ty| interners. intern_ty ( ty, sess, definitions , cstore ) ;
906905
907906 CommonTypes {
908907 unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1023,6 +1022,9 @@ pub struct GlobalCtxt<'tcx> {
10231022 /// Common consts, pre-interned for your convenience.
10241023 pub consts : CommonConsts < ' tcx > ,
10251024
1025+ definitions : rustc_hir:: definitions:: Definitions ,
1026+ cstore : Box < CrateStoreDyn > ,
1027+
10261028 /// Output of the resolver.
10271029 pub ( crate ) untracked_resolutions : ty:: ResolverOutputs ,
10281030
@@ -1163,7 +1165,9 @@ impl<'tcx> TyCtxt<'tcx> {
11631165 s : & ' tcx Session ,
11641166 lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
11651167 arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1166- resolutions : ty:: ResolverOutputs ,
1168+ definitions : rustc_hir:: definitions:: Definitions ,
1169+ cstore : Box < CrateStoreDyn > ,
1170+ untracked_resolutions : ty:: ResolverOutputs ,
11671171 krate : & ' tcx hir:: Crate < ' tcx > ,
11681172 dep_graph : DepGraph ,
11691173 on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1176,7 +1180,7 @@ impl<'tcx> TyCtxt<'tcx> {
11761180 s. fatal ( & err) ;
11771181 } ) ;
11781182 let interners = CtxtInterners :: new ( arena) ;
1179- let common_types = CommonTypes :: new ( & interners, s, & resolutions ) ;
1183+ let common_types = CommonTypes :: new ( & interners, s, & definitions , & * cstore ) ;
11801184 let common_lifetimes = CommonLifetimes :: new ( & interners) ;
11811185 let common_consts = CommonConsts :: new ( & interners, & common_types) ;
11821186
@@ -1186,7 +1190,9 @@ impl<'tcx> TyCtxt<'tcx> {
11861190 arena,
11871191 interners,
11881192 dep_graph,
1189- untracked_resolutions : resolutions,
1193+ definitions,
1194+ cstore,
1195+ untracked_resolutions,
11901196 prof : s. prof . clone ( ) ,
11911197 types : common_types,
11921198 lifetimes : common_lifetimes,
@@ -1287,9 +1293,9 @@ impl<'tcx> TyCtxt<'tcx> {
12871293 pub fn def_key ( self , id : DefId ) -> rustc_hir:: definitions:: DefKey {
12881294 // Accessing the DefKey is ok, since it is part of DefPathHash.
12891295 if let Some ( id) = id. as_local ( ) {
1290- self . untracked_resolutions . definitions . def_key ( id)
1296+ self . definitions . def_key ( id)
12911297 } else {
1292- self . untracked_resolutions . cstore . def_key ( id)
1298+ self . cstore . def_key ( id)
12931299 }
12941300 }
12951301
@@ -1301,19 +1307,19 @@ impl<'tcx> TyCtxt<'tcx> {
13011307 pub fn def_path ( self , id : DefId ) -> rustc_hir:: definitions:: DefPath {
13021308 // Accessing the DefPath is ok, since it is part of DefPathHash.
13031309 if let Some ( id) = id. as_local ( ) {
1304- self . untracked_resolutions . definitions . def_path ( id)
1310+ self . definitions . def_path ( id)
13051311 } else {
1306- self . untracked_resolutions . cstore . def_path ( id)
1312+ self . cstore . def_path ( id)
13071313 }
13081314 }
13091315
13101316 #[ inline]
13111317 pub fn def_path_hash ( self , def_id : DefId ) -> rustc_hir:: definitions:: DefPathHash {
13121318 // Accessing the DefPathHash is ok, it is incr. comp. stable.
13131319 if let Some ( def_id) = def_id. as_local ( ) {
1314- self . untracked_resolutions . definitions . def_path_hash ( def_id)
1320+ self . definitions . def_path_hash ( def_id)
13151321 } else {
1316- self . untracked_resolutions . cstore . def_path_hash ( def_id)
1322+ self . cstore . def_path_hash ( def_id)
13171323 }
13181324 }
13191325
@@ -1322,7 +1328,7 @@ impl<'tcx> TyCtxt<'tcx> {
13221328 if crate_num == LOCAL_CRATE {
13231329 self . sess . local_stable_crate_id ( )
13241330 } else {
1325- self . untracked_resolutions . cstore . stable_crate_id ( crate_num)
1331+ self . cstore . stable_crate_id ( crate_num)
13261332 }
13271333 }
13281334
@@ -1333,7 +1339,7 @@ impl<'tcx> TyCtxt<'tcx> {
13331339 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
13341340 LOCAL_CRATE
13351341 } else {
1336- self . untracked_resolutions . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
1342+ self . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
13371343 }
13381344 }
13391345
@@ -1348,16 +1354,12 @@ impl<'tcx> TyCtxt<'tcx> {
13481354 // If this is a DefPathHash from the local crate, we can look up the
13491355 // DefId in the tcx's `Definitions`.
13501356 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1351- self . untracked_resolutions
1352- . definitions
1353- . local_def_path_hash_to_def_id ( hash, err)
1354- . to_def_id ( )
1357+ self . definitions . local_def_path_hash_to_def_id ( hash, err) . to_def_id ( )
13551358 } else {
13561359 // If this is a DefPathHash from an upstream crate, let the CrateStore map
13571360 // it to a DefId.
1358- let cstore = & self . untracked_resolutions . cstore ;
1359- let cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ;
1360- cstore. def_path_hash_to_def_id ( cnum, hash)
1361+ let cnum = self . cstore . stable_crate_id_to_crate_num ( stable_crate_id) ;
1362+ self . cstore . def_path_hash_to_def_id ( cnum, hash)
13611363 }
13621364 }
13631365
@@ -1369,7 +1371,7 @@ impl<'tcx> TyCtxt<'tcx> {
13691371 let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
13701372 ( self . crate_name , self . sess . local_stable_crate_id ( ) )
13711373 } else {
1372- let cstore = & self . untracked_resolutions . cstore ;
1374+ let cstore = & self . cstore ;
13731375 ( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
13741376 } ;
13751377
@@ -1385,30 +1387,24 @@ impl<'tcx> TyCtxt<'tcx> {
13851387
13861388 /// Note that this is *untracked* and should only be used within the query
13871389 /// system if the result is otherwise tracked through queries
1388- pub fn cstore_untracked ( self ) -> & ' tcx ty :: CrateStoreDyn {
1389- & * self . untracked_resolutions . cstore
1390+ pub fn cstore_untracked ( self ) -> & ' tcx CrateStoreDyn {
1391+ & * self . cstore
13901392 }
13911393
13921394 /// Note that this is *untracked* and should only be used within the query
13931395 /// system if the result is otherwise tracked through queries
13941396 pub fn definitions_untracked ( self ) -> & ' tcx hir:: definitions:: Definitions {
1395- & self . untracked_resolutions . definitions
1397+ & self . definitions
13961398 }
13971399
13981400 #[ inline( always) ]
13991401 pub fn create_stable_hashing_context ( self ) -> StableHashingContext < ' tcx > {
1400- let resolutions = & self . gcx . untracked_resolutions ;
1401- StableHashingContext :: new ( self . sess , & resolutions. definitions , & * resolutions. cstore )
1402+ StableHashingContext :: new ( self . sess , & self . definitions , & * self . cstore )
14021403 }
14031404
14041405 #[ inline( always) ]
14051406 pub fn create_no_span_stable_hashing_context ( self ) -> StableHashingContext < ' tcx > {
1406- let resolutions = & self . gcx . untracked_resolutions ;
1407- StableHashingContext :: ignore_spans (
1408- self . sess ,
1409- & resolutions. definitions ,
1410- & * resolutions. cstore ,
1411- )
1407+ StableHashingContext :: ignore_spans ( self . sess , & self . definitions , & * self . cstore )
14121408 }
14131409
14141410 pub fn serialize_query_result_cache ( self , encoder : & mut FileEncoder ) -> FileEncodeResult {
@@ -2237,7 +2233,7 @@ impl<'tcx> TyCtxt<'tcx> {
22372233 #[ allow( rustc:: usage_of_ty_tykind) ]
22382234 #[ inline]
22392235 pub fn mk_ty ( self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
2240- self . interners . intern_ty ( st, self . sess , & self . gcx . untracked_resolutions )
2236+ self . interners . intern_ty ( st, self . sess , & self . definitions , & * self . cstore )
22412237 }
22422238
22432239 #[ inline]
0 commit comments