@@ -6,7 +6,7 @@ pub mod tls;
6
6
7
7
use crate :: arena:: Arena ;
8
8
use crate :: dep_graph:: { DepGraph , DepKindStruct } ;
9
- use crate :: infer:: canonical:: { CanonicalVarInfo , CanonicalVarInfos } ;
9
+ use crate :: infer:: canonical:: CanonicalVarInfo ;
10
10
use crate :: lint:: struct_lint_level;
11
11
use crate :: middle:: codegen_fn_attrs:: CodegenFnAttrs ;
12
12
use crate :: middle:: resolve_bound_vars;
@@ -1565,24 +1565,28 @@ macro_rules! slice_interners {
1565
1565
( $( $field: ident: $method: ident( $ty: ty) ) ,+ $( , ) ?) => (
1566
1566
impl <' tcx> TyCtxt <' tcx> {
1567
1567
$( pub fn $method( self , v: & [ $ty] ) -> & ' tcx List <$ty> {
1568
- self . interners. $field. intern_ref( v, || {
1569
- InternedInSet ( List :: from_arena( & * self . arena, v) )
1570
- } ) . 0
1568
+ if v. is_empty( ) {
1569
+ List :: empty( )
1570
+ } else {
1571
+ self . interners. $field. intern_ref( v, || {
1572
+ InternedInSet ( List :: from_arena( & * self . arena, v) )
1573
+ } ) . 0
1574
+ }
1571
1575
} ) +
1572
1576
}
1573
1577
) ;
1574
1578
}
1575
1579
1576
1580
slice_interners ! (
1577
- const_lists: _intern_const_list ( Const <' tcx>) ,
1578
- substs: _intern_substs ( GenericArg <' tcx>) ,
1579
- canonical_var_infos: _intern_canonical_var_infos ( CanonicalVarInfo <' tcx>) ,
1581
+ const_lists: intern_const_list ( Const <' tcx>) ,
1582
+ substs: intern_substs ( GenericArg <' tcx>) ,
1583
+ canonical_var_infos: intern_canonical_var_infos ( CanonicalVarInfo <' tcx>) ,
1580
1584
poly_existential_predicates:
1581
1585
_intern_poly_existential_predicates( PolyExistentialPredicate <' tcx>) ,
1582
1586
predicates: _intern_predicates( Predicate <' tcx>) ,
1583
- projs: _intern_projs ( ProjectionKind ) ,
1584
- place_elems: _intern_place_elems ( PlaceElem <' tcx>) ,
1585
- bound_variable_kinds: _intern_bound_variable_kinds ( ty:: BoundVariableKind ) ,
1587
+ projs: intern_projs ( ProjectionKind ) ,
1588
+ place_elems: intern_place_elems ( PlaceElem <' tcx>) ,
1589
+ bound_variable_kinds: intern_bound_variable_kinds ( ty:: BoundVariableKind ) ,
1586
1590
) ;
1587
1591
1588
1592
impl < ' tcx > TyCtxt < ' tcx > {
@@ -2152,12 +2156,7 @@ impl<'tcx> TyCtxt<'tcx> {
2152
2156
// FIXME consider asking the input slice to be sorted to avoid
2153
2157
// re-interning permutations, in which case that would be asserted
2154
2158
// here.
2155
- if preds. is_empty ( ) {
2156
- // The macro-generated method below asserts we don't intern an empty slice.
2157
- List :: empty ( )
2158
- } else {
2159
- self . _intern_predicates ( preds)
2160
- }
2159
+ self . _intern_predicates ( preds)
2161
2160
}
2162
2161
2163
2162
pub fn mk_const_list < I , T > ( self , iter : I ) -> T :: Output
@@ -2168,50 +2167,16 @@ impl<'tcx> TyCtxt<'tcx> {
2168
2167
T :: collect_and_apply ( iter, |xs| self . intern_const_list ( xs) )
2169
2168
}
2170
2169
2171
- pub fn intern_const_list ( self , cs : & [ ty:: Const < ' tcx > ] ) -> & ' tcx List < ty:: Const < ' tcx > > {
2172
- if cs. is_empty ( ) { List :: empty ( ) } else { self . _intern_const_list ( cs) }
2173
- }
2174
-
2175
2170
pub fn intern_type_list ( self , ts : & [ Ty < ' tcx > ] ) -> & ' tcx List < Ty < ' tcx > > {
2176
- if ts. is_empty ( ) {
2177
- List :: empty ( )
2178
- } else {
2179
- // Actually intern type lists as lists of `GenericArg`s.
2180
- //
2181
- // Transmuting from `Ty<'tcx>` to `GenericArg<'tcx>` is sound
2182
- // as explained in ty_slice_as_generic_arg`. With this,
2183
- // we guarantee that even when transmuting between `List<Ty<'tcx>>`
2184
- // and `List<GenericArg<'tcx>>`, the uniqueness requirement for
2185
- // lists is upheld.
2186
- let substs = self . _intern_substs ( ty:: subst:: ty_slice_as_generic_args ( ts) ) ;
2187
- substs. try_as_type_list ( ) . unwrap ( )
2188
- }
2189
- }
2190
-
2191
- pub fn intern_substs ( self , ts : & [ GenericArg < ' tcx > ] ) -> & ' tcx List < GenericArg < ' tcx > > {
2192
- if ts. is_empty ( ) { List :: empty ( ) } else { self . _intern_substs ( ts) }
2193
- }
2194
-
2195
- pub fn intern_projs ( self , ps : & [ ProjectionKind ] ) -> & ' tcx List < ProjectionKind > {
2196
- if ps. is_empty ( ) { List :: empty ( ) } else { self . _intern_projs ( ps) }
2197
- }
2198
-
2199
- pub fn intern_place_elems ( self , ts : & [ PlaceElem < ' tcx > ] ) -> & ' tcx List < PlaceElem < ' tcx > > {
2200
- if ts. is_empty ( ) { List :: empty ( ) } else { self . _intern_place_elems ( ts) }
2201
- }
2202
-
2203
- pub fn intern_canonical_var_infos (
2204
- self ,
2205
- ts : & [ CanonicalVarInfo < ' tcx > ] ,
2206
- ) -> CanonicalVarInfos < ' tcx > {
2207
- if ts. is_empty ( ) { List :: empty ( ) } else { self . _intern_canonical_var_infos ( ts) }
2208
- }
2209
-
2210
- pub fn intern_bound_variable_kinds (
2211
- self ,
2212
- ts : & [ ty:: BoundVariableKind ] ,
2213
- ) -> & ' tcx List < ty:: BoundVariableKind > {
2214
- if ts. is_empty ( ) { List :: empty ( ) } else { self . _intern_bound_variable_kinds ( ts) }
2171
+ // Actually intern type lists as lists of `GenericArg`s.
2172
+ //
2173
+ // Transmuting from `Ty<'tcx>` to `GenericArg<'tcx>` is sound
2174
+ // as explained in ty_slice_as_generic_arg`. With this,
2175
+ // we guarantee that even when transmuting between `List<Ty<'tcx>>`
2176
+ // and `List<GenericArg<'tcx>>`, the uniqueness requirement for
2177
+ // lists is upheld.
2178
+ let substs = self . intern_substs ( ty:: subst:: ty_slice_as_generic_args ( ts) ) ;
2179
+ substs. try_as_type_list ( ) . unwrap ( )
2215
2180
}
2216
2181
2217
2182
// Unlike various other `mk_*` functions, this one uses `I: IntoIterator`
0 commit comments