@@ -50,6 +50,7 @@ use rustc_middle::mir::FakeReadCause;
50
50
use rustc_query_system:: ich:: StableHashingContext ;
51
51
use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
52
52
use rustc_session:: config:: { CrateType , OutputFilenames } ;
53
+ use rustc_session:: cstore:: CrateStoreDyn ;
53
54
use rustc_session:: lint:: { Level , Lint } ;
54
55
use rustc_session:: Limit ;
55
56
use rustc_session:: Session ;
@@ -177,7 +178,8 @@ impl<'tcx> CtxtInterners<'tcx> {
177
178
& self ,
178
179
kind : TyKind < ' tcx > ,
179
180
sess : & Session ,
180
- resolutions : & ty:: ResolverOutputs ,
181
+ definitions : & rustc_hir:: definitions:: Definitions ,
182
+ cstore : & CrateStoreDyn ,
181
183
) -> Ty < ' tcx > {
182
184
Ty ( Interned :: new_unchecked (
183
185
self . type_
@@ -192,11 +194,7 @@ impl<'tcx> CtxtInterners<'tcx> {
192
194
Fingerprint :: ZERO
193
195
} else {
194
196
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) ;
200
198
kind. hash_stable ( & mut hcx, & mut hasher) ;
201
199
hasher. finish ( )
202
200
} ;
@@ -934,9 +932,10 @@ impl<'tcx> CommonTypes<'tcx> {
934
932
fn new (
935
933
interners : & CtxtInterners < ' tcx > ,
936
934
sess : & Session ,
937
- resolutions : & ty:: ResolverOutputs ,
935
+ definitions : & rustc_hir:: definitions:: Definitions ,
936
+ cstore : & CrateStoreDyn ,
938
937
) -> CommonTypes < ' tcx > {
939
- let mk = |ty| interners. intern_ty ( ty, sess, resolutions ) ;
938
+ let mk = |ty| interners. intern_ty ( ty, sess, definitions , cstore ) ;
940
939
941
940
CommonTypes {
942
941
unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1057,6 +1056,9 @@ pub struct GlobalCtxt<'tcx> {
1057
1056
/// Common consts, pre-interned for your convenience.
1058
1057
pub consts : CommonConsts < ' tcx > ,
1059
1058
1059
+ definitions : rustc_hir:: definitions:: Definitions ,
1060
+ cstore : Box < CrateStoreDyn > ,
1061
+
1060
1062
/// Output of the resolver.
1061
1063
pub ( crate ) untracked_resolutions : ty:: ResolverOutputs ,
1062
1064
@@ -1218,7 +1220,9 @@ impl<'tcx> TyCtxt<'tcx> {
1218
1220
s : & ' tcx Session ,
1219
1221
lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
1220
1222
arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1221
- resolutions : ty:: ResolverOutputs ,
1223
+ definitions : rustc_hir:: definitions:: Definitions ,
1224
+ cstore : Box < CrateStoreDyn > ,
1225
+ untracked_resolutions : ty:: ResolverOutputs ,
1222
1226
krate : & ' tcx hir:: Crate < ' tcx > ,
1223
1227
dep_graph : DepGraph ,
1224
1228
on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1231,7 +1235,7 @@ impl<'tcx> TyCtxt<'tcx> {
1231
1235
s. fatal ( & err) ;
1232
1236
} ) ;
1233
1237
let interners = CtxtInterners :: new ( arena) ;
1234
- let common_types = CommonTypes :: new ( & interners, s, & resolutions ) ;
1238
+ let common_types = CommonTypes :: new ( & interners, s, & definitions , & * cstore ) ;
1235
1239
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1236
1240
let common_consts = CommonConsts :: new ( & interners, & common_types) ;
1237
1241
@@ -1241,7 +1245,9 @@ impl<'tcx> TyCtxt<'tcx> {
1241
1245
arena,
1242
1246
interners,
1243
1247
dep_graph,
1244
- untracked_resolutions : resolutions,
1248
+ definitions,
1249
+ cstore,
1250
+ untracked_resolutions,
1245
1251
prof : s. prof . clone ( ) ,
1246
1252
types : common_types,
1247
1253
lifetimes : common_lifetimes,
@@ -1342,9 +1348,9 @@ impl<'tcx> TyCtxt<'tcx> {
1342
1348
pub fn def_key ( self , id : DefId ) -> rustc_hir:: definitions:: DefKey {
1343
1349
// Accessing the DefKey is ok, since it is part of DefPathHash.
1344
1350
if let Some ( id) = id. as_local ( ) {
1345
- self . untracked_resolutions . definitions . def_key ( id)
1351
+ self . definitions . def_key ( id)
1346
1352
} else {
1347
- self . untracked_resolutions . cstore . def_key ( id)
1353
+ self . cstore . def_key ( id)
1348
1354
}
1349
1355
}
1350
1356
@@ -1356,19 +1362,19 @@ impl<'tcx> TyCtxt<'tcx> {
1356
1362
pub fn def_path ( self , id : DefId ) -> rustc_hir:: definitions:: DefPath {
1357
1363
// Accessing the DefPath is ok, since it is part of DefPathHash.
1358
1364
if let Some ( id) = id. as_local ( ) {
1359
- self . untracked_resolutions . definitions . def_path ( id)
1365
+ self . definitions . def_path ( id)
1360
1366
} else {
1361
- self . untracked_resolutions . cstore . def_path ( id)
1367
+ self . cstore . def_path ( id)
1362
1368
}
1363
1369
}
1364
1370
1365
1371
#[ inline]
1366
1372
pub fn def_path_hash ( self , def_id : DefId ) -> rustc_hir:: definitions:: DefPathHash {
1367
1373
// Accessing the DefPathHash is ok, it is incr. comp. stable.
1368
1374
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)
1370
1376
} else {
1371
- self . untracked_resolutions . cstore . def_path_hash ( def_id)
1377
+ self . cstore . def_path_hash ( def_id)
1372
1378
}
1373
1379
}
1374
1380
@@ -1377,7 +1383,7 @@ impl<'tcx> TyCtxt<'tcx> {
1377
1383
if crate_num == LOCAL_CRATE {
1378
1384
self . sess . local_stable_crate_id ( )
1379
1385
} else {
1380
- self . untracked_resolutions . cstore . stable_crate_id ( crate_num)
1386
+ self . cstore . stable_crate_id ( crate_num)
1381
1387
}
1382
1388
}
1383
1389
@@ -1388,7 +1394,7 @@ impl<'tcx> TyCtxt<'tcx> {
1388
1394
if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1389
1395
LOCAL_CRATE
1390
1396
} 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)
1392
1398
}
1393
1399
}
1394
1400
@@ -1403,16 +1409,12 @@ impl<'tcx> TyCtxt<'tcx> {
1403
1409
// If this is a DefPathHash from the local crate, we can look up the
1404
1410
// DefId in the tcx's `Definitions`.
1405
1411
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 ( )
1410
1413
} else {
1411
1414
// If this is a DefPathHash from an upstream crate, let the CrateStore map
1412
1415
// 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)
1416
1418
}
1417
1419
}
1418
1420
@@ -1424,7 +1426,7 @@ impl<'tcx> TyCtxt<'tcx> {
1424
1426
let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
1425
1427
( self . crate_name , self . sess . local_stable_crate_id ( ) )
1426
1428
} else {
1427
- let cstore = & self . untracked_resolutions . cstore ;
1429
+ let cstore = & self . cstore ;
1428
1430
( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
1429
1431
} ;
1430
1432
@@ -1440,30 +1442,24 @@ impl<'tcx> TyCtxt<'tcx> {
1440
1442
1441
1443
/// Note that this is *untracked* and should only be used within the query
1442
1444
/// 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
1445
1447
}
1446
1448
1447
1449
/// Note that this is *untracked* and should only be used within the query
1448
1450
/// system if the result is otherwise tracked through queries
1449
1451
pub fn definitions_untracked ( self ) -> & ' tcx hir:: definitions:: Definitions {
1450
- & self . untracked_resolutions . definitions
1452
+ & self . definitions
1451
1453
}
1452
1454
1453
1455
#[ inline( always) ]
1454
1456
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 )
1457
1458
}
1458
1459
1459
1460
#[ inline( always) ]
1460
1461
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 )
1467
1463
}
1468
1464
1469
1465
pub fn serialize_query_result_cache ( self , encoder : FileEncoder ) -> FileEncodeResult {
@@ -2254,7 +2250,7 @@ impl<'tcx> TyCtxt<'tcx> {
2254
2250
#[ allow( rustc:: usage_of_ty_tykind) ]
2255
2251
#[ inline]
2256
2252
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 )
2258
2254
}
2259
2255
2260
2256
#[ inline]
0 commit comments