@@ -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:: { CrateType , OutputFilenames } ;
53+ use rustc_session:: cstore:: CrateStoreDyn ;
5354use rustc_session:: lint:: { Level , Lint } ;
5455use rustc_session:: Limit ;
5556use rustc_session:: Session ;
@@ -177,7 +178,8 @@ impl<'tcx> CtxtInterners<'tcx> {
177178 & self ,
178179 kind : TyKind < ' tcx > ,
179180 sess : & Session ,
180- resolutions : & ty:: ResolverOutputs ,
181+ definitions : & rustc_hir:: definitions:: Definitions ,
182+ cstore : & CrateStoreDyn ,
181183 ) -> Ty < ' tcx > {
182184 Ty ( Interned :: new_unchecked (
183185 self . type_
@@ -192,11 +194,7 @@ impl<'tcx> CtxtInterners<'tcx> {
192194 Fingerprint :: ZERO
193195 } else {
194196 let mut hasher = StableHasher :: new ( ) ;
195- let mut hcx = StableHashingContext :: ignore_spans (
196- sess,
197- & resolutions. definitions ,
198- & * resolutions. cstore ,
199- ) ;
197+ let mut hcx = StableHashingContext :: ignore_spans ( sess, definitions, cstore) ;
200198 kind. hash_stable ( & mut hcx, & mut hasher) ;
201199 hasher. finish ( )
202200 } ;
@@ -934,9 +932,10 @@ impl<'tcx> CommonTypes<'tcx> {
934932 fn new (
935933 interners : & CtxtInterners < ' tcx > ,
936934 sess : & Session ,
937- resolutions : & ty:: ResolverOutputs ,
935+ definitions : & rustc_hir:: definitions:: Definitions ,
936+ cstore : & CrateStoreDyn ,
938937 ) -> CommonTypes < ' tcx > {
939- let mk = |ty| interners. intern_ty ( ty, sess, resolutions ) ;
938+ let mk = |ty| interners. intern_ty ( ty, sess, definitions , cstore ) ;
940939
941940 CommonTypes {
942941 unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1057,6 +1056,9 @@ pub struct GlobalCtxt<'tcx> {
10571056 /// Common consts, pre-interned for your convenience.
10581057 pub consts : CommonConsts < ' tcx > ,
10591058
1059+ definitions : rustc_hir:: definitions:: Definitions ,
1060+ cstore : Box < CrateStoreDyn > ,
1061+
10601062 /// Output of the resolver.
10611063 pub ( crate ) untracked_resolutions : ty:: ResolverOutputs ,
10621064
@@ -1218,7 +1220,9 @@ impl<'tcx> TyCtxt<'tcx> {
12181220 s : & ' tcx Session ,
12191221 lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
12201222 arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1221- resolutions : ty:: ResolverOutputs ,
1223+ definitions : rustc_hir:: definitions:: Definitions ,
1224+ cstore : Box < CrateStoreDyn > ,
1225+ untracked_resolutions : ty:: ResolverOutputs ,
12221226 krate : & ' tcx hir:: Crate < ' tcx > ,
12231227 dep_graph : DepGraph ,
12241228 on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1231,7 +1235,7 @@ impl<'tcx> TyCtxt<'tcx> {
12311235 s. fatal ( & err) ;
12321236 } ) ;
12331237 let interners = CtxtInterners :: new ( arena) ;
1234- let common_types = CommonTypes :: new ( & interners, s, & resolutions ) ;
1238+ let common_types = CommonTypes :: new ( & interners, s, & definitions , & * cstore ) ;
12351239 let common_lifetimes = CommonLifetimes :: new ( & interners) ;
12361240 let common_consts = CommonConsts :: new ( & interners, & common_types) ;
12371241
@@ -1241,7 +1245,9 @@ impl<'tcx> TyCtxt<'tcx> {
12411245 arena,
12421246 interners,
12431247 dep_graph,
1244- untracked_resolutions : resolutions,
1248+ definitions,
1249+ cstore,
1250+ untracked_resolutions,
12451251 prof : s. prof . clone ( ) ,
12461252 types : common_types,
12471253 lifetimes : common_lifetimes,
@@ -1342,9 +1348,9 @@ impl<'tcx> TyCtxt<'tcx> {
13421348 pub fn def_key ( self , id : DefId ) -> rustc_hir:: definitions:: DefKey {
13431349 // Accessing the DefKey is ok, since it is part of DefPathHash.
13441350 if let Some ( id) = id. as_local ( ) {
1345- self . untracked_resolutions . definitions . def_key ( id)
1351+ self . definitions . def_key ( id)
13461352 } else {
1347- self . untracked_resolutions . cstore . def_key ( id)
1353+ self . cstore . def_key ( id)
13481354 }
13491355 }
13501356
@@ -1356,19 +1362,19 @@ impl<'tcx> TyCtxt<'tcx> {
13561362 pub fn def_path ( self , id : DefId ) -> rustc_hir:: definitions:: DefPath {
13571363 // Accessing the DefPath is ok, since it is part of DefPathHash.
13581364 if let Some ( id) = id. as_local ( ) {
1359- self . untracked_resolutions . definitions . def_path ( id)
1365+ self . definitions . def_path ( id)
13601366 } else {
1361- self . untracked_resolutions . cstore . def_path ( id)
1367+ self . cstore . def_path ( id)
13621368 }
13631369 }
13641370
13651371 #[ inline]
13661372 pub fn def_path_hash ( self , def_id : DefId ) -> rustc_hir:: definitions:: DefPathHash {
13671373 // Accessing the DefPathHash is ok, it is incr. comp. stable.
13681374 if let Some ( def_id) = def_id. as_local ( ) {
1369- self . untracked_resolutions . definitions . def_path_hash ( def_id)
1375+ self . definitions . def_path_hash ( def_id)
13701376 } else {
1371- self . untracked_resolutions . cstore . def_path_hash ( def_id)
1377+ self . cstore . def_path_hash ( def_id)
13721378 }
13731379 }
13741380
@@ -1377,7 +1383,7 @@ impl<'tcx> TyCtxt<'tcx> {
13771383 if crate_num == LOCAL_CRATE {
13781384 self . sess . local_stable_crate_id ( )
13791385 } else {
1380- self . untracked_resolutions . cstore . stable_crate_id ( crate_num)
1386+ self . cstore . stable_crate_id ( crate_num)
13811387 }
13821388 }
13831389
@@ -1388,7 +1394,7 @@ impl<'tcx> TyCtxt<'tcx> {
13881394 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
13891395 LOCAL_CRATE
13901396 } else {
1391- self . untracked_resolutions . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
1397+ self . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
13921398 }
13931399 }
13941400
@@ -1403,16 +1409,12 @@ impl<'tcx> TyCtxt<'tcx> {
14031409 // If this is a DefPathHash from the local crate, we can look up the
14041410 // DefId in the tcx's `Definitions`.
14051411 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1406- self . untracked_resolutions
1407- . definitions
1408- . local_def_path_hash_to_def_id ( hash, err)
1409- . to_def_id ( )
1412+ self . definitions . local_def_path_hash_to_def_id ( hash, err) . to_def_id ( )
14101413 } else {
14111414 // If this is a DefPathHash from an upstream crate, let the CrateStore map
14121415 // it to a DefId.
1413- let cstore = & self . untracked_resolutions . cstore ;
1414- let cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ;
1415- cstore. def_path_hash_to_def_id ( cnum, hash)
1416+ let cnum = self . cstore . stable_crate_id_to_crate_num ( stable_crate_id) ;
1417+ self . cstore . def_path_hash_to_def_id ( cnum, hash)
14161418 }
14171419 }
14181420
@@ -1424,7 +1426,7 @@ impl<'tcx> TyCtxt<'tcx> {
14241426 let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
14251427 ( self . crate_name , self . sess . local_stable_crate_id ( ) )
14261428 } else {
1427- let cstore = & self . untracked_resolutions . cstore ;
1429+ let cstore = & self . cstore ;
14281430 ( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
14291431 } ;
14301432
@@ -1440,30 +1442,24 @@ impl<'tcx> TyCtxt<'tcx> {
14401442
14411443 /// Note that this is *untracked* and should only be used within the query
14421444 /// system if the result is otherwise tracked through queries
1443- pub fn cstore_untracked ( self ) -> & ' tcx ty :: CrateStoreDyn {
1444- & * self . untracked_resolutions . cstore
1445+ pub fn cstore_untracked ( self ) -> & ' tcx CrateStoreDyn {
1446+ & * self . cstore
14451447 }
14461448
14471449 /// Note that this is *untracked* and should only be used within the query
14481450 /// system if the result is otherwise tracked through queries
14491451 pub fn definitions_untracked ( self ) -> & ' tcx hir:: definitions:: Definitions {
1450- & self . untracked_resolutions . definitions
1452+ & self . definitions
14511453 }
14521454
14531455 #[ inline( always) ]
14541456 pub fn create_stable_hashing_context ( self ) -> StableHashingContext < ' tcx > {
1455- let resolutions = & self . gcx . untracked_resolutions ;
1456- StableHashingContext :: new ( self . sess , & resolutions. definitions , & * resolutions. cstore )
1457+ StableHashingContext :: new ( self . sess , & self . definitions , & * self . cstore )
14571458 }
14581459
14591460 #[ inline( always) ]
14601461 pub fn create_no_span_stable_hashing_context ( self ) -> StableHashingContext < ' tcx > {
1461- let resolutions = & self . gcx . untracked_resolutions ;
1462- StableHashingContext :: ignore_spans (
1463- self . sess ,
1464- & resolutions. definitions ,
1465- & * resolutions. cstore ,
1466- )
1462+ StableHashingContext :: ignore_spans ( self . sess , & self . definitions , & * self . cstore )
14671463 }
14681464
14691465 pub fn serialize_query_result_cache ( self , encoder : FileEncoder ) -> FileEncodeResult {
@@ -2254,7 +2250,7 @@ impl<'tcx> TyCtxt<'tcx> {
22542250 #[ allow( rustc:: usage_of_ty_tykind) ]
22552251 #[ inline]
22562252 pub fn mk_ty ( self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
2257- self . interners . intern_ty ( st, self . sess , & self . gcx . untracked_resolutions )
2253+ self . interners . intern_ty ( st, self . sess , & self . definitions , & * self . cstore )
22582254 }
22592255
22602256 #[ inline]
0 commit comments