@@ -46,6 +46,7 @@ use rustc_middle::mir::FakeReadCause;
4646use rustc_query_system:: ich:: { NodeIdHashingMode , StableHashingContext } ;
4747use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
4848use rustc_session:: config:: { BorrowckMode , CrateType , OutputFilenames } ;
49+ use rustc_session:: cstore:: CrateStoreDyn ;
4950use rustc_session:: lint:: { Level , Lint } ;
5051use rustc_session:: Limit ;
5152use rustc_session:: Session ;
@@ -999,6 +1000,9 @@ pub struct GlobalCtxt<'tcx> {
9991000 /// Common consts, pre-interned for your convenience.
10001001 pub consts : CommonConsts < ' tcx > ,
10011002
1003+ pub definitions : rustc_hir:: definitions:: Definitions ,
1004+ pub cstore : Box < CrateStoreDyn > ,
1005+
10021006 /// Output of the resolver.
10031007 pub ( crate ) untracked_resolutions : ty:: ResolverOutputs ,
10041008
@@ -1145,7 +1149,9 @@ impl<'tcx> TyCtxt<'tcx> {
11451149 s : & ' tcx Session ,
11461150 lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
11471151 arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1148- resolutions : ty:: ResolverOutputs ,
1152+ definitions : rustc_hir:: definitions:: Definitions ,
1153+ cstore : Box < CrateStoreDyn > ,
1154+ untracked_resolutions : ty:: ResolverOutputs ,
11491155 krate : & ' tcx hir:: Crate < ' tcx > ,
11501156 dep_graph : DepGraph ,
11511157 on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1168,7 +1174,9 @@ impl<'tcx> TyCtxt<'tcx> {
11681174 arena,
11691175 interners,
11701176 dep_graph,
1171- untracked_resolutions : resolutions,
1177+ definitions,
1178+ cstore,
1179+ untracked_resolutions,
11721180 prof : s. prof . clone ( ) ,
11731181 types : common_types,
11741182 lifetimes : common_lifetimes,
@@ -1254,9 +1262,9 @@ impl<'tcx> TyCtxt<'tcx> {
12541262 pub fn def_key ( self , id : DefId ) -> rustc_hir:: definitions:: DefKey {
12551263 // Accessing the DefKey is ok, since it is part of DefPathHash.
12561264 if let Some ( id) = id. as_local ( ) {
1257- self . untracked_resolutions . definitions . def_key ( id)
1265+ self . definitions . def_key ( id)
12581266 } else {
1259- self . untracked_resolutions . cstore . def_key ( id)
1267+ self . cstore . def_key ( id)
12601268 }
12611269 }
12621270
@@ -1268,19 +1276,19 @@ impl<'tcx> TyCtxt<'tcx> {
12681276 pub fn def_path ( self , id : DefId ) -> rustc_hir:: definitions:: DefPath {
12691277 // Accessing the DefPath is ok, since it is part of DefPathHash.
12701278 if let Some ( id) = id. as_local ( ) {
1271- self . untracked_resolutions . definitions . def_path ( id)
1279+ self . definitions . def_path ( id)
12721280 } else {
1273- self . untracked_resolutions . cstore . def_path ( id)
1281+ self . cstore . def_path ( id)
12741282 }
12751283 }
12761284
12771285 #[ inline]
12781286 pub fn def_path_hash ( self , def_id : DefId ) -> rustc_hir:: definitions:: DefPathHash {
12791287 // Accessing the DefPathHash is ok, it is incr. comp. stable.
12801288 if let Some ( def_id) = def_id. as_local ( ) {
1281- self . untracked_resolutions . definitions . def_path_hash ( def_id)
1289+ self . definitions . def_path_hash ( def_id)
12821290 } else {
1283- self . untracked_resolutions . cstore . def_path_hash ( def_id)
1291+ self . cstore . def_path_hash ( def_id)
12841292 }
12851293 }
12861294
@@ -1289,7 +1297,7 @@ impl<'tcx> TyCtxt<'tcx> {
12891297 if crate_num == LOCAL_CRATE {
12901298 self . sess . local_stable_crate_id ( )
12911299 } else {
1292- self . untracked_resolutions . cstore . stable_crate_id ( crate_num)
1300+ self . cstore . stable_crate_id ( crate_num)
12931301 }
12941302 }
12951303
@@ -1300,7 +1308,7 @@ impl<'tcx> TyCtxt<'tcx> {
13001308 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
13011309 LOCAL_CRATE
13021310 } else {
1303- self . untracked_resolutions . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
1311+ self . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
13041312 }
13051313 }
13061314
@@ -1315,13 +1323,12 @@ impl<'tcx> TyCtxt<'tcx> {
13151323 // If this is a DefPathHash from the local crate, we can look up the
13161324 // DefId in the tcx's `Definitions`.
13171325 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1318- self . untracked_resolutions . definitions . local_def_path_hash_to_def_id ( hash) . to_def_id ( )
1326+ self . definitions . local_def_path_hash_to_def_id ( hash) . to_def_id ( )
13191327 } else {
13201328 // If this is a DefPathHash from an upstream crate, let the CrateStore map
13211329 // it to a DefId.
1322- let cstore = & self . untracked_resolutions . cstore ;
1323- let cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ;
1324- cstore. def_path_hash_to_def_id ( cnum, hash)
1330+ let cnum = self . cstore . stable_crate_id_to_crate_num ( stable_crate_id) ;
1331+ self . cstore . def_path_hash_to_def_id ( cnum, hash)
13251332 }
13261333 }
13271334
@@ -1333,7 +1340,7 @@ impl<'tcx> TyCtxt<'tcx> {
13331340 let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
13341341 ( self . crate_name , self . sess . local_stable_crate_id ( ) )
13351342 } else {
1336- let cstore = & self . untracked_resolutions . cstore ;
1343+ let cstore = & self . cstore ;
13371344 ( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
13381345 } ;
13391346
@@ -1349,30 +1356,24 @@ impl<'tcx> TyCtxt<'tcx> {
13491356
13501357 /// Note that this is *untracked* and should only be used within the query
13511358 /// system if the result is otherwise tracked through queries
1352- pub fn cstore_untracked ( self ) -> & ' tcx ty :: CrateStoreDyn {
1353- & * self . untracked_resolutions . cstore
1359+ pub fn cstore_untracked ( self ) -> & ' tcx CrateStoreDyn {
1360+ & * self . cstore
13541361 }
13551362
13561363 /// Note that this is *untracked* and should only be used within the query
13571364 /// system if the result is otherwise tracked through queries
13581365 pub fn definitions_untracked ( self ) -> & ' tcx hir:: definitions:: Definitions {
1359- & self . untracked_resolutions . definitions
1366+ & self . definitions
13601367 }
13611368
13621369 #[ inline( always) ]
13631370 pub fn create_stable_hashing_context ( self ) -> StableHashingContext < ' tcx > {
1364- let resolutions = & self . gcx . untracked_resolutions ;
1365- StableHashingContext :: new ( self . sess , & resolutions. definitions , & * resolutions. cstore )
1371+ StableHashingContext :: new ( self . sess , & self . definitions , & * self . cstore )
13661372 }
13671373
13681374 #[ inline( always) ]
13691375 pub fn create_no_span_stable_hashing_context ( self ) -> StableHashingContext < ' tcx > {
1370- let resolutions = & self . gcx . untracked_resolutions ;
1371- StableHashingContext :: ignore_spans (
1372- self . sess ,
1373- & resolutions. definitions ,
1374- & * resolutions. cstore ,
1375- )
1376+ StableHashingContext :: ignore_spans ( self . sess , & self . definitions , & * self . cstore )
13761377 }
13771378
13781379 pub fn serialize_query_result_cache ( self , encoder : & mut FileEncoder ) -> FileEncodeResult {
0 commit comments