@@ -102,6 +102,7 @@ pub struct CtxtInterners<'tcx> {
102
102
// Specifically use a speedy hash algorithm for these hash sets, since
103
103
// they're accessed quite often.
104
104
type_ : InternedSet < ' tcx , TyS < ' tcx > > ,
105
+ type_list : InternedSet < ' tcx , List < Ty < ' tcx > > > ,
105
106
substs : InternedSet < ' tcx , InternalSubsts < ' tcx > > ,
106
107
canonical_var_infos : InternedSet < ' tcx , List < CanonicalVarInfo < ' tcx > > > ,
107
108
region : InternedSet < ' tcx , RegionKind > ,
@@ -123,6 +124,7 @@ impl<'tcx> CtxtInterners<'tcx> {
123
124
CtxtInterners {
124
125
arena,
125
126
type_ : Default :: default ( ) ,
127
+ type_list : Default :: default ( ) ,
126
128
substs : Default :: default ( ) ,
127
129
region : Default :: default ( ) ,
128
130
poly_existential_predicates : Default :: default ( ) ,
@@ -1670,25 +1672,6 @@ macro_rules! nop_lift {
1670
1672
} ;
1671
1673
}
1672
1674
1673
- // Can't use the macros as we have reuse the `substs` here.
1674
- //
1675
- // See `intern_type_list` for more info.
1676
- impl < ' a , ' tcx > Lift < ' tcx > for & ' a List < Ty < ' a > > {
1677
- type Lifted = & ' tcx List < Ty < ' tcx > > ;
1678
- fn lift_to_tcx ( self , tcx : TyCtxt < ' tcx > ) -> Option < Self :: Lifted > {
1679
- if self . is_empty ( ) {
1680
- return Some ( List :: empty ( ) ) ;
1681
- }
1682
- if tcx. interners . substs . contains_pointer_to ( & InternedInSet ( self . as_substs ( ) ) ) {
1683
- // SAFETY: `self` is interned and therefore valid
1684
- // for the entire lifetime of the `TyCtxt`.
1685
- Some ( unsafe { mem:: transmute :: < & ' a List < Ty < ' a > > , & ' tcx List < Ty < ' tcx > > > ( self ) } )
1686
- } else {
1687
- None
1688
- }
1689
- }
1690
- }
1691
-
1692
1675
macro_rules! nop_list_lift {
1693
1676
( $set: ident; $ty: ty => $lifted: ty) => {
1694
1677
impl <' a, ' tcx> Lift <' tcx> for & ' a List <$ty> {
@@ -1713,6 +1696,7 @@ nop_lift! {const_; Const<'a> => Const<'tcx>}
1713
1696
nop_lift ! { const_allocation; ConstAllocation <' a> => ConstAllocation <' tcx>}
1714
1697
nop_lift ! { predicate; Predicate <' a> => Predicate <' tcx>}
1715
1698
1699
+ nop_list_lift ! { type_list; Ty <' a> => Ty <' tcx>}
1716
1700
nop_list_lift ! { poly_existential_predicates; ty:: Binder <' a, ExistentialPredicate <' a>> => ty:: Binder <' tcx, ExistentialPredicate <' tcx>>}
1717
1701
nop_list_lift ! { predicates; Predicate <' a> => Predicate <' tcx>}
1718
1702
nop_list_lift ! { canonical_var_infos; CanonicalVarInfo <' a> => CanonicalVarInfo <' tcx>}
@@ -2203,6 +2187,7 @@ macro_rules! slice_interners {
2203
2187
}
2204
2188
2205
2189
slice_interners ! (
2190
+ type_list: _intern_type_list( Ty <' tcx>) ,
2206
2191
substs: _intern_substs( GenericArg <' tcx>) ,
2207
2192
canonical_var_infos: _intern_canonical_var_infos( CanonicalVarInfo <' tcx>) ,
2208
2193
poly_existential_predicates:
@@ -2620,19 +2605,7 @@ impl<'tcx> TyCtxt<'tcx> {
2620
2605
}
2621
2606
2622
2607
pub fn intern_type_list ( self , ts : & [ Ty < ' tcx > ] ) -> & ' tcx List < Ty < ' tcx > > {
2623
- if ts. is_empty ( ) {
2624
- List :: empty ( )
2625
- } else {
2626
- // Actually intern type lists as lists of `GenericArg`s.
2627
- //
2628
- // Transmuting from `Ty<'tcx>` to `GenericArg<'tcx>` is sound
2629
- // as explained in ty_slice_as_generic_arg`. With this,
2630
- // we guarantee that even when transmuting between `List<Ty<'tcx>>`
2631
- // and `List<GenericArg<'tcx>>`, the uniqueness requirement for
2632
- // lists is upheld.
2633
- let substs = self . _intern_substs ( ty:: subst:: ty_slice_as_generic_args ( ts) ) ;
2634
- substs. try_as_type_list ( ) . unwrap ( )
2635
- }
2608
+ if ts. is_empty ( ) { List :: empty ( ) } else { self . _intern_type_list ( ts) }
2636
2609
}
2637
2610
2638
2611
pub fn intern_substs ( self , ts : & [ GenericArg < ' tcx > ] ) -> & ' tcx List < GenericArg < ' tcx > > {
0 commit comments