@@ -2189,90 +2189,65 @@ impl<'tcx> Borrow<[Goal<'tcx>]> for Interned<'tcx, List<Goal<'tcx>>> {
21892189 }
21902190}
21912191
2192- macro_rules! intern_method {
2193- ( $lt_tcx: tt, $name: ident: $method: ident( $alloc: ty,
2194- $alloc_method: expr,
2195- $alloc_to_key: expr) -> $ty: ty) => {
2196- impl <$lt_tcx> TyCtxt <$lt_tcx> {
2197- pub fn $method( self , v: $alloc) -> & $lt_tcx $ty {
2198- let key = ( $alloc_to_key) ( & v) ;
2199-
2200- self . interners. $name. intern_ref( key, || {
2201- Interned ( $alloc_method( & self . interners. arena, v) )
2202-
2203- } ) . 0
2204- }
2205- }
2206- }
2207- }
2208-
22092192macro_rules! direct_interners {
2210- ( $lt_tcx : tt , $ ( $name: ident: $method: ident( $ty: ty) ) ,+) => {
2211- $( impl <$lt_tcx > PartialEq for Interned <$lt_tcx , $ty> {
2193+ ( $( $name: ident: $method: ident( $ty: ty) ) ,+) => {
2194+ $( impl <' tcx > PartialEq for Interned <' tcx , $ty> {
22122195 fn eq( & self , other: & Self ) -> bool {
22132196 self . 0 == other. 0
22142197 }
22152198 }
22162199
2217- impl <$lt_tcx > Eq for Interned <$lt_tcx , $ty> { }
2200+ impl <' tcx > Eq for Interned <' tcx , $ty> { }
22182201
2219- impl <$lt_tcx > Hash for Interned <$lt_tcx , $ty> {
2202+ impl <' tcx > Hash for Interned <' tcx , $ty> {
22202203 fn hash<H : Hasher >( & self , s: & mut H ) {
22212204 self . 0 . hash( s)
22222205 }
22232206 }
22242207
2225- intern_method!(
2226- $lt_tcx,
2227- $name: $method( $ty,
2228- |a: & $lt_tcx SyncDroplessArena , v| -> & $lt_tcx $ty { a. alloc( v) } ,
2229- |x| x) -> $ty) ; ) +
2208+ impl <' tcx> TyCtxt <' tcx> {
2209+ pub fn $method( self , v: $ty) -> & ' tcx $ty {
2210+ self . interners. $name. intern_ref( & v, || {
2211+ Interned ( self . interners. arena. alloc( v) )
2212+ } ) . 0
2213+ }
2214+ } ) +
22302215 }
22312216}
22322217
22332218pub fn keep_local < ' tcx , T : ty:: TypeFoldable < ' tcx > > ( x : & T ) -> bool {
22342219 x. has_type_flags ( ty:: TypeFlags :: KEEP_IN_LOCAL_TCX )
22352220}
22362221
2237- direct_interners ! ( ' tcx ,
2222+ direct_interners ! (
22382223 region: mk_region( RegionKind ) ,
22392224 goal: mk_goal( GoalKind <' tcx>) ,
22402225 const_: mk_const( Const <' tcx>)
22412226) ;
22422227
22432228macro_rules! slice_interners {
22442229 ( $( $field: ident: $method: ident( $ty: ty) ) ,+) => (
2245- $( intern_method!( ' tcx, $field: $method(
2246- & [ $ty] ,
2247- |a, v| List :: from_arena( a, v) ,
2248- Deref :: deref) -> List <$ty>) ; ) +
2230+ $( impl <' tcx> TyCtxt <' tcx> {
2231+ pub fn $method( self , v: & [ $ty] ) -> & ' tcx List <$ty> {
2232+ self . interners. $field. intern_ref( v, || {
2233+ Interned ( List :: from_arena( & self . interners. arena, v) )
2234+ } ) . 0
2235+ }
2236+ } ) +
22492237 ) ;
22502238}
22512239
22522240slice_interners ! (
2253- existential_predicates: _intern_existential_predicates( ExistentialPredicate <' tcx>) ,
2254- predicates: _intern_predicates( Predicate <' tcx>) ,
22552241 type_list: _intern_type_list( Ty <' tcx>) ,
22562242 substs: _intern_substs( GenericArg <' tcx>) ,
2243+ canonical_var_infos: _intern_canonical_var_infos( CanonicalVarInfo ) ,
2244+ existential_predicates: _intern_existential_predicates( ExistentialPredicate <' tcx>) ,
2245+ predicates: _intern_predicates( Predicate <' tcx>) ,
22572246 clauses: _intern_clauses( Clause <' tcx>) ,
22582247 goal_list: _intern_goals( Goal <' tcx>) ,
22592248 projs: _intern_projs( ProjectionKind )
22602249) ;
22612250
2262- // This isn't a perfect fit: `CanonicalVarInfo` slices are always
2263- // allocated in the global arena, so this `intern_method!` macro is
2264- // overly general. However, we just return `false` for the code that checks
2265- // whether they belong in the thread-local arena, so no harm done, and
2266- // seems better than open-coding the rest.
2267- intern_method ! {
2268- ' tcx,
2269- canonical_var_infos: _intern_canonical_var_infos(
2270- & [ CanonicalVarInfo ] ,
2271- |a, v| List :: from_arena( a, v) ,
2272- Deref :: deref
2273- ) -> List <CanonicalVarInfo >
2274- }
2275-
22762251impl < ' tcx > TyCtxt < ' tcx > {
22772252 /// Given a `fn` type, returns an equivalent `unsafe fn` type;
22782253 /// that is, a `fn` type that is equivalent in every way for being
0 commit comments