@@ -35,7 +35,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
3535use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
3636use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
3737use rustc_data_structures:: steal:: Steal ;
38- use rustc_data_structures:: sync:: { self , Lock , Lrc , ReadGuard , RwLock , WorkerLocal } ;
38+ use rustc_data_structures:: sync:: { self , Lock , Lrc , ReadGuard , WorkerLocal } ;
3939use rustc_data_structures:: unord:: UnordSet ;
4040use rustc_data_structures:: vec_map:: VecMap ;
4141use rustc_errors:: {
@@ -182,18 +182,12 @@ impl<'tcx> CtxtInterners<'tcx> {
182182 /// Interns a type.
183183 #[ allow( rustc:: usage_of_ty_tykind) ]
184184 #[ inline( never) ]
185- fn intern_ty (
186- & self ,
187- kind : TyKind < ' tcx > ,
188- sess : & Session ,
189- definitions : & rustc_hir:: definitions:: Definitions ,
190- untracked : & Untracked ,
191- ) -> Ty < ' tcx > {
185+ fn intern_ty ( & self , kind : TyKind < ' tcx > , sess : & Session , untracked : & Untracked ) -> Ty < ' tcx > {
192186 Ty ( Interned :: new_unchecked (
193187 self . type_
194188 . intern ( kind, |kind| {
195189 let flags = super :: flags:: FlagComputation :: for_kind ( & kind) ;
196- let stable_hash = self . stable_hash ( & flags, sess, definitions , untracked, & kind) ;
190+ let stable_hash = self . stable_hash ( & flags, sess, untracked, & kind) ;
197191
198192 InternedInSet ( self . arena . alloc ( WithCachedTypeInfo {
199193 internee : kind,
@@ -210,7 +204,6 @@ impl<'tcx> CtxtInterners<'tcx> {
210204 & self ,
211205 flags : & ty:: flags:: FlagComputation ,
212206 sess : & ' a Session ,
213- definitions : & ' a rustc_hir:: definitions:: Definitions ,
214207 untracked : & ' a Untracked ,
215208 val : & T ,
216209 ) -> Fingerprint {
@@ -220,7 +213,7 @@ impl<'tcx> CtxtInterners<'tcx> {
220213 Fingerprint :: ZERO
221214 } else {
222215 let mut hasher = StableHasher :: new ( ) ;
223- let mut hcx = StableHashingContext :: new ( sess, definitions , untracked) ;
216+ let mut hcx = StableHashingContext :: new ( sess, untracked) ;
224217 val. hash_stable ( & mut hcx, & mut hasher) ;
225218 hasher. finish ( )
226219 }
@@ -231,15 +224,14 @@ impl<'tcx> CtxtInterners<'tcx> {
231224 & self ,
232225 kind : Binder < ' tcx , PredicateKind < ' tcx > > ,
233226 sess : & Session ,
234- definitions : & rustc_hir:: definitions:: Definitions ,
235227 untracked : & Untracked ,
236228 ) -> Predicate < ' tcx > {
237229 Predicate ( Interned :: new_unchecked (
238230 self . predicate
239231 . intern ( kind, |kind| {
240232 let flags = super :: flags:: FlagComputation :: for_predicate ( kind) ;
241233
242- let stable_hash = self . stable_hash ( & flags, sess, definitions , untracked, & kind) ;
234+ let stable_hash = self . stable_hash ( & flags, sess, untracked, & kind) ;
243235
244236 InternedInSet ( self . arena . alloc ( WithCachedTypeInfo {
245237 internee : kind,
@@ -957,10 +949,9 @@ impl<'tcx> CommonTypes<'tcx> {
957949 fn new (
958950 interners : & CtxtInterners < ' tcx > ,
959951 sess : & Session ,
960- definitions : & rustc_hir:: definitions:: Definitions ,
961952 untracked : & Untracked ,
962953 ) -> CommonTypes < ' tcx > {
963- let mk = |ty| interners. intern_ty ( ty, sess, definitions , untracked) ;
954+ let mk = |ty| interners. intern_ty ( ty, sess, untracked) ;
964955
965956 CommonTypes {
966957 unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1106,8 +1097,6 @@ pub struct GlobalCtxt<'tcx> {
11061097 /// Common consts, pre-interned for your convenience.
11071098 pub consts : CommonConsts < ' tcx > ,
11081099
1109- definitions : RwLock < Definitions > ,
1110-
11111100 untracked : Untracked ,
11121101 /// Output of the resolver.
11131102 pub ( crate ) untracked_resolutions : ty:: ResolverGlobalCtxt ,
@@ -1273,7 +1262,6 @@ impl<'tcx> TyCtxt<'tcx> {
12731262 lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
12741263 arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
12751264 hir_arena : & ' tcx WorkerLocal < hir:: Arena < ' tcx > > ,
1276- definitions : Definitions ,
12771265 untracked_resolutions : ty:: ResolverGlobalCtxt ,
12781266 untracked : Untracked ,
12791267 krate : Lrc < ast:: Crate > ,
@@ -1288,7 +1276,7 @@ impl<'tcx> TyCtxt<'tcx> {
12881276 s. emit_fatal ( err) ;
12891277 } ) ;
12901278 let interners = CtxtInterners :: new ( arena) ;
1291- let common_types = CommonTypes :: new ( & interners, s, & definitions , & untracked) ;
1279+ let common_types = CommonTypes :: new ( & interners, s, & untracked) ;
12921280 let common_lifetimes = CommonLifetimes :: new ( & interners) ;
12931281 let common_consts = CommonConsts :: new ( & interners, & common_types) ;
12941282
@@ -1299,7 +1287,6 @@ impl<'tcx> TyCtxt<'tcx> {
12991287 hir_arena,
13001288 interners,
13011289 dep_graph,
1302- definitions : RwLock :: new ( definitions) ,
13031290 prof : s. prof . clone ( ) ,
13041291 types : common_types,
13051292 lifetimes : common_lifetimes,
@@ -1477,7 +1464,7 @@ impl<'tcx> TyCtxt<'tcx> {
14771464 // If this is a DefPathHash from the local crate, we can look up the
14781465 // DefId in the tcx's `Definitions`.
14791466 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1480- self . definitions . read ( ) . local_def_path_hash_to_def_id ( hash, err) . to_def_id ( )
1467+ self . untracked . definitions . read ( ) . local_def_path_hash_to_def_id ( hash, err) . to_def_id ( )
14811468 } else {
14821469 // If this is a DefPathHash from an upstream crate, let the CrateStore map
14831470 // it to a DefId.
@@ -1537,7 +1524,7 @@ impl<'tcx> TyCtxtAt<'tcx> {
15371524 // This is fine because:
15381525 // - those queries are `eval_always` so we won't miss their result changing;
15391526 // - this write will have happened before these queries are called.
1540- let key = self . definitions . write ( ) . create_def ( parent, data) ;
1527+ let key = self . untracked . definitions . write ( ) . create_def ( parent, data) ;
15411528
15421529 let feed = TyCtxtFeed { tcx : self . tcx , key } ;
15431530 feed. def_span ( self . span ) ;
@@ -1551,7 +1538,7 @@ impl<'tcx> TyCtxt<'tcx> {
15511538 // definitions change.
15521539 self . dep_graph . read_index ( DepNodeIndex :: FOREVER_RED_NODE ) ;
15531540
1554- let definitions = & self . definitions ;
1541+ let definitions = & self . untracked . definitions ;
15551542 std:: iter:: from_generator ( || {
15561543 let mut i = 0 ;
15571544
@@ -1575,7 +1562,7 @@ impl<'tcx> TyCtxt<'tcx> {
15751562
15761563 // Leak a read lock once we start iterating on definitions, to prevent adding new ones
15771564 // while iterating. If some query needs to add definitions, it should be `ensure`d above.
1578- let definitions = self . definitions . leak ( ) ;
1565+ let definitions = self . untracked . definitions . leak ( ) ;
15791566 definitions. def_path_table ( )
15801567 }
15811568
@@ -1587,7 +1574,7 @@ impl<'tcx> TyCtxt<'tcx> {
15871574 self . ensure ( ) . hir_crate ( ( ) ) ;
15881575 // Leak a read lock once we start iterating on definitions, to prevent adding new ones
15891576 // while iterating. If some query needs to add definitions, it should be `ensure`d above.
1590- let definitions = self . definitions . leak ( ) ;
1577+ let definitions = self . untracked . definitions . leak ( ) ;
15911578 definitions. def_path_hash_to_def_index_map ( )
15921579 }
15931580
@@ -1601,7 +1588,7 @@ impl<'tcx> TyCtxt<'tcx> {
16011588 /// system if the result is otherwise tracked through queries
16021589 #[ inline]
16031590 pub fn definitions_untracked ( self ) -> ReadGuard < ' tcx , Definitions > {
1604- self . definitions . read ( )
1591+ self . untracked . definitions . read ( )
16051592 }
16061593
16071594 /// Note that this is *untracked* and should only be used within the query
@@ -1616,9 +1603,7 @@ impl<'tcx> TyCtxt<'tcx> {
16161603 self ,
16171604 f : impl FnOnce ( StableHashingContext < ' _ > ) -> R ,
16181605 ) -> R {
1619- let definitions = self . definitions_untracked ( ) ;
1620- let hcx = StableHashingContext :: new ( self . sess , & * definitions, & self . untracked ) ;
1621- f ( hcx)
1606+ f ( StableHashingContext :: new ( self . sess , & self . untracked ) )
16221607 }
16231608
16241609 pub fn serialize_query_result_cache ( self , encoder : FileEncoder ) -> FileEncodeResult {
@@ -2412,7 +2397,6 @@ impl<'tcx> TyCtxt<'tcx> {
24122397 self . interners . intern_ty (
24132398 st,
24142399 self . sess ,
2415- & self . definitions . read ( ) ,
24162400 // This is only used to create a stable hashing context.
24172401 & self . untracked ,
24182402 )
@@ -2423,7 +2407,6 @@ impl<'tcx> TyCtxt<'tcx> {
24232407 self . interners . intern_predicate (
24242408 binder,
24252409 self . sess ,
2426- & self . definitions . read ( ) ,
24272410 // This is only used to create a stable hashing context.
24282411 & self . untracked ,
24292412 )
0 commit comments