@@ -46,6 +46,7 @@ use rustc_middle::mir::FakeReadCause;
46
46
use rustc_query_system:: ich:: { NodeIdHashingMode , StableHashingContext } ;
47
47
use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
48
48
use rustc_session:: config:: { BorrowckMode , CrateType , OutputFilenames } ;
49
+ use rustc_session:: cstore:: CrateStoreDyn ;
49
50
use rustc_session:: lint:: { Level , Lint } ;
50
51
use rustc_session:: Limit ;
51
52
use rustc_session:: Session ;
@@ -999,6 +1000,9 @@ pub struct GlobalCtxt<'tcx> {
999
1000
/// Common consts, pre-interned for your convenience.
1000
1001
pub consts : CommonConsts < ' tcx > ,
1001
1002
1003
+ pub definitions : rustc_hir:: definitions:: Definitions ,
1004
+ pub cstore : Box < CrateStoreDyn > ,
1005
+
1002
1006
/// Output of the resolver.
1003
1007
pub ( crate ) untracked_resolutions : ty:: ResolverOutputs ,
1004
1008
@@ -1145,7 +1149,9 @@ impl<'tcx> TyCtxt<'tcx> {
1145
1149
s : & ' tcx Session ,
1146
1150
lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
1147
1151
arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1148
- resolutions : ty:: ResolverOutputs ,
1152
+ definitions : rustc_hir:: definitions:: Definitions ,
1153
+ cstore : Box < CrateStoreDyn > ,
1154
+ untracked_resolutions : ty:: ResolverOutputs ,
1149
1155
krate : & ' tcx hir:: Crate < ' tcx > ,
1150
1156
dep_graph : DepGraph ,
1151
1157
on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1168,7 +1174,9 @@ impl<'tcx> TyCtxt<'tcx> {
1168
1174
arena,
1169
1175
interners,
1170
1176
dep_graph,
1171
- untracked_resolutions : resolutions,
1177
+ definitions,
1178
+ cstore,
1179
+ untracked_resolutions,
1172
1180
prof : s. prof . clone ( ) ,
1173
1181
types : common_types,
1174
1182
lifetimes : common_lifetimes,
@@ -1254,9 +1262,9 @@ impl<'tcx> TyCtxt<'tcx> {
1254
1262
pub fn def_key ( self , id : DefId ) -> rustc_hir:: definitions:: DefKey {
1255
1263
// Accessing the DefKey is ok, since it is part of DefPathHash.
1256
1264
if let Some ( id) = id. as_local ( ) {
1257
- self . untracked_resolutions . definitions . def_key ( id)
1265
+ self . definitions . def_key ( id)
1258
1266
} else {
1259
- self . untracked_resolutions . cstore . def_key ( id)
1267
+ self . cstore . def_key ( id)
1260
1268
}
1261
1269
}
1262
1270
@@ -1268,19 +1276,19 @@ impl<'tcx> TyCtxt<'tcx> {
1268
1276
pub fn def_path ( self , id : DefId ) -> rustc_hir:: definitions:: DefPath {
1269
1277
// Accessing the DefPath is ok, since it is part of DefPathHash.
1270
1278
if let Some ( id) = id. as_local ( ) {
1271
- self . untracked_resolutions . definitions . def_path ( id)
1279
+ self . definitions . def_path ( id)
1272
1280
} else {
1273
- self . untracked_resolutions . cstore . def_path ( id)
1281
+ self . cstore . def_path ( id)
1274
1282
}
1275
1283
}
1276
1284
1277
1285
#[ inline]
1278
1286
pub fn def_path_hash ( self , def_id : DefId ) -> rustc_hir:: definitions:: DefPathHash {
1279
1287
// Accessing the DefPathHash is ok, it is incr. comp. stable.
1280
1288
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)
1282
1290
} else {
1283
- self . untracked_resolutions . cstore . def_path_hash ( def_id)
1291
+ self . cstore . def_path_hash ( def_id)
1284
1292
}
1285
1293
}
1286
1294
@@ -1289,7 +1297,7 @@ impl<'tcx> TyCtxt<'tcx> {
1289
1297
if crate_num == LOCAL_CRATE {
1290
1298
self . sess . local_stable_crate_id ( )
1291
1299
} else {
1292
- self . untracked_resolutions . cstore . stable_crate_id ( crate_num)
1300
+ self . cstore . stable_crate_id ( crate_num)
1293
1301
}
1294
1302
}
1295
1303
@@ -1300,7 +1308,7 @@ impl<'tcx> TyCtxt<'tcx> {
1300
1308
if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1301
1309
LOCAL_CRATE
1302
1310
} 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)
1304
1312
}
1305
1313
}
1306
1314
@@ -1315,13 +1323,12 @@ impl<'tcx> TyCtxt<'tcx> {
1315
1323
// If this is a DefPathHash from the local crate, we can look up the
1316
1324
// DefId in the tcx's `Definitions`.
1317
1325
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 ( )
1319
1327
} else {
1320
1328
// If this is a DefPathHash from an upstream crate, let the CrateStore map
1321
1329
// 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)
1325
1332
}
1326
1333
}
1327
1334
@@ -1333,7 +1340,7 @@ impl<'tcx> TyCtxt<'tcx> {
1333
1340
let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
1334
1341
( self . crate_name , self . sess . local_stable_crate_id ( ) )
1335
1342
} else {
1336
- let cstore = & self . untracked_resolutions . cstore ;
1343
+ let cstore = & self . cstore ;
1337
1344
( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
1338
1345
} ;
1339
1346
@@ -1349,30 +1356,24 @@ impl<'tcx> TyCtxt<'tcx> {
1349
1356
1350
1357
/// Note that this is *untracked* and should only be used within the query
1351
1358
/// 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
1354
1361
}
1355
1362
1356
1363
/// Note that this is *untracked* and should only be used within the query
1357
1364
/// system if the result is otherwise tracked through queries
1358
1365
pub fn definitions_untracked ( self ) -> & ' tcx hir:: definitions:: Definitions {
1359
- & self . untracked_resolutions . definitions
1366
+ & self . definitions
1360
1367
}
1361
1368
1362
1369
#[ inline( always) ]
1363
1370
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 )
1366
1372
}
1367
1373
1368
1374
#[ inline( always) ]
1369
1375
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 )
1376
1377
}
1377
1378
1378
1379
pub fn serialize_query_result_cache ( self , encoder : & mut FileEncoder ) -> FileEncodeResult {
0 commit comments