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