@@ -2189,90 +2189,65 @@ impl<'tcx> Borrow<[Goal<'tcx>]> for Interned<'tcx, List<Goal<'tcx>>> {
2189
2189
}
2190
2190
}
2191
2191
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
-
2209
2192
macro_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> {
2212
2195
fn eq( & self , other: & Self ) -> bool {
2213
2196
self . 0 == other. 0
2214
2197
}
2215
2198
}
2216
2199
2217
- impl <$lt_tcx > Eq for Interned <$lt_tcx , $ty> { }
2200
+ impl <' tcx > Eq for Interned <' tcx , $ty> { }
2218
2201
2219
- impl <$lt_tcx > Hash for Interned <$lt_tcx , $ty> {
2202
+ impl <' tcx > Hash for Interned <' tcx , $ty> {
2220
2203
fn hash<H : Hasher >( & self , s: & mut H ) {
2221
2204
self . 0 . hash( s)
2222
2205
}
2223
2206
}
2224
2207
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
+ } ) +
2230
2215
}
2231
2216
}
2232
2217
2233
2218
pub fn keep_local < ' tcx , T : ty:: TypeFoldable < ' tcx > > ( x : & T ) -> bool {
2234
2219
x. has_type_flags ( ty:: TypeFlags :: KEEP_IN_LOCAL_TCX )
2235
2220
}
2236
2221
2237
- direct_interners ! ( ' tcx ,
2222
+ direct_interners ! (
2238
2223
region: mk_region( RegionKind ) ,
2239
2224
goal: mk_goal( GoalKind <' tcx>) ,
2240
2225
const_: mk_const( Const <' tcx>)
2241
2226
) ;
2242
2227
2243
2228
macro_rules! slice_interners {
2244
2229
( $( $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
+ } ) +
2249
2237
) ;
2250
2238
}
2251
2239
2252
2240
slice_interners ! (
2253
- existential_predicates: _intern_existential_predicates( ExistentialPredicate <' tcx>) ,
2254
- predicates: _intern_predicates( Predicate <' tcx>) ,
2255
2241
type_list: _intern_type_list( Ty <' tcx>) ,
2256
2242
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>) ,
2257
2246
clauses: _intern_clauses( Clause <' tcx>) ,
2258
2247
goal_list: _intern_goals( Goal <' tcx>) ,
2259
2248
projs: _intern_projs( ProjectionKind )
2260
2249
) ;
2261
2250
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
-
2276
2251
impl < ' tcx > TyCtxt < ' tcx > {
2277
2252
/// Given a `fn` type, returns an equivalent `unsafe fn` type;
2278
2253
/// that is, a `fn` type that is equivalent in every way for being
0 commit comments