Refactor tcx mk_const parameters.

This commit is contained in:
Mateusz 2022-11-04 20:33:32 +00:00
parent 6330c27ae2
commit c97fd8183a
No known key found for this signature in database
GPG key ID: 386CB5E415137469
21 changed files with 74 additions and 104 deletions

View file

@ -773,10 +773,10 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
self.fold_const(bound_to)
} else {
let var = self.canonical_var(info, const_var.into());
self.tcx().mk_const(ty::ConstS {
kind: ty::ConstKind::Bound(self.binder_index, var),
ty: self.fold_ty(const_var.ty()),
})
self.tcx().mk_const(
ty::ConstKind::Bound(self.binder_index, var),
self.fold_ty(const_var.ty()),
)
}
}
}

View file

@ -147,12 +147,7 @@ impl<'tcx> InferCtxt<'tcx> {
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }, ty) => {
let universe_mapped = universe_map(universe);
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, name };
self.tcx
.mk_const(ty::ConstS {
kind: ty::ConstKind::Placeholder(placeholder_mapped),
ty,
})
.into()
self.tcx.mk_const(ty::ConstKind::Placeholder(placeholder_mapped), ty).into()
}
}
}

View file

@ -741,10 +741,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
substs,
substs,
)?;
Ok(self.tcx().mk_const(ty::ConstS {
ty: c.ty(),
kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
}))
Ok(self.tcx().mk_const(
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
c.ty(),
))
}
_ => relate::super_relate_consts(self, c, c),
}
@ -955,10 +955,10 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
substs,
)?;
Ok(self.tcx().mk_const(ty::ConstS {
ty: c.ty(),
kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
}))
Ok(self.tcx().mk_const(
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
c.ty(),
))
}
_ => relate::super_relate_consts(self, c, c),
}

View file

@ -94,13 +94,13 @@ impl<'tcx> InferCtxt<'tcx> {
}))
},
consts: &mut |bound_var: ty::BoundVar, ty| {
self.tcx.mk_const(ty::ConstS {
kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
self.tcx.mk_const(
ty::ConstKind::Placeholder(ty::PlaceholderConst {
universe: next_universe,
name: bound_var,
}),
ty,
})
)
},
};

View file

@ -2065,13 +2065,13 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
if ty.has_non_region_param() || ty.has_non_region_infer() {
bug!("const `{ct}`'s type should not reference params or types");
}
tcx.mk_const(ty::ConstS {
ty,
kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
tcx.mk_const(
ty::ConstKind::Placeholder(ty::PlaceholderConst {
universe: ty::UniverseIndex::ROOT,
name: ty::BoundVar::from_usize(idx),
}),
})
ty,
)
.into()
}
_ => arg,