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:
parent
6248bbbf26
commit
7a72560154
25 changed files with 92 additions and 82 deletions
|
@ -588,10 +588,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
_id: chalk_ir::OpaqueTyId<RustInterner<'tcx>>,
|
||||
) -> chalk_ir::Ty<RustInterner<'tcx>> {
|
||||
// FIXME(chalk): actually get hidden ty
|
||||
self.interner
|
||||
.tcx
|
||||
.mk_ty(ty::Tuple(self.interner.tcx.intern_type_list(&[])))
|
||||
.lower_into(self.interner)
|
||||
self.interner.tcx.types.unit.lower_into(self.interner)
|
||||
}
|
||||
|
||||
fn closure_kind(
|
||||
|
@ -721,13 +718,13 @@ impl<'tcx> chalk_ir::UnificationDatabase<RustInterner<'tcx>> for RustIrDatabase<
|
|||
fn bound_vars_for_item(tcx: TyCtxt<'_>, def_id: DefId) -> SubstsRef<'_> {
|
||||
InternalSubsts::for_item(tcx, def_id, |param, substs| match param.kind {
|
||||
ty::GenericParamDefKind::Type { .. } => tcx
|
||||
.mk_ty(ty::Bound(
|
||||
.mk_bound(
|
||||
ty::INNERMOST,
|
||||
ty::BoundTy {
|
||||
var: ty::BoundVar::from(param.index),
|
||||
kind: ty::BoundTyKind::Param(param.def_id, param.name),
|
||||
},
|
||||
))
|
||||
)
|
||||
.into(),
|
||||
|
||||
ty::GenericParamDefKind::Lifetime => {
|
||||
|
@ -790,10 +787,9 @@ impl<'tcx> ty::TypeFolder<'tcx> for ReplaceOpaqueTyFolder<'tcx> {
|
|||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) = *ty.kind() {
|
||||
if def_id == self.opaque_ty_id.0 && substs == self.identity_substs {
|
||||
return self.tcx.mk_ty(ty::Bound(
|
||||
self.binder_index,
|
||||
ty::BoundTy::from(ty::BoundVar::from_u32(0)),
|
||||
));
|
||||
return self
|
||||
.tcx
|
||||
.mk_bound(self.binder_index, ty::BoundTy::from(ty::BoundVar::from_u32(0)));
|
||||
}
|
||||
}
|
||||
ty
|
||||
|
|
|
@ -677,11 +677,11 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
|
|||
// shifted in by one so that they are still escaping.
|
||||
let predicates = ty::fold::shift_vars(interner.tcx, self, 1);
|
||||
|
||||
let self_ty = interner.tcx.mk_ty(ty::Bound(
|
||||
let self_ty = interner.tcx.mk_bound(
|
||||
// This is going to be wrapped in a binder
|
||||
ty::DebruijnIndex::from_usize(1),
|
||||
ty::BoundTy { var: ty::BoundVar::from_usize(0), kind: ty::BoundTyKind::Anon(0) },
|
||||
));
|
||||
);
|
||||
let where_clauses = predicates.into_iter().map(|predicate| {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, predicate);
|
||||
|
@ -1077,18 +1077,18 @@ impl<'tcx> TypeFolder<'tcx> for ParamsSubstitutor<'tcx> {
|
|||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match *t.kind() {
|
||||
ty::Param(param) => match self.list.iter().position(|r| r == ¶m) {
|
||||
Some(idx) => self.tcx.mk_ty(ty::Placeholder(ty::PlaceholderType {
|
||||
Some(idx) => self.tcx.mk_placeholder(ty::PlaceholderType {
|
||||
universe: ty::UniverseIndex::from_usize(0),
|
||||
name: ty::BoundTyKind::Anon(idx as u32),
|
||||
})),
|
||||
}),
|
||||
None => {
|
||||
self.list.push(param);
|
||||
let idx = self.list.len() - 1 + self.next_ty_placeholder;
|
||||
self.params.insert(idx as u32, param);
|
||||
self.tcx.mk_ty(ty::Placeholder(ty::PlaceholderType {
|
||||
self.tcx.mk_placeholder(ty::PlaceholderType {
|
||||
universe: ty::UniverseIndex::from_usize(0),
|
||||
name: ty::BoundTyKind::Anon(idx as u32),
|
||||
}))
|
||||
})
|
||||
}
|
||||
},
|
||||
_ => t.super_fold_with(self),
|
||||
|
@ -1147,7 +1147,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseParamsSubstitutor<'tcx> {
|
|||
match *t.kind() {
|
||||
ty::Placeholder(ty::PlaceholderType { universe: ty::UniverseIndex::ROOT, name }) => {
|
||||
match self.params.get(&name.expect_anon()) {
|
||||
Some(param) => self.tcx.mk_ty(ty::Param(*param)),
|
||||
Some(&ty::ParamTy { index, name }) => self.tcx.mk_ty_param(index, name),
|
||||
None => t,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue