Skip to content

Commit 306a7ea

Browse files
committed
AliasTy::new instead of tcx method
1 parent 6d7160c commit 306a7ea

File tree

15 files changed

+46
-39
lines changed

15 files changed

+46
-39
lines changed

compiler/rustc_hir_analysis/src/astconv/bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
448448

449449
debug!(?args_trait_ref_and_assoc_item);
450450

451-
tcx.mk_alias_ty(assoc_item.def_id, args_trait_ref_and_assoc_item)
451+
ty::AliasTy::new(tcx, assoc_item.def_id, args_trait_ref_and_assoc_item)
452452
})
453453
};
454454

compiler/rustc_hir_analysis/src/astconv/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
437437
);
438438

439439
let quiet_projection_ty =
440-
tcx.mk_alias_ty(projection_ty.def_id, args_with_infer_self);
440+
ty::AliasTy::new(tcx, projection_ty.def_id, args_with_infer_self);
441441

442442
let term = pred.skip_binder().term;
443443

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
916916
// Type aliases defined in crates that have the
917917
// feature `lazy_type_alias` enabled get encoded as a type alias that normalization will
918918
// then actually instantiate the where bounds of.
919-
let alias_ty = tcx.mk_alias_ty(did, args);
919+
let alias_ty = ty::AliasTy::new(tcx, did, args);
920920
Ty::new_alias(tcx, ty::Weak, alias_ty)
921921
} else {
922922
tcx.at(span).type_of(did).instantiate(tcx, args)
@@ -1718,7 +1718,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
17181718
.chain(args.into_iter().skip(parent_args.len())),
17191719
);
17201720

1721-
let ty = Ty::new_alias(tcx, ty::Inherent, tcx.mk_alias_ty(assoc_item, args));
1721+
let ty = Ty::new_alias(tcx, ty::Inherent, ty::AliasTy::new(tcx, assoc_item, args));
17221722

17231723
return Ok(Some((ty, assoc_item)));
17241724
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2286,7 +2286,7 @@ pub(super) fn check_type_bounds<'tcx>(
22862286
_ => predicates.push(
22872287
ty::Binder::bind_with_vars(
22882288
ty::ProjectionPredicate {
2289-
projection_ty: tcx.mk_alias_ty(trait_ty.def_id, rebased_args),
2289+
projection_ty: ty::AliasTy::new(tcx, trait_ty.def_id, rebased_args),
22902290
term: normalize_impl_ty.into(),
22912291
},
22922292
bound_vars,

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
674674
);
675675

676676
let quiet_projection_ty =
677-
tcx.mk_alias_ty(projection_ty.def_id, args_with_infer_self);
677+
ty::AliasTy::new(tcx, projection_ty.def_id, args_with_infer_self);
678678

679679
let term = pred.skip_binder().term;
680680

compiler/rustc_middle/src/ty/context.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,6 @@ impl<'tcx> TyCtxt<'tcx> {
16871687
&& let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(_def_id))
16881688
{
16891689
// If this is an inherent projection.
1690-
16911690
generics.params.len() + 1
16921691
} else {
16931692
generics.count()
@@ -1897,15 +1896,6 @@ impl<'tcx> TyCtxt<'tcx> {
18971896
self.mk_args_from_iter(iter::once(self_ty.into()).chain(rest))
18981897
}
18991898

1900-
pub fn mk_alias_ty(
1901-
self,
1902-
def_id: DefId,
1903-
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
1904-
) -> ty::AliasTy<'tcx> {
1905-
let args = self.check_and_mk_args(def_id, args);
1906-
ty::AliasTy { def_id, args, _use_mk_alias_ty_instead: () }
1907-
}
1908-
19091899
pub fn mk_bound_variable_kinds_from_iter<I, T>(self, iter: I) -> T::Output
19101900
where
19111901
I: Iterator<Item = T>,

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ impl<'tcx> Term<'tcx> {
10231023
_ => None,
10241024
},
10251025
TermKind::Const(ct) => match ct.kind() {
1026-
ConstKind::Unevaluated(uv) => Some(tcx.mk_alias_ty(uv.def, uv.args)),
1026+
ConstKind::Unevaluated(uv) => Some(AliasTy::new(tcx, uv.def, uv.args)),
10271027
_ => None,
10281028
},
10291029
}

compiler/rustc_middle/src/ty/relate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl<'tcx> Relate<'tcx> for ty::AliasTy<'tcx> {
288288
}
289289
def => bug!("unknown alias DefKind: {def:?}"),
290290
};
291-
Ok(relation.tcx().mk_alias_ty(a.def_id, args))
291+
Ok(ty::AliasTy::new(relation.tcx(), a.def_id, args))
292292
}
293293
}
294294
}

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,20 @@ pub struct AliasTy<'tcx> {
12131213
pub def_id: DefId,
12141214

12151215
/// 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: (),
12181218
}
12191219

12201220
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+
12211230
pub fn kind(self, tcx: TyCtxt<'tcx>) -> ty::AliasKind {
12221231
match tcx.def_kind(self.def_id) {
12231232
DefKind::AssocTy
@@ -1245,7 +1254,7 @@ impl<'tcx> AliasTy<'tcx> {
12451254
}
12461255

12471256
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)))
12491258
}
12501259
}
12511260

@@ -1667,8 +1676,11 @@ impl<'tcx> ExistentialProjection<'tcx> {
16671676
debug_assert!(!self_ty.has_escaping_bound_vars());
16681677

16691678
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+
),
16721684
term: self.term,
16731685
}
16741686
}
@@ -1971,7 +1983,7 @@ impl<'tcx> Ty<'tcx> {
19711983

19721984
#[inline]
19731985
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))
19751987
}
19761988

19771989
/// Constructs a `TyKind::Error` type with current `ErrorGuaranteed`
@@ -2135,7 +2147,7 @@ impl<'tcx> Ty<'tcx> {
21352147
item_def_id: DefId,
21362148
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
21372149
) -> 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))
21392151
}
21402152

21412153
#[inline]

compiler/rustc_trait_selection/src/solve/normalize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
129129
self.at.cause.clone(),
130130
self.at.param_env,
131131
ty::ProjectionPredicate {
132-
projection_ty: tcx.mk_alias_ty(uv.def, uv.args),
132+
projection_ty: AliasTy::new(tcx, uv.def, uv.args),
133133
term: new_infer_ct.into(),
134134
},
135135
);

0 commit comments

Comments
 (0)