@@ -35,7 +35,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
35
35
use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
36
36
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
37
37
use 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 } ;
39
39
use rustc_data_structures:: unord:: UnordSet ;
40
40
use rustc_data_structures:: vec_map:: VecMap ;
41
41
use rustc_errors:: {
@@ -182,18 +182,12 @@ impl<'tcx> CtxtInterners<'tcx> {
182
182
/// Interns a type.
183
183
#[ allow( rustc:: usage_of_ty_tykind) ]
184
184
#[ 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 > {
192
186
Ty ( Interned :: new_unchecked (
193
187
self . type_
194
188
. intern ( kind, |kind| {
195
189
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) ;
197
191
198
192
InternedInSet ( self . arena . alloc ( WithCachedTypeInfo {
199
193
internee : kind,
@@ -210,7 +204,6 @@ impl<'tcx> CtxtInterners<'tcx> {
210
204
& self ,
211
205
flags : & ty:: flags:: FlagComputation ,
212
206
sess : & ' a Session ,
213
- definitions : & ' a rustc_hir:: definitions:: Definitions ,
214
207
untracked : & ' a Untracked ,
215
208
val : & T ,
216
209
) -> Fingerprint {
@@ -220,7 +213,7 @@ impl<'tcx> CtxtInterners<'tcx> {
220
213
Fingerprint :: ZERO
221
214
} else {
222
215
let mut hasher = StableHasher :: new ( ) ;
223
- let mut hcx = StableHashingContext :: new ( sess, definitions , untracked) ;
216
+ let mut hcx = StableHashingContext :: new ( sess, untracked) ;
224
217
val. hash_stable ( & mut hcx, & mut hasher) ;
225
218
hasher. finish ( )
226
219
}
@@ -231,15 +224,14 @@ impl<'tcx> CtxtInterners<'tcx> {
231
224
& self ,
232
225
kind : Binder < ' tcx , PredicateKind < ' tcx > > ,
233
226
sess : & Session ,
234
- definitions : & rustc_hir:: definitions:: Definitions ,
235
227
untracked : & Untracked ,
236
228
) -> Predicate < ' tcx > {
237
229
Predicate ( Interned :: new_unchecked (
238
230
self . predicate
239
231
. intern ( kind, |kind| {
240
232
let flags = super :: flags:: FlagComputation :: for_predicate ( kind) ;
241
233
242
- let stable_hash = self . stable_hash ( & flags, sess, definitions , untracked, & kind) ;
234
+ let stable_hash = self . stable_hash ( & flags, sess, untracked, & kind) ;
243
235
244
236
InternedInSet ( self . arena . alloc ( WithCachedTypeInfo {
245
237
internee : kind,
@@ -957,10 +949,9 @@ impl<'tcx> CommonTypes<'tcx> {
957
949
fn new (
958
950
interners : & CtxtInterners < ' tcx > ,
959
951
sess : & Session ,
960
- definitions : & rustc_hir:: definitions:: Definitions ,
961
952
untracked : & Untracked ,
962
953
) -> CommonTypes < ' tcx > {
963
- let mk = |ty| interners. intern_ty ( ty, sess, definitions , untracked) ;
954
+ let mk = |ty| interners. intern_ty ( ty, sess, untracked) ;
964
955
965
956
CommonTypes {
966
957
unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1106,8 +1097,6 @@ pub struct GlobalCtxt<'tcx> {
1106
1097
/// Common consts, pre-interned for your convenience.
1107
1098
pub consts : CommonConsts < ' tcx > ,
1108
1099
1109
- definitions : RwLock < Definitions > ,
1110
-
1111
1100
untracked : Untracked ,
1112
1101
/// Output of the resolver.
1113
1102
pub ( crate ) untracked_resolutions : ty:: ResolverGlobalCtxt ,
@@ -1273,7 +1262,6 @@ impl<'tcx> TyCtxt<'tcx> {
1273
1262
lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
1274
1263
arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1275
1264
hir_arena : & ' tcx WorkerLocal < hir:: Arena < ' tcx > > ,
1276
- definitions : Definitions ,
1277
1265
untracked_resolutions : ty:: ResolverGlobalCtxt ,
1278
1266
untracked : Untracked ,
1279
1267
krate : Lrc < ast:: Crate > ,
@@ -1288,7 +1276,7 @@ impl<'tcx> TyCtxt<'tcx> {
1288
1276
s. emit_fatal ( err) ;
1289
1277
} ) ;
1290
1278
let interners = CtxtInterners :: new ( arena) ;
1291
- let common_types = CommonTypes :: new ( & interners, s, & definitions , & untracked) ;
1279
+ let common_types = CommonTypes :: new ( & interners, s, & untracked) ;
1292
1280
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1293
1281
let common_consts = CommonConsts :: new ( & interners, & common_types) ;
1294
1282
@@ -1299,7 +1287,6 @@ impl<'tcx> TyCtxt<'tcx> {
1299
1287
hir_arena,
1300
1288
interners,
1301
1289
dep_graph,
1302
- definitions : RwLock :: new ( definitions) ,
1303
1290
prof : s. prof . clone ( ) ,
1304
1291
types : common_types,
1305
1292
lifetimes : common_lifetimes,
@@ -1477,7 +1464,7 @@ impl<'tcx> TyCtxt<'tcx> {
1477
1464
// If this is a DefPathHash from the local crate, we can look up the
1478
1465
// DefId in the tcx's `Definitions`.
1479
1466
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 ( )
1481
1468
} else {
1482
1469
// If this is a DefPathHash from an upstream crate, let the CrateStore map
1483
1470
// it to a DefId.
@@ -1537,7 +1524,7 @@ impl<'tcx> TyCtxtAt<'tcx> {
1537
1524
// This is fine because:
1538
1525
// - those queries are `eval_always` so we won't miss their result changing;
1539
1526
// - 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) ;
1541
1528
1542
1529
let feed = TyCtxtFeed { tcx : self . tcx , key } ;
1543
1530
feed. def_span ( self . span ) ;
@@ -1551,7 +1538,7 @@ impl<'tcx> TyCtxt<'tcx> {
1551
1538
// definitions change.
1552
1539
self . dep_graph . read_index ( DepNodeIndex :: FOREVER_RED_NODE ) ;
1553
1540
1554
- let definitions = & self . definitions ;
1541
+ let definitions = & self . untracked . definitions ;
1555
1542
std:: iter:: from_generator ( || {
1556
1543
let mut i = 0 ;
1557
1544
@@ -1575,7 +1562,7 @@ impl<'tcx> TyCtxt<'tcx> {
1575
1562
1576
1563
// Leak a read lock once we start iterating on definitions, to prevent adding new ones
1577
1564
// 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 ( ) ;
1579
1566
definitions. def_path_table ( )
1580
1567
}
1581
1568
@@ -1587,7 +1574,7 @@ impl<'tcx> TyCtxt<'tcx> {
1587
1574
self . ensure ( ) . hir_crate ( ( ) ) ;
1588
1575
// Leak a read lock once we start iterating on definitions, to prevent adding new ones
1589
1576
// 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 ( ) ;
1591
1578
definitions. def_path_hash_to_def_index_map ( )
1592
1579
}
1593
1580
@@ -1601,7 +1588,7 @@ impl<'tcx> TyCtxt<'tcx> {
1601
1588
/// system if the result is otherwise tracked through queries
1602
1589
#[ inline]
1603
1590
pub fn definitions_untracked ( self ) -> ReadGuard < ' tcx , Definitions > {
1604
- self . definitions . read ( )
1591
+ self . untracked . definitions . read ( )
1605
1592
}
1606
1593
1607
1594
/// Note that this is *untracked* and should only be used within the query
@@ -1616,9 +1603,7 @@ impl<'tcx> TyCtxt<'tcx> {
1616
1603
self ,
1617
1604
f : impl FnOnce ( StableHashingContext < ' _ > ) -> R ,
1618
1605
) -> 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 ) )
1622
1607
}
1623
1608
1624
1609
pub fn serialize_query_result_cache ( self , encoder : FileEncoder ) -> FileEncodeResult {
@@ -2412,7 +2397,6 @@ impl<'tcx> TyCtxt<'tcx> {
2412
2397
self . interners . intern_ty (
2413
2398
st,
2414
2399
self . sess ,
2415
- & self . definitions . read ( ) ,
2416
2400
// This is only used to create a stable hashing context.
2417
2401
& self . untracked ,
2418
2402
)
@@ -2423,7 +2407,6 @@ impl<'tcx> TyCtxt<'tcx> {
2423
2407
self . interners . intern_predicate (
2424
2408
binder,
2425
2409
self . sess ,
2426
- & self . definitions . read ( ) ,
2427
2410
// This is only used to create a stable hashing context.
2428
2411
& self . untracked ,
2429
2412
)
0 commit comments