@@ -58,7 +58,7 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
58
58
StableVec } ;
59
59
use arena:: { TypedArena , DroplessArena } ;
60
60
use rustc_data_structures:: indexed_vec:: IndexVec ;
61
- use rustc_data_structures:: sync:: Lrc ;
61
+ use rustc_data_structures:: sync:: { Lrc , Lock } ;
62
62
use std:: any:: Any ;
63
63
use std:: borrow:: Borrow ;
64
64
use std:: cell:: { Cell , RefCell } ;
@@ -131,28 +131,28 @@ pub struct CtxtInterners<'tcx> {
131
131
132
132
/// Specifically use a speedy hash algorithm for these hash sets,
133
133
/// they're accessed quite often.
134
- type_ : RefCell < FxHashSet < Interned < ' tcx , TyS < ' tcx > > > > ,
135
- type_list : RefCell < FxHashSet < Interned < ' tcx , Slice < Ty < ' tcx > > > > > ,
136
- substs : RefCell < FxHashSet < Interned < ' tcx , Substs < ' tcx > > > > ,
137
- canonical_var_infos : RefCell < FxHashSet < Interned < ' tcx , Slice < CanonicalVarInfo > > > > ,
138
- region : RefCell < FxHashSet < Interned < ' tcx , RegionKind > > > ,
139
- existential_predicates : RefCell < FxHashSet < Interned < ' tcx , Slice < ExistentialPredicate < ' tcx > > > > > ,
140
- predicates : RefCell < FxHashSet < Interned < ' tcx , Slice < Predicate < ' tcx > > > > > ,
141
- const_ : RefCell < FxHashSet < Interned < ' tcx , Const < ' tcx > > > > ,
134
+ type_ : Lock < FxHashSet < Interned < ' tcx , TyS < ' tcx > > > > ,
135
+ type_list : Lock < FxHashSet < Interned < ' tcx , Slice < Ty < ' tcx > > > > > ,
136
+ substs : Lock < FxHashSet < Interned < ' tcx , Substs < ' tcx > > > > ,
137
+ canonical_var_infos : Lock < FxHashSet < Interned < ' tcx , Slice < CanonicalVarInfo > > > > ,
138
+ region : Lock < FxHashSet < Interned < ' tcx , RegionKind > > > ,
139
+ existential_predicates : Lock < FxHashSet < Interned < ' tcx , Slice < ExistentialPredicate < ' tcx > > > > > ,
140
+ predicates : Lock < FxHashSet < Interned < ' tcx , Slice < Predicate < ' tcx > > > > > ,
141
+ const_ : Lock < FxHashSet < Interned < ' tcx , Const < ' tcx > > > > ,
142
142
}
143
143
144
144
impl < ' gcx : ' tcx , ' tcx > CtxtInterners < ' tcx > {
145
145
fn new ( arena : & ' tcx DroplessArena ) -> CtxtInterners < ' tcx > {
146
146
CtxtInterners {
147
- arena,
148
- type_ : RefCell :: new ( FxHashSet ( ) ) ,
149
- type_list : RefCell :: new ( FxHashSet ( ) ) ,
150
- substs : RefCell :: new ( FxHashSet ( ) ) ,
151
- region : RefCell :: new ( FxHashSet ( ) ) ,
152
- existential_predicates : RefCell :: new ( FxHashSet ( ) ) ,
153
- canonical_var_infos : RefCell :: new ( FxHashSet ( ) ) ,
154
- predicates : RefCell :: new ( FxHashSet ( ) ) ,
155
- const_ : RefCell :: new ( FxHashSet ( ) ) ,
147
+ arena : arena ,
148
+ type_ : Lock :: new ( FxHashSet ( ) ) ,
149
+ type_list : Lock :: new ( FxHashSet ( ) ) ,
150
+ substs : Lock :: new ( FxHashSet ( ) ) ,
151
+ canonical_var_infos : Lock :: new ( FxHashSet ( ) ) ,
152
+ region : Lock :: new ( FxHashSet ( ) ) ,
153
+ existential_predicates : Lock :: new ( FxHashSet ( ) ) ,
154
+ predicates : Lock :: new ( FxHashSet ( ) ) ,
155
+ const_ : Lock :: new ( FxHashSet ( ) ) ,
156
156
}
157
157
}
158
158
@@ -892,11 +892,11 @@ pub struct GlobalCtxt<'tcx> {
892
892
/// by `proc-macro` crates.
893
893
pub derive_macros : RefCell < NodeMap < Symbol > > ,
894
894
895
- stability_interner : RefCell < FxHashSet < & ' tcx attr:: Stability > > ,
895
+ stability_interner : Lock < FxHashSet < & ' tcx attr:: Stability > > ,
896
896
897
897
pub interpret_interner : InterpretInterner < ' tcx > ,
898
898
899
- layout_interner : RefCell < FxHashSet < & ' tcx LayoutDetails > > ,
899
+ layout_interner : Lock < FxHashSet < & ' tcx LayoutDetails > > ,
900
900
901
901
/// A vector of every trait accessible in the whole crate
902
902
/// (i.e. including those from subcrates). This is used only for
@@ -910,15 +910,15 @@ pub struct GlobalCtxt<'tcx> {
910
910
/// This is intended to only get used during the trans phase of the compiler
911
911
/// when satisfying the query for a particular codegen unit. Internally in
912
912
/// the query it'll send data along this channel to get processed later.
913
- pub tx_to_llvm_workers : mpsc:: Sender < Box < dyn Any + Send > > ,
913
+ pub tx_to_llvm_workers : Lock < mpsc:: Sender < Box < dyn Any + Send > > > ,
914
914
915
915
output_filenames : Arc < OutputFilenames > ,
916
916
}
917
917
918
918
/// Everything needed to efficiently work with interned allocations
919
919
#[ derive( Debug , Default ) ]
920
920
pub struct InterpretInterner < ' tcx > {
921
- inner : RefCell < InterpretInternerInner < ' tcx > > ,
921
+ inner : Lock < InterpretInternerInner < ' tcx > > ,
922
922
}
923
923
924
924
#[ derive( Debug , Default ) ]
@@ -1278,13 +1278,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1278
1278
evaluation_cache : traits:: EvaluationCache :: new ( ) ,
1279
1279
crate_name : Symbol :: intern ( crate_name) ,
1280
1280
data_layout,
1281
- layout_interner : RefCell :: new ( FxHashSet ( ) ) ,
1281
+ layout_interner : Lock :: new ( FxHashSet ( ) ) ,
1282
1282
layout_depth : Cell :: new ( 0 ) ,
1283
1283
derive_macros : RefCell :: new ( NodeMap ( ) ) ,
1284
- stability_interner : RefCell :: new ( FxHashSet ( ) ) ,
1284
+ stability_interner : Lock :: new ( FxHashSet ( ) ) ,
1285
1285
interpret_interner : Default :: default ( ) ,
1286
1286
all_traits : RefCell :: new ( None ) ,
1287
- tx_to_llvm_workers : tx ,
1287
+ tx_to_llvm_workers : Lock :: new ( tx ) ,
1288
1288
output_filenames : Arc :: new ( output_filenames. clone ( ) ) ,
1289
1289
} ;
1290
1290
0 commit comments