@@ -59,7 +59,7 @@ use rustc_query_system::dep_graph::DepNodeIndex;
5959use rustc_query_system:: ich:: StableHashingContext ;
6060use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
6161use rustc_session:: config:: { CrateType , OutputFilenames } ;
62- use rustc_session:: cstore:: CrateStoreDyn ;
62+ use rustc_session:: cstore:: { CrateStoreDyn , Untracked } ;
6363use rustc_session:: lint:: Lint ;
6464use rustc_session:: Limit ;
6565use rustc_session:: Session ;
@@ -187,15 +187,13 @@ impl<'tcx> CtxtInterners<'tcx> {
187187 kind : TyKind < ' tcx > ,
188188 sess : & Session ,
189189 definitions : & rustc_hir:: definitions:: Definitions ,
190- cstore : & CrateStoreDyn ,
191- source_span : & IndexVec < LocalDefId , Span > ,
190+ untracked : & Untracked ,
192191 ) -> Ty < ' tcx > {
193192 Ty ( Interned :: new_unchecked (
194193 self . type_
195194 . intern ( kind, |kind| {
196195 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) ;
199197
200198 InternedInSet ( self . arena . alloc ( WithCachedTypeInfo {
201199 internee : kind,
@@ -213,8 +211,7 @@ impl<'tcx> CtxtInterners<'tcx> {
213211 flags : & ty:: flags:: FlagComputation ,
214212 sess : & ' a Session ,
215213 definitions : & ' a rustc_hir:: definitions:: Definitions ,
216- cstore : & ' a CrateStoreDyn ,
217- source_span : & ' a IndexVec < LocalDefId , Span > ,
214+ untracked : & ' a Untracked ,
218215 val : & T ,
219216 ) -> Fingerprint {
220217 // 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> {
223220 Fingerprint :: ZERO
224221 } else {
225222 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 ) ;
227224 val. hash_stable ( & mut hcx, & mut hasher) ;
228225 hasher. finish ( )
229226 }
@@ -235,16 +232,14 @@ impl<'tcx> CtxtInterners<'tcx> {
235232 kind : Binder < ' tcx , PredicateKind < ' tcx > > ,
236233 sess : & Session ,
237234 definitions : & rustc_hir:: definitions:: Definitions ,
238- cstore : & CrateStoreDyn ,
239- source_span : & IndexVec < LocalDefId , Span > ,
235+ untracked : & Untracked ,
240236 ) -> Predicate < ' tcx > {
241237 Predicate ( Interned :: new_unchecked (
242238 self . predicate
243239 . intern ( kind, |kind| {
244240 let flags = super :: flags:: FlagComputation :: for_predicate ( kind) ;
245241
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) ;
248243
249244 InternedInSet ( self . arena . alloc ( WithCachedTypeInfo {
250245 internee : kind,
@@ -963,10 +958,9 @@ impl<'tcx> CommonTypes<'tcx> {
963958 interners : & CtxtInterners < ' tcx > ,
964959 sess : & Session ,
965960 definitions : & rustc_hir:: definitions:: Definitions ,
966- cstore : & CrateStoreDyn ,
967- source_span : & IndexVec < LocalDefId , Span > ,
961+ untracked : & Untracked ,
968962 ) -> 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 ) ;
970964
971965 CommonTypes {
972966 unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1114,6 +1108,7 @@ pub struct GlobalCtxt<'tcx> {
11141108
11151109 definitions : RwLock < Definitions > ,
11161110
1111+ untracked : Untracked ,
11171112 /// Output of the resolver.
11181113 pub ( crate ) untracked_resolutions : ty:: ResolverGlobalCtxt ,
11191114 /// The entire crate as AST. This field serves as the input for the hir_crate query,
@@ -1280,6 +1275,7 @@ impl<'tcx> TyCtxt<'tcx> {
12801275 hir_arena : & ' tcx WorkerLocal < hir:: Arena < ' tcx > > ,
12811276 definitions : Definitions ,
12821277 untracked_resolutions : ty:: ResolverGlobalCtxt ,
1278+ untracked : Untracked ,
12831279 krate : Lrc < ast:: Crate > ,
12841280 dep_graph : DepGraph ,
12851281 on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1292,14 +1288,7 @@ impl<'tcx> TyCtxt<'tcx> {
12921288 s. emit_fatal ( err) ;
12931289 } ) ;
12941290 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) ;
13031292 let common_lifetimes = CommonLifetimes :: new ( & interners) ;
13041293 let common_consts = CommonConsts :: new ( & interners, & common_types) ;
13051294
@@ -1315,6 +1304,7 @@ impl<'tcx> TyCtxt<'tcx> {
13151304 types : common_types,
13161305 lifetimes : common_lifetimes,
13171306 consts : common_consts,
1307+ untracked,
13181308 untracked_resolutions,
13191309 untracked_crate : Steal :: new ( krate) ,
13201310 on_disk_cache,
@@ -1428,7 +1418,7 @@ impl<'tcx> TyCtxt<'tcx> {
14281418 if let Some ( id) = id. as_local ( ) {
14291419 self . definitions_untracked ( ) . def_key ( id)
14301420 } else {
1431- self . untracked_resolutions . cstore . def_key ( id)
1421+ self . untracked . cstore . def_key ( id)
14321422 }
14331423 }
14341424
@@ -1442,7 +1432,7 @@ impl<'tcx> TyCtxt<'tcx> {
14421432 if let Some ( id) = id. as_local ( ) {
14431433 self . definitions_untracked ( ) . def_path ( id)
14441434 } else {
1445- self . untracked_resolutions . cstore . def_path ( id)
1435+ self . untracked . cstore . def_path ( id)
14461436 }
14471437 }
14481438
@@ -1452,7 +1442,7 @@ impl<'tcx> TyCtxt<'tcx> {
14521442 if let Some ( def_id) = def_id. as_local ( ) {
14531443 self . definitions_untracked ( ) . def_path_hash ( def_id)
14541444 } else {
1455- self . untracked_resolutions . cstore . def_path_hash ( def_id)
1445+ self . untracked . cstore . def_path_hash ( def_id)
14561446 }
14571447 }
14581448
@@ -1461,7 +1451,7 @@ impl<'tcx> TyCtxt<'tcx> {
14611451 if crate_num == LOCAL_CRATE {
14621452 self . sess . local_stable_crate_id ( )
14631453 } else {
1464- self . untracked_resolutions . cstore . stable_crate_id ( crate_num)
1454+ self . untracked . cstore . stable_crate_id ( crate_num)
14651455 }
14661456 }
14671457
@@ -1472,7 +1462,7 @@ impl<'tcx> TyCtxt<'tcx> {
14721462 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
14731463 LOCAL_CRATE
14741464 } 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)
14761466 }
14771467 }
14781468
@@ -1491,7 +1481,7 @@ impl<'tcx> TyCtxt<'tcx> {
14911481 } else {
14921482 // If this is a DefPathHash from an upstream crate, let the CrateStore map
14931483 // it to a DefId.
1494- let cstore = & * self . untracked_resolutions . cstore ;
1484+ let cstore = & * self . untracked . cstore ;
14951485 let cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ;
14961486 cstore. def_path_hash_to_def_id ( cnum, hash)
14971487 }
@@ -1505,7 +1495,7 @@ impl<'tcx> TyCtxt<'tcx> {
15051495 let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
15061496 ( self . crate_name , self . sess . local_stable_crate_id ( ) )
15071497 } else {
1508- let cstore = & * self . untracked_resolutions . cstore ;
1498+ let cstore = & * self . untracked . cstore ;
15091499 ( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
15101500 } ;
15111501
@@ -1604,7 +1594,7 @@ impl<'tcx> TyCtxt<'tcx> {
16041594 /// Note that this is *untracked* and should only be used within the query
16051595 /// system if the result is otherwise tracked through queries
16061596 pub fn cstore_untracked ( self ) -> & ' tcx CrateStoreDyn {
1607- & * self . untracked_resolutions . cstore
1597+ & * self . untracked . cstore
16081598 }
16091599
16101600 /// Note that this is *untracked* and should only be used within the query
@@ -1618,7 +1608,7 @@ impl<'tcx> TyCtxt<'tcx> {
16181608 /// system if the result is otherwise tracked through queries
16191609 #[ inline]
16201610 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 )
16221612 }
16231613
16241614 #[ inline( always) ]
@@ -1627,12 +1617,7 @@ impl<'tcx> TyCtxt<'tcx> {
16271617 f : impl FnOnce ( StableHashingContext < ' _ > ) -> R ,
16281618 ) -> R {
16291619 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 ) ;
16361621 f ( hcx)
16371622 }
16381623
@@ -2428,9 +2413,8 @@ impl<'tcx> TyCtxt<'tcx> {
24282413 st,
24292414 self . sess ,
24302415 & self . definitions . read ( ) ,
2431- & * self . untracked_resolutions . cstore ,
24322416 // This is only used to create a stable hashing context.
2433- & self . untracked_resolutions . source_span ,
2417+ & self . untracked ,
24342418 )
24352419 }
24362420
@@ -2440,9 +2424,8 @@ impl<'tcx> TyCtxt<'tcx> {
24402424 binder,
24412425 self . sess ,
24422426 & self . definitions . read ( ) ,
2443- & * self . untracked_resolutions . cstore ,
24442427 // This is only used to create a stable hashing context.
2445- & self . untracked_resolutions . source_span ,
2428+ & self . untracked ,
24462429 )
24472430 }
24482431
@@ -3124,4 +3107,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
31243107 // We want to check if the panic handler was defined in this crate
31253108 tcx. lang_items ( ) . panic_impl ( ) . map_or ( false , |did| did. is_local ( ) )
31263109 } ;
3110+ providers. source_span =
3111+ |tcx, def_id| tcx. untracked . source_span . get ( def_id) . copied ( ) . unwrap_or ( DUMMY_SP ) ;
31273112}
0 commit comments