1
Fork 0

Reduce direct mk_ty usage.

We use more specific `mk_*` functions in most places, might as well use
them as much as possible.
This commit is contained in:
Nicholas Nethercote 2023-02-08 12:28:03 +11:00
parent 6248bbbf26
commit 7a72560154
25 changed files with 92 additions and 82 deletions

View file

@ -1250,7 +1250,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
//
// Calling `skip_binder` is okay, because `add_bounds` expects the `param_ty`
// parameter to have a skipped binder.
let param_ty = tcx.mk_ty(ty::Alias(ty::Projection, projection_ty.skip_binder()));
let param_ty = tcx.mk_alias(ty::Projection, projection_ty.skip_binder());
self.add_bounds(param_ty, ast_bounds.iter(), bounds, candidate.bound_vars());
}
}
@ -2930,7 +2930,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
};
tcx.mk_ty(ty::Array(self.ast_ty_to_ty(ty), length))
tcx.mk_array_with_const_len(self.ast_ty_to_ty(ty), length)
}
hir::TyKind::Typeof(e) => {
let ty_erased = tcx.type_of(e.def_id);

View file

@ -1927,10 +1927,10 @@ pub(super) fn check_type_bounds<'tcx>(
let kind = ty::BoundTyKind::Param(param.def_id, param.name);
let bound_var = ty::BoundVariableKind::Ty(kind);
bound_vars.push(bound_var);
tcx.mk_ty(ty::Bound(
tcx.mk_bound(
ty::INNERMOST,
ty::BoundTy { var: ty::BoundVar::from_usize(bound_vars.len() - 1), kind },
))
)
.into()
}
GenericParamDefKind::Lifetime => {

View file

@ -603,8 +603,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>(
// our example, the type was `Self`, which will also be
// `Self` in the GAT.
let ty_param = gat_generics.param_at(*ty_idx, tcx);
let ty_param = tcx
.mk_ty(ty::Param(ty::ParamTy { index: ty_param.index, name: ty_param.name }));
let ty_param = tcx.mk_ty_param(ty_param.index, ty_param.name);
// Same for the region. In our example, 'a corresponds
// to the 'me parameter.
let region_param = gat_generics.param_at(*region_a_idx, tcx);