@@ -1213,11 +1213,20 @@ pub struct AliasTy<'tcx> {
1213
1213
pub def_id : DefId ,
1214
1214
1215
1215
/// This field exists to prevent the creation of `AliasTy` without using
1216
- /// [TyCtxt::mk_alias_ty ].
1217
- pub ( super ) _use_mk_alias_ty_instead : ( ) ,
1216
+ /// [AliasTy::new ].
1217
+ _use_alias_ty_new_instead : ( ) ,
1218
1218
}
1219
1219
1220
1220
impl < ' tcx > AliasTy < ' tcx > {
1221
+ pub fn new (
1222
+ tcx : TyCtxt < ' tcx > ,
1223
+ def_id : DefId ,
1224
+ args : impl IntoIterator < Item : Into < GenericArg < ' tcx > > > ,
1225
+ ) -> ty:: AliasTy < ' tcx > {
1226
+ let args = tcx. check_and_mk_args ( def_id, args) ;
1227
+ ty:: AliasTy { def_id, args, _use_alias_ty_new_instead : ( ) }
1228
+ }
1229
+
1221
1230
pub fn kind ( self , tcx : TyCtxt < ' tcx > ) -> ty:: AliasKind {
1222
1231
match tcx. def_kind ( self . def_id ) {
1223
1232
DefKind :: AssocTy
@@ -1245,7 +1254,7 @@ impl<'tcx> AliasTy<'tcx> {
1245
1254
}
1246
1255
1247
1256
pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> Self {
1248
- tcx . mk_alias_ty ( self . def_id , [ self_ty. into ( ) ] . into_iter ( ) . chain ( self . args . iter ( ) . skip ( 1 ) ) )
1257
+ AliasTy :: new ( tcx , self . def_id , [ self_ty. into ( ) ] . into_iter ( ) . chain ( self . args . iter ( ) . skip ( 1 ) ) )
1249
1258
}
1250
1259
}
1251
1260
@@ -1667,8 +1676,11 @@ impl<'tcx> ExistentialProjection<'tcx> {
1667
1676
debug_assert ! ( !self_ty. has_escaping_bound_vars( ) ) ;
1668
1677
1669
1678
ty:: ProjectionPredicate {
1670
- projection_ty : tcx
1671
- . mk_alias_ty ( self . def_id , [ self_ty. into ( ) ] . into_iter ( ) . chain ( self . args ) ) ,
1679
+ projection_ty : AliasTy :: new (
1680
+ tcx,
1681
+ self . def_id ,
1682
+ [ self_ty. into ( ) ] . into_iter ( ) . chain ( self . args ) ,
1683
+ ) ,
1672
1684
term : self . term ,
1673
1685
}
1674
1686
}
@@ -1971,7 +1983,7 @@ impl<'tcx> Ty<'tcx> {
1971
1983
1972
1984
#[ inline]
1973
1985
pub fn new_opaque ( tcx : TyCtxt < ' tcx > , def_id : DefId , args : GenericArgsRef < ' tcx > ) -> Ty < ' tcx > {
1974
- Ty :: new_alias ( tcx, ty:: Opaque , tcx . mk_alias_ty ( def_id, args) )
1986
+ Ty :: new_alias ( tcx, ty:: Opaque , AliasTy :: new ( tcx , def_id, args) )
1975
1987
}
1976
1988
1977
1989
/// Constructs a `TyKind::Error` type with current `ErrorGuaranteed`
@@ -2135,7 +2147,7 @@ impl<'tcx> Ty<'tcx> {
2135
2147
item_def_id : DefId ,
2136
2148
args : impl IntoIterator < Item : Into < GenericArg < ' tcx > > > ,
2137
2149
) -> Ty < ' tcx > {
2138
- Ty :: new_alias ( tcx, ty:: Projection , tcx . mk_alias_ty ( item_def_id, args) )
2150
+ Ty :: new_alias ( tcx, ty:: Projection , AliasTy :: new ( tcx , item_def_id, args) )
2139
2151
}
2140
2152
2141
2153
#[ inline]
0 commit comments