@@ -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:: { BorrowckMode , 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 ;
@@ -150,7 +151,8 @@ impl<'tcx> CtxtInterners<'tcx> {
150
151
& self ,
151
152
kind : TyKind < ' tcx > ,
152
153
sess : & Session ,
153
- resolutions : & ty:: ResolverOutputs ,
154
+ definitions : & rustc_hir:: definitions:: Definitions ,
155
+ cstore : & CrateStoreDyn ,
154
156
) -> Ty < ' tcx > {
155
157
Ty ( Interned :: new_unchecked (
156
158
self . type_
@@ -165,11 +167,7 @@ impl<'tcx> CtxtInterners<'tcx> {
165
167
Fingerprint :: ZERO
166
168
} else {
167
169
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) ;
173
171
kind. hash_stable ( & mut hcx, & mut hasher) ;
174
172
hasher. finish ( )
175
173
} ;
@@ -900,9 +898,10 @@ impl<'tcx> CommonTypes<'tcx> {
900
898
fn new (
901
899
interners : & CtxtInterners < ' tcx > ,
902
900
sess : & Session ,
903
- resolutions : & ty:: ResolverOutputs ,
901
+ definitions : & rustc_hir:: definitions:: Definitions ,
902
+ cstore : & CrateStoreDyn ,
904
903
) -> CommonTypes < ' tcx > {
905
- let mk = |ty| interners. intern_ty ( ty, sess, resolutions ) ;
904
+ let mk = |ty| interners. intern_ty ( ty, sess, definitions , cstore ) ;
906
905
907
906
CommonTypes {
908
907
unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1023,6 +1022,9 @@ pub struct GlobalCtxt<'tcx> {
1023
1022
/// Common consts, pre-interned for your convenience.
1024
1023
pub consts : CommonConsts < ' tcx > ,
1025
1024
1025
+ definitions : rustc_hir:: definitions:: Definitions ,
1026
+ cstore : Box < CrateStoreDyn > ,
1027
+
1026
1028
/// Output of the resolver.
1027
1029
pub ( crate ) untracked_resolutions : ty:: ResolverOutputs ,
1028
1030
@@ -1163,7 +1165,9 @@ impl<'tcx> TyCtxt<'tcx> {
1163
1165
s : & ' tcx Session ,
1164
1166
lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
1165
1167
arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1166
- resolutions : ty:: ResolverOutputs ,
1168
+ definitions : rustc_hir:: definitions:: Definitions ,
1169
+ cstore : Box < CrateStoreDyn > ,
1170
+ untracked_resolutions : ty:: ResolverOutputs ,
1167
1171
krate : & ' tcx hir:: Crate < ' tcx > ,
1168
1172
dep_graph : DepGraph ,
1169
1173
on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1176,7 +1180,7 @@ impl<'tcx> TyCtxt<'tcx> {
1176
1180
s. fatal ( & err) ;
1177
1181
} ) ;
1178
1182
let interners = CtxtInterners :: new ( arena) ;
1179
- let common_types = CommonTypes :: new ( & interners, s, & resolutions ) ;
1183
+ let common_types = CommonTypes :: new ( & interners, s, & definitions , & * cstore ) ;
1180
1184
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1181
1185
let common_consts = CommonConsts :: new ( & interners, & common_types) ;
1182
1186
@@ -1186,7 +1190,9 @@ impl<'tcx> TyCtxt<'tcx> {
1186
1190
arena,
1187
1191
interners,
1188
1192
dep_graph,
1189
- untracked_resolutions : resolutions,
1193
+ definitions,
1194
+ cstore,
1195
+ untracked_resolutions,
1190
1196
prof : s. prof . clone ( ) ,
1191
1197
types : common_types,
1192
1198
lifetimes : common_lifetimes,
@@ -1287,9 +1293,9 @@ impl<'tcx> TyCtxt<'tcx> {
1287
1293
pub fn def_key ( self , id : DefId ) -> rustc_hir:: definitions:: DefKey {
1288
1294
// Accessing the DefKey is ok, since it is part of DefPathHash.
1289
1295
if let Some ( id) = id. as_local ( ) {
1290
- self . untracked_resolutions . definitions . def_key ( id)
1296
+ self . definitions . def_key ( id)
1291
1297
} else {
1292
- self . untracked_resolutions . cstore . def_key ( id)
1298
+ self . cstore . def_key ( id)
1293
1299
}
1294
1300
}
1295
1301
@@ -1301,19 +1307,19 @@ impl<'tcx> TyCtxt<'tcx> {
1301
1307
pub fn def_path ( self , id : DefId ) -> rustc_hir:: definitions:: DefPath {
1302
1308
// Accessing the DefPath is ok, since it is part of DefPathHash.
1303
1309
if let Some ( id) = id. as_local ( ) {
1304
- self . untracked_resolutions . definitions . def_path ( id)
1310
+ self . definitions . def_path ( id)
1305
1311
} else {
1306
- self . untracked_resolutions . cstore . def_path ( id)
1312
+ self . cstore . def_path ( id)
1307
1313
}
1308
1314
}
1309
1315
1310
1316
#[ inline]
1311
1317
pub fn def_path_hash ( self , def_id : DefId ) -> rustc_hir:: definitions:: DefPathHash {
1312
1318
// Accessing the DefPathHash is ok, it is incr. comp. stable.
1313
1319
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)
1315
1321
} else {
1316
- self . untracked_resolutions . cstore . def_path_hash ( def_id)
1322
+ self . cstore . def_path_hash ( def_id)
1317
1323
}
1318
1324
}
1319
1325
@@ -1322,7 +1328,7 @@ impl<'tcx> TyCtxt<'tcx> {
1322
1328
if crate_num == LOCAL_CRATE {
1323
1329
self . sess . local_stable_crate_id ( )
1324
1330
} else {
1325
- self . untracked_resolutions . cstore . stable_crate_id ( crate_num)
1331
+ self . cstore . stable_crate_id ( crate_num)
1326
1332
}
1327
1333
}
1328
1334
@@ -1333,7 +1339,7 @@ impl<'tcx> TyCtxt<'tcx> {
1333
1339
if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1334
1340
LOCAL_CRATE
1335
1341
} 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)
1337
1343
}
1338
1344
}
1339
1345
@@ -1348,16 +1354,12 @@ impl<'tcx> TyCtxt<'tcx> {
1348
1354
// If this is a DefPathHash from the local crate, we can look up the
1349
1355
// DefId in the tcx's `Definitions`.
1350
1356
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 ( )
1355
1358
} else {
1356
1359
// If this is a DefPathHash from an upstream crate, let the CrateStore map
1357
1360
// 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)
1361
1363
}
1362
1364
}
1363
1365
@@ -1369,7 +1371,7 @@ impl<'tcx> TyCtxt<'tcx> {
1369
1371
let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
1370
1372
( self . crate_name , self . sess . local_stable_crate_id ( ) )
1371
1373
} else {
1372
- let cstore = & self . untracked_resolutions . cstore ;
1374
+ let cstore = & self . cstore ;
1373
1375
( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
1374
1376
} ;
1375
1377
@@ -1385,30 +1387,24 @@ impl<'tcx> TyCtxt<'tcx> {
1385
1387
1386
1388
/// Note that this is *untracked* and should only be used within the query
1387
1389
/// 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
1390
1392
}
1391
1393
1392
1394
/// Note that this is *untracked* and should only be used within the query
1393
1395
/// system if the result is otherwise tracked through queries
1394
1396
pub fn definitions_untracked ( self ) -> & ' tcx hir:: definitions:: Definitions {
1395
- & self . untracked_resolutions . definitions
1397
+ & self . definitions
1396
1398
}
1397
1399
1398
1400
#[ inline( always) ]
1399
1401
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 )
1402
1403
}
1403
1404
1404
1405
#[ inline( always) ]
1405
1406
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 )
1412
1408
}
1413
1409
1414
1410
pub fn serialize_query_result_cache ( self , encoder : & mut FileEncoder ) -> FileEncodeResult {
@@ -2237,7 +2233,7 @@ impl<'tcx> TyCtxt<'tcx> {
2237
2233
#[ allow( rustc:: usage_of_ty_tykind) ]
2238
2234
#[ inline]
2239
2235
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 )
2241
2237
}
2242
2238
2243
2239
#[ inline]
0 commit comments