@@ -59,7 +59,7 @@ use rustc_query_system::dep_graph::DepNodeIndex;
59
59
use rustc_query_system:: ich:: StableHashingContext ;
60
60
use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
61
61
use rustc_session:: config:: { CrateType , OutputFilenames } ;
62
- use rustc_session:: cstore:: CrateStoreDyn ;
62
+ use rustc_session:: cstore:: { CrateStoreDyn , Untracked } ;
63
63
use rustc_session:: lint:: Lint ;
64
64
use rustc_session:: Limit ;
65
65
use rustc_session:: Session ;
@@ -187,15 +187,13 @@ impl<'tcx> CtxtInterners<'tcx> {
187
187
kind : TyKind < ' tcx > ,
188
188
sess : & Session ,
189
189
definitions : & rustc_hir:: definitions:: Definitions ,
190
- cstore : & CrateStoreDyn ,
191
- source_span : & IndexVec < LocalDefId , Span > ,
190
+ untracked : & Untracked ,
192
191
) -> Ty < ' tcx > {
193
192
Ty ( Interned :: new_unchecked (
194
193
self . type_
195
194
. intern ( kind, |kind| {
196
195
let flags = super :: flags:: FlagComputation :: for_kind ( & kind) ;
197
- let stable_hash =
198
- self . stable_hash ( & flags, sess, definitions, cstore, source_span, & kind) ;
196
+ let stable_hash = self . stable_hash ( & flags, sess, definitions, untracked, & kind) ;
199
197
200
198
InternedInSet ( self . arena . alloc ( WithCachedTypeInfo {
201
199
internee : kind,
@@ -213,8 +211,7 @@ impl<'tcx> CtxtInterners<'tcx> {
213
211
flags : & ty:: flags:: FlagComputation ,
214
212
sess : & ' a Session ,
215
213
definitions : & ' a rustc_hir:: definitions:: Definitions ,
216
- cstore : & ' a CrateStoreDyn ,
217
- source_span : & ' a IndexVec < LocalDefId , Span > ,
214
+ untracked : & ' a Untracked ,
218
215
val : & T ,
219
216
) -> Fingerprint {
220
217
// It's impossible to hash inference variables (and will ICE), so we don't need to try to cache them.
@@ -223,7 +220,7 @@ impl<'tcx> CtxtInterners<'tcx> {
223
220
Fingerprint :: ZERO
224
221
} else {
225
222
let mut hasher = StableHasher :: new ( ) ;
226
- let mut hcx = StableHashingContext :: new ( sess, definitions, cstore , source_span ) ;
223
+ let mut hcx = StableHashingContext :: new ( sess, definitions, untracked ) ;
227
224
val. hash_stable ( & mut hcx, & mut hasher) ;
228
225
hasher. finish ( )
229
226
}
@@ -235,16 +232,14 @@ impl<'tcx> CtxtInterners<'tcx> {
235
232
kind : Binder < ' tcx , PredicateKind < ' tcx > > ,
236
233
sess : & Session ,
237
234
definitions : & rustc_hir:: definitions:: Definitions ,
238
- cstore : & CrateStoreDyn ,
239
- source_span : & IndexVec < LocalDefId , Span > ,
235
+ untracked : & Untracked ,
240
236
) -> Predicate < ' tcx > {
241
237
Predicate ( Interned :: new_unchecked (
242
238
self . predicate
243
239
. intern ( kind, |kind| {
244
240
let flags = super :: flags:: FlagComputation :: for_predicate ( kind) ;
245
241
246
- let stable_hash =
247
- self . stable_hash ( & flags, sess, definitions, cstore, source_span, & kind) ;
242
+ let stable_hash = self . stable_hash ( & flags, sess, definitions, untracked, & kind) ;
248
243
249
244
InternedInSet ( self . arena . alloc ( WithCachedTypeInfo {
250
245
internee : kind,
@@ -963,10 +958,9 @@ impl<'tcx> CommonTypes<'tcx> {
963
958
interners : & CtxtInterners < ' tcx > ,
964
959
sess : & Session ,
965
960
definitions : & rustc_hir:: definitions:: Definitions ,
966
- cstore : & CrateStoreDyn ,
967
- source_span : & IndexVec < LocalDefId , Span > ,
961
+ untracked : & Untracked ,
968
962
) -> CommonTypes < ' tcx > {
969
- let mk = |ty| interners. intern_ty ( ty, sess, definitions, cstore , source_span ) ;
963
+ let mk = |ty| interners. intern_ty ( ty, sess, definitions, untracked ) ;
970
964
971
965
CommonTypes {
972
966
unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1114,6 +1108,7 @@ pub struct GlobalCtxt<'tcx> {
1114
1108
1115
1109
definitions : RwLock < Definitions > ,
1116
1110
1111
+ untracked : Untracked ,
1117
1112
/// Output of the resolver.
1118
1113
pub ( crate ) untracked_resolutions : ty:: ResolverGlobalCtxt ,
1119
1114
/// The entire crate as AST. This field serves as the input for the hir_crate query,
@@ -1280,6 +1275,7 @@ impl<'tcx> TyCtxt<'tcx> {
1280
1275
hir_arena : & ' tcx WorkerLocal < hir:: Arena < ' tcx > > ,
1281
1276
definitions : Definitions ,
1282
1277
untracked_resolutions : ty:: ResolverGlobalCtxt ,
1278
+ untracked : Untracked ,
1283
1279
krate : Lrc < ast:: Crate > ,
1284
1280
dep_graph : DepGraph ,
1285
1281
on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1292,14 +1288,7 @@ impl<'tcx> TyCtxt<'tcx> {
1292
1288
s. emit_fatal ( err) ;
1293
1289
} ) ;
1294
1290
let interners = CtxtInterners :: new ( arena) ;
1295
- let common_types = CommonTypes :: new (
1296
- & interners,
1297
- s,
1298
- & definitions,
1299
- & * untracked_resolutions. cstore ,
1300
- // This is only used to create a stable hashing context.
1301
- & untracked_resolutions. source_span ,
1302
- ) ;
1291
+ let common_types = CommonTypes :: new ( & interners, s, & definitions, & untracked) ;
1303
1292
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1304
1293
let common_consts = CommonConsts :: new ( & interners, & common_types) ;
1305
1294
@@ -1315,6 +1304,7 @@ impl<'tcx> TyCtxt<'tcx> {
1315
1304
types : common_types,
1316
1305
lifetimes : common_lifetimes,
1317
1306
consts : common_consts,
1307
+ untracked,
1318
1308
untracked_resolutions,
1319
1309
untracked_crate : Steal :: new ( krate) ,
1320
1310
on_disk_cache,
@@ -1428,7 +1418,7 @@ impl<'tcx> TyCtxt<'tcx> {
1428
1418
if let Some ( id) = id. as_local ( ) {
1429
1419
self . definitions_untracked ( ) . def_key ( id)
1430
1420
} else {
1431
- self . untracked_resolutions . cstore . def_key ( id)
1421
+ self . untracked . cstore . def_key ( id)
1432
1422
}
1433
1423
}
1434
1424
@@ -1442,7 +1432,7 @@ impl<'tcx> TyCtxt<'tcx> {
1442
1432
if let Some ( id) = id. as_local ( ) {
1443
1433
self . definitions_untracked ( ) . def_path ( id)
1444
1434
} else {
1445
- self . untracked_resolutions . cstore . def_path ( id)
1435
+ self . untracked . cstore . def_path ( id)
1446
1436
}
1447
1437
}
1448
1438
@@ -1452,7 +1442,7 @@ impl<'tcx> TyCtxt<'tcx> {
1452
1442
if let Some ( def_id) = def_id. as_local ( ) {
1453
1443
self . definitions_untracked ( ) . def_path_hash ( def_id)
1454
1444
} else {
1455
- self . untracked_resolutions . cstore . def_path_hash ( def_id)
1445
+ self . untracked . cstore . def_path_hash ( def_id)
1456
1446
}
1457
1447
}
1458
1448
@@ -1461,7 +1451,7 @@ impl<'tcx> TyCtxt<'tcx> {
1461
1451
if crate_num == LOCAL_CRATE {
1462
1452
self . sess . local_stable_crate_id ( )
1463
1453
} else {
1464
- self . untracked_resolutions . cstore . stable_crate_id ( crate_num)
1454
+ self . untracked . cstore . stable_crate_id ( crate_num)
1465
1455
}
1466
1456
}
1467
1457
@@ -1472,7 +1462,7 @@ impl<'tcx> TyCtxt<'tcx> {
1472
1462
if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1473
1463
LOCAL_CRATE
1474
1464
} else {
1475
- self . untracked_resolutions . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
1465
+ self . untracked . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
1476
1466
}
1477
1467
}
1478
1468
@@ -1491,7 +1481,7 @@ impl<'tcx> TyCtxt<'tcx> {
1491
1481
} else {
1492
1482
// If this is a DefPathHash from an upstream crate, let the CrateStore map
1493
1483
// it to a DefId.
1494
- let cstore = & * self . untracked_resolutions . cstore ;
1484
+ let cstore = & * self . untracked . cstore ;
1495
1485
let cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ;
1496
1486
cstore. def_path_hash_to_def_id ( cnum, hash)
1497
1487
}
@@ -1505,7 +1495,7 @@ impl<'tcx> TyCtxt<'tcx> {
1505
1495
let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
1506
1496
( self . crate_name , self . sess . local_stable_crate_id ( ) )
1507
1497
} else {
1508
- let cstore = & * self . untracked_resolutions . cstore ;
1498
+ let cstore = & * self . untracked . cstore ;
1509
1499
( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
1510
1500
} ;
1511
1501
@@ -1604,7 +1594,7 @@ impl<'tcx> TyCtxt<'tcx> {
1604
1594
/// Note that this is *untracked* and should only be used within the query
1605
1595
/// system if the result is otherwise tracked through queries
1606
1596
pub fn cstore_untracked ( self ) -> & ' tcx CrateStoreDyn {
1607
- & * self . untracked_resolutions . cstore
1597
+ & * self . untracked . cstore
1608
1598
}
1609
1599
1610
1600
/// Note that this is *untracked* and should only be used within the query
@@ -1618,7 +1608,7 @@ impl<'tcx> TyCtxt<'tcx> {
1618
1608
/// system if the result is otherwise tracked through queries
1619
1609
#[ inline]
1620
1610
pub fn source_span_untracked ( self , def_id : LocalDefId ) -> Span {
1621
- self . untracked_resolutions . source_span . get ( def_id) . copied ( ) . unwrap_or ( DUMMY_SP )
1611
+ self . untracked . source_span . get ( def_id) . copied ( ) . unwrap_or ( DUMMY_SP )
1622
1612
}
1623
1613
1624
1614
#[ inline( always) ]
@@ -1627,12 +1617,7 @@ impl<'tcx> TyCtxt<'tcx> {
1627
1617
f : impl FnOnce ( StableHashingContext < ' _ > ) -> R ,
1628
1618
) -> R {
1629
1619
let definitions = self . definitions_untracked ( ) ;
1630
- let hcx = StableHashingContext :: new (
1631
- self . sess ,
1632
- & * definitions,
1633
- & * self . untracked_resolutions . cstore ,
1634
- & self . untracked_resolutions . source_span ,
1635
- ) ;
1620
+ let hcx = StableHashingContext :: new ( self . sess , & * definitions, & self . untracked ) ;
1636
1621
f ( hcx)
1637
1622
}
1638
1623
@@ -2428,9 +2413,8 @@ impl<'tcx> TyCtxt<'tcx> {
2428
2413
st,
2429
2414
self . sess ,
2430
2415
& self . definitions . read ( ) ,
2431
- & * self . untracked_resolutions . cstore ,
2432
2416
// This is only used to create a stable hashing context.
2433
- & self . untracked_resolutions . source_span ,
2417
+ & self . untracked ,
2434
2418
)
2435
2419
}
2436
2420
@@ -2440,9 +2424,8 @@ impl<'tcx> TyCtxt<'tcx> {
2440
2424
binder,
2441
2425
self . sess ,
2442
2426
& self . definitions . read ( ) ,
2443
- & * self . untracked_resolutions . cstore ,
2444
2427
// This is only used to create a stable hashing context.
2445
- & self . untracked_resolutions . source_span ,
2428
+ & self . untracked ,
2446
2429
)
2447
2430
}
2448
2431
@@ -3124,4 +3107,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
3124
3107
// We want to check if the panic handler was defined in this crate
3125
3108
tcx. lang_items ( ) . panic_impl ( ) . map_or ( false , |did| did. is_local ( ) )
3126
3109
} ;
3110
+ providers. source_span =
3111
+ |tcx, def_id| tcx. untracked . source_span . get ( def_id) . copied ( ) . unwrap_or ( DUMMY_SP ) ;
3127
3112
}
0 commit comments