@@ -49,10 +49,9 @@ use crate::util::common::ErrorReported;
4949use crate :: util:: nodemap:: { DefIdMap , DefIdSet , ItemLocalMap , ItemLocalSet , NodeMap } ;
5050use crate :: util:: nodemap:: { FxHashMap , FxHashSet } ;
5151
52- use arena:: SyncDroplessArena ;
5352use errors:: DiagnosticBuilder ;
5453use rustc_data_structures:: profiling:: SelfProfilerRef ;
55- use rustc_data_structures:: sharded:: ShardedHashMap ;
54+ use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
5655use rustc_data_structures:: stable_hasher:: {
5756 hash_stable_hashmap, HashStable , StableHasher , StableVec ,
5857} ;
@@ -78,21 +77,11 @@ use syntax::expand::allocator::AllocatorKind;
7877use syntax:: source_map:: MultiSpan ;
7978use syntax:: symbol:: { kw, sym, Symbol } ;
8079
81- pub struct AllArenas {
82- pub interner : SyncDroplessArena ,
83- }
84-
85- impl AllArenas {
86- pub fn new ( ) -> Self {
87- AllArenas { interner : SyncDroplessArena :: default ( ) }
88- }
89- }
90-
9180type InternedSet < ' tcx , T > = ShardedHashMap < Interned < ' tcx , T > , ( ) > ;
9281
9382pub struct CtxtInterners < ' tcx > {
9483 /// The arena that types, regions, etc. are allocated from.
95- arena : & ' tcx SyncDroplessArena ,
84+ arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
9685
9786 /// Specifically use a speedy hash algorithm for these hash sets, since
9887 /// they're accessed quite often.
@@ -112,7 +101,7 @@ pub struct CtxtInterners<'tcx> {
112101}
113102
114103impl < ' tcx > CtxtInterners < ' tcx > {
115- fn new ( arena : & ' tcx SyncDroplessArena ) -> CtxtInterners < ' tcx > {
104+ fn new ( arena : & ' tcx WorkerLocal < Arena < ' tcx > > ) -> CtxtInterners < ' tcx > {
116105 CtxtInterners {
117106 arena,
118107 type_ : Default :: default ( ) ,
@@ -1115,7 +1104,6 @@ impl<'tcx> TyCtxt<'tcx> {
11151104 lint_store : Lrc < lint:: LintStore > ,
11161105 local_providers : ty:: query:: Providers < ' tcx > ,
11171106 extern_providers : ty:: query:: Providers < ' tcx > ,
1118- arenas : & ' tcx AllArenas ,
11191107 arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
11201108 resolutions : ty:: ResolverOutputs ,
11211109 hir : hir_map:: Map < ' tcx > ,
@@ -1126,7 +1114,7 @@ impl<'tcx> TyCtxt<'tcx> {
11261114 let data_layout = TargetDataLayout :: parse ( & s. target . target ) . unwrap_or_else ( |err| {
11271115 s. fatal ( & err) ;
11281116 } ) ;
1129- let interners = CtxtInterners :: new ( & arenas . interner ) ;
1117+ let interners = CtxtInterners :: new ( arena ) ;
11301118 let common_types = CommonTypes :: new ( & interners) ;
11311119 let common_lifetimes = CommonLifetimes :: new ( & interners) ;
11321120 let common_consts = CommonConsts :: new ( & interners, & common_types) ;
@@ -1557,11 +1545,11 @@ pub trait Lift<'tcx>: fmt::Debug {
15571545}
15581546
15591547macro_rules! nop_lift {
1560- ( $ty: ty => $lifted: ty) => {
1548+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
15611549 impl <' a, ' tcx> Lift <' tcx> for $ty {
15621550 type Lifted = $lifted;
15631551 fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1564- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1552+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
15651553 Some ( unsafe { mem:: transmute( * self ) } )
15661554 } else {
15671555 None
@@ -1572,14 +1560,14 @@ macro_rules! nop_lift {
15721560}
15731561
15741562macro_rules! nop_list_lift {
1575- ( $ty: ty => $lifted: ty) => {
1563+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
15761564 impl <' a, ' tcx> Lift <' tcx> for & ' a List <$ty> {
15771565 type Lifted = & ' tcx List <$lifted>;
15781566 fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
15791567 if self . is_empty( ) {
15801568 return Some ( List :: empty( ) ) ;
15811569 }
1582- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1570+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
15831571 Some ( unsafe { mem:: transmute( * self ) } )
15841572 } else {
15851573 None
@@ -1589,21 +1577,21 @@ macro_rules! nop_list_lift {
15891577 } ;
15901578}
15911579
1592- nop_lift ! { Ty <' a> => Ty <' tcx>}
1593- nop_lift ! { Region <' a> => Region <' tcx>}
1594- nop_lift ! { Goal <' a> => Goal <' tcx>}
1595- nop_lift ! { & ' a Const <' a> => & ' tcx Const <' tcx>}
1580+ nop_lift ! { type_ ; Ty <' a> => Ty <' tcx>}
1581+ nop_lift ! { region ; Region <' a> => Region <' tcx>}
1582+ nop_lift ! { goal ; Goal <' a> => Goal <' tcx>}
1583+ nop_lift ! { const_ ; & ' a Const <' a> => & ' tcx Const <' tcx>}
15961584
1597- nop_list_lift ! { Goal <' a> => Goal <' tcx>}
1598- nop_list_lift ! { Clause <' a> => Clause <' tcx>}
1599- nop_list_lift ! { Ty <' a> => Ty <' tcx>}
1600- nop_list_lift ! { ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1601- nop_list_lift ! { Predicate <' a> => Predicate <' tcx>}
1602- nop_list_lift ! { CanonicalVarInfo => CanonicalVarInfo }
1603- nop_list_lift ! { ProjectionKind => ProjectionKind }
1585+ nop_list_lift ! { goal_list ; Goal <' a> => Goal <' tcx>}
1586+ nop_list_lift ! { clauses ; Clause <' a> => Clause <' tcx>}
1587+ nop_list_lift ! { type_list ; Ty <' a> => Ty <' tcx>}
1588+ nop_list_lift ! { existential_predicates ; ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1589+ nop_list_lift ! { predicates ; Predicate <' a> => Predicate <' tcx>}
1590+ nop_list_lift ! { canonical_var_infos ; CanonicalVarInfo => CanonicalVarInfo }
1591+ nop_list_lift ! { projs ; ProjectionKind => ProjectionKind }
16041592
16051593// This is the impl for `&'a InternalSubsts<'a>`.
1606- nop_list_lift ! { GenericArg <' a> => GenericArg <' tcx>}
1594+ nop_list_lift ! { substs ; GenericArg <' a> => GenericArg <' tcx>}
16071595
16081596pub mod tls {
16091597 use super :: { ptr_eq, GlobalCtxt , TyCtxt } ;
@@ -1927,6 +1915,11 @@ impl<'tcx, T: 'tcx + ?Sized> Clone for Interned<'tcx, T> {
19271915}
19281916impl < ' tcx , T : ' tcx + ?Sized > Copy for Interned < ' tcx , T > { }
19291917
1918+ unsafe impl < ' tcx , T : ' tcx + ?Sized > IntoPointer for Interned < ' tcx , T > {
1919+ fn into_pointer ( & self ) -> * const ( ) {
1920+ self . 0 as * const _ as * const ( )
1921+ }
1922+ }
19301923// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
19311924impl < ' tcx > PartialEq for Interned < ' tcx , TyS < ' tcx > > {
19321925 fn eq ( & self , other : & Interned < ' tcx , TyS < ' tcx > > ) -> bool {
@@ -2079,7 +2072,7 @@ macro_rules! slice_interners {
20792072 $( impl <' tcx> TyCtxt <' tcx> {
20802073 pub fn $method( self , v: & [ $ty] ) -> & ' tcx List <$ty> {
20812074 self . interners. $field. intern_ref( v, || {
2082- Interned ( List :: from_arena( & self . interners . arena, v) )
2075+ Interned ( List :: from_arena( & * self . arena, v) )
20832076 } ) . 0
20842077 }
20852078 } ) +
0 commit comments