Replace mk_const with Const::new_x methods

This commit is contained in:
Boxy 2023-07-04 14:26:19 +01:00
parent cd68ead9ec
commit ddbc774e74
32 changed files with 219 additions and 134 deletions

View file

@ -377,7 +377,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
// any equated inference vars correctly!
let root_vid = self.infcx.root_const_var(vid);
if root_vid != vid {
c = self.infcx.tcx.mk_const(ty::InferConst::Var(root_vid), c.ty());
c = ty::Const::new_var(self.infcx.tcx, root_vid, c.ty());
vid = root_vid;
}
@ -426,6 +426,6 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
var
}),
);
self.interner().mk_const(ty::ConstKind::Bound(self.binder_index, var), c.ty())
ty::Const::new_bound(self.infcx.tcx, self.binder_index, var, c.ty())
}
}

View file

@ -96,7 +96,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
let recursion_limit = tcx.recursion_limit();
if !recursion_limit.value_within_limit(self.depth) {
self.at.infcx.err_ctxt().report_overflow_error(
&tcx.mk_const(uv, ty),
&ty::Const::new_unevaluated(tcx, uv, ty),
self.at.cause.span,
true,
|_| {},
@ -131,7 +131,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
let ct = infcx.resolve_vars_if_possible(new_infer_ct);
ct.try_fold_with(self)?
} else {
tcx.mk_const(uv, ty).try_super_fold_with(self)?
ty::Const::new_unevaluated(tcx, uv, ty).try_super_fold_with(self)?
};
self.depth -= 1;

View file

@ -794,7 +794,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
unevaluated,
Some(obligation.cause.span),
) {
Ok(Some(valtree)) => Ok(selcx.tcx().mk_const(valtree, c.ty())),
Ok(Some(valtree)) => Ok(ty::Const::new_value(selcx.tcx(),valtree, c.ty())),
Ok(None) => {
let tcx = self.tcx;
let reported =

View file

@ -1612,16 +1612,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.tcx
.mk_projection(data.projection_ty.def_id, data.projection_ty.substs)
.into(),
ty::TermKind::Const(ct) => self
.tcx
.mk_const(
ty::UnevaluatedConst {
def: data.projection_ty.def_id,
substs: data.projection_ty.substs,
},
ct.ty(),
)
.into(),
ty::TermKind::Const(ct) => ty::Const::new_unevaluated(
self.tcx,
ty::UnevaluatedConst {
def: data.projection_ty.def_id,
substs: data.projection_ty.substs,
},
ct.ty(),
)
.into(),
};
let normalized_term =
ocx.normalize(&obligation.cause, obligation.param_env, unnormalized_term);

View file

@ -924,7 +924,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
let universe = self.universe_for(debruijn);
let p = ty::PlaceholderConst { universe, bound: bound_const };
self.mapped_consts.insert(p, bound_const);
self.infcx.tcx.mk_const(p, ct.ty())
ty::Const::new_placeholder(self.infcx.tcx, p, ct.ty())
}
_ => ct.super_fold_with(self),
}
@ -1059,7 +1059,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
let db = ty::DebruijnIndex::from_usize(
self.universe_indices.len() - index + self.current_index.as_usize() - 1,
);
self.interner().mk_const(ty::ConstKind::Bound(db, *replace_var), ct.ty())
ty::Const::new_bound(self.infcx.tcx, db, *replace_var, ct.ty())
}
None => ct,
}
@ -1500,16 +1500,16 @@ fn project<'cx, 'tcx>(
DefKind::AssocTy | DefKind::ImplTraitPlaceholder => tcx
.mk_projection(obligation.predicate.def_id, obligation.predicate.substs)
.into(),
DefKind::AssocConst => tcx
.mk_const(
ty::ConstKind::Unevaluated(ty::UnevaluatedConst::new(
obligation.predicate.def_id,
obligation.predicate.substs,
)),
tcx.type_of(obligation.predicate.def_id)
.subst(tcx, obligation.predicate.substs),
)
.into(),
DefKind::AssocConst => ty::Const::new_unevaluated(
tcx,
ty::UnevaluatedConst::new(
obligation.predicate.def_id,
obligation.predicate.substs,
),
tcx.type_of(obligation.predicate.def_id)
.subst(tcx, obligation.predicate.substs),
)
.into(),
kind => {
bug!("unknown projection def-id: {}", kind.descr(obligation.predicate.def_id))
}
@ -2397,8 +2397,8 @@ fn confirm_impl_candidate<'cx, 'tcx>(
let term: ty::EarlyBinder<ty::Term<'tcx>> = if is_const {
let did = assoc_ty.item.def_id;
let identity_substs = crate::traits::InternalSubsts::identity_for_item(tcx, did);
let kind = ty::ConstKind::Unevaluated(ty::UnevaluatedConst::new(did, identity_substs));
ty.map_bound(|ty| tcx.mk_const(kind, ty).into())
let uv = ty::UnevaluatedConst::new(did, identity_substs);
ty.map_bound(|ty| ty::Const::new_unevaluated(tcx, uv, ty).into())
} else {
ty.map_bound(|ty| ty.into())
};

View file

@ -613,11 +613,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
GenericParamDefKind::Const { .. } => {
let bound_var = ty::BoundVariableKind::Const;
bound_vars.push(bound_var);
tcx.mk_const(
ty::ConstKind::Bound(
ty::INNERMOST,
ty::BoundVar::from_usize(bound_vars.len() - 1),
),
ty::Const::new_bound(
tcx,
ty::INNERMOST,
ty::BoundVar::from_usize(bound_vars.len() - 1),
tcx.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic"),