@@ -58,7 +58,7 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
5858 StableVec } ;
5959use arena:: { TypedArena , DroplessArena } ;
6060use rustc_data_structures:: indexed_vec:: IndexVec ;
61- use rustc_data_structures:: sync:: Lrc ;
61+ use rustc_data_structures:: sync:: { Lrc , Lock } ;
6262use std:: any:: Any ;
6363use std:: borrow:: Borrow ;
6464use std:: cell:: { Cell , RefCell } ;
@@ -131,28 +131,28 @@ pub struct CtxtInterners<'tcx> {
131131
132132 /// Specifically use a speedy hash algorithm for these hash sets,
133133 /// 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 > > > > ,
142142}
143143
144144impl < ' gcx : ' tcx , ' tcx > CtxtInterners < ' tcx > {
145145 fn new ( arena : & ' tcx DroplessArena ) -> CtxtInterners < ' tcx > {
146146 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 ( ) ) ,
156156 }
157157 }
158158
@@ -892,11 +892,11 @@ pub struct GlobalCtxt<'tcx> {
892892 /// by `proc-macro` crates.
893893 pub derive_macros : RefCell < NodeMap < Symbol > > ,
894894
895- stability_interner : RefCell < FxHashSet < & ' tcx attr:: Stability > > ,
895+ stability_interner : Lock < FxHashSet < & ' tcx attr:: Stability > > ,
896896
897897 pub interpret_interner : InterpretInterner < ' tcx > ,
898898
899- layout_interner : RefCell < FxHashSet < & ' tcx LayoutDetails > > ,
899+ layout_interner : Lock < FxHashSet < & ' tcx LayoutDetails > > ,
900900
901901 /// A vector of every trait accessible in the whole crate
902902 /// (i.e. including those from subcrates). This is used only for
@@ -910,15 +910,15 @@ pub struct GlobalCtxt<'tcx> {
910910 /// This is intended to only get used during the trans phase of the compiler
911911 /// when satisfying the query for a particular codegen unit. Internally in
912912 /// 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 > > > ,
914914
915915 output_filenames : Arc < OutputFilenames > ,
916916}
917917
918918/// Everything needed to efficiently work with interned allocations
919919#[ derive( Debug , Default ) ]
920920pub struct InterpretInterner < ' tcx > {
921- inner : RefCell < InterpretInternerInner < ' tcx > > ,
921+ inner : Lock < InterpretInternerInner < ' tcx > > ,
922922}
923923
924924#[ derive( Debug , Default ) ]
@@ -1278,13 +1278,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12781278 evaluation_cache : traits:: EvaluationCache :: new ( ) ,
12791279 crate_name : Symbol :: intern ( crate_name) ,
12801280 data_layout,
1281- layout_interner : RefCell :: new ( FxHashSet ( ) ) ,
1281+ layout_interner : Lock :: new ( FxHashSet ( ) ) ,
12821282 layout_depth : Cell :: new ( 0 ) ,
12831283 derive_macros : RefCell :: new ( NodeMap ( ) ) ,
1284- stability_interner : RefCell :: new ( FxHashSet ( ) ) ,
1284+ stability_interner : Lock :: new ( FxHashSet ( ) ) ,
12851285 interpret_interner : Default :: default ( ) ,
12861286 all_traits : RefCell :: new ( None ) ,
1287- tx_to_llvm_workers : tx ,
1287+ tx_to_llvm_workers : Lock :: new ( tx ) ,
12881288 output_filenames : Arc :: new ( output_filenames. clone ( ) ) ,
12891289 } ;
12901290
0 commit comments