Replace mk_const
with Const::new_x
methods
This commit is contained in:
parent
cd68ead9ec
commit
ddbc774e74
32 changed files with 219 additions and 134 deletions
|
@ -497,7 +497,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
|
|||
// any equated inference vars correctly!
|
||||
let root_vid = self.infcx.root_const_var(vid);
|
||||
if root_vid != vid {
|
||||
ct = self.infcx.tcx.mk_const(ty::InferConst::Var(root_vid), ct.ty());
|
||||
ct = ty::Const::new_var(self.infcx.tcx, root_vid, ct.ty());
|
||||
vid = root_vid;
|
||||
}
|
||||
|
||||
|
@ -804,10 +804,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
|||
self.fold_const(bound_to)
|
||||
} else {
|
||||
let var = self.canonical_var(info, const_var.into());
|
||||
self.interner().mk_const(
|
||||
ty::ConstKind::Bound(self.binder_index, var),
|
||||
self.fold_ty(const_var.ty()),
|
||||
)
|
||||
ty::Const::new_bound(self.tcx, self.binder_index, var, self.fold_ty(const_var.ty()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, bound }, ty) => {
|
||||
let universe_mapped = universe_map(universe);
|
||||
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, bound };
|
||||
self.tcx.mk_const(placeholder_mapped, ty).into()
|
||||
ty::Const::new_placeholder(self.tcx, placeholder_mapped, ty).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
|
|||
Entry::Vacant(entry) => {
|
||||
let index = self.const_freshen_count;
|
||||
self.const_freshen_count += 1;
|
||||
let ct = self.infcx.tcx.mk_const(freshener(index), ty);
|
||||
let ct = ty::Const::new_infer(self.infcx.tcx, freshener(index), ty);
|
||||
entry.insert(ct);
|
||||
ct
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ where
|
|||
origin: var_value.origin,
|
||||
val: ConstVariableValue::Unknown { universe: self.for_universe },
|
||||
});
|
||||
Ok(self.tcx().mk_const(new_var_id, c.ty()))
|
||||
Ok(ty::Const::new_var(self.tcx(), new_var_id, c.ty()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +412,11 @@ where
|
|||
substs,
|
||||
substs,
|
||||
)?;
|
||||
Ok(self.tcx().mk_const(ty::UnevaluatedConst { def, substs }, c.ty()))
|
||||
Ok(ty::Const::new_unevaluated(
|
||||
self.tcx(),
|
||||
ty::UnevaluatedConst { def, substs },
|
||||
c.ty(),
|
||||
))
|
||||
}
|
||||
ty::ConstKind::Placeholder(placeholder) => {
|
||||
if self.for_universe.can_name(placeholder.universe) {
|
||||
|
|
|
@ -94,7 +94,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
})
|
||||
},
|
||||
consts: &mut |bound_var: ty::BoundVar, ty| {
|
||||
self.tcx.mk_const(
|
||||
ty::Const::new_placeholder(
|
||||
self.tcx,
|
||||
ty::PlaceholderConst { universe: next_universe, bound: bound_var },
|
||||
ty,
|
||||
)
|
||||
|
|
|
@ -999,7 +999,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}
|
||||
|
||||
pub fn next_const_var(&self, ty: Ty<'tcx>, origin: ConstVariableOrigin) -> ty::Const<'tcx> {
|
||||
self.tcx.mk_const(self.next_const_var_id(origin), ty)
|
||||
ty::Const::new_var(self.tcx, self.next_const_var_id(origin), ty)
|
||||
}
|
||||
|
||||
pub fn next_const_var_in_universe(
|
||||
|
@ -1013,7 +1013,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
.borrow_mut()
|
||||
.const_unification_table()
|
||||
.new_key(ConstVarValue { origin, val: ConstVariableValue::Unknown { universe } });
|
||||
self.tcx.mk_const(vid, ty)
|
||||
ty::Const::new_var(self.tcx, vid, ty)
|
||||
}
|
||||
|
||||
pub fn next_const_var_id(&self, origin: ConstVariableOrigin) -> ConstVid<'tcx> {
|
||||
|
@ -1131,15 +1131,15 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
origin,
|
||||
val: ConstVariableValue::Unknown { universe: self.universe() },
|
||||
});
|
||||
self.tcx
|
||||
.mk_const(
|
||||
const_var_id,
|
||||
self.tcx
|
||||
.type_of(param.def_id)
|
||||
.no_bound_vars()
|
||||
.expect("const parameter types cannot be generic"),
|
||||
)
|
||||
.into()
|
||||
ty::Const::new_var(
|
||||
self.tcx,
|
||||
const_var_id,
|
||||
self.tcx
|
||||
.type_of(param.def_id)
|
||||
.no_bound_vars()
|
||||
.expect("const parameter types cannot be generic"),
|
||||
)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1472,7 +1472,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
span: Option<Span>,
|
||||
) -> Result<ty::Const<'tcx>, ErrorHandled> {
|
||||
match self.const_eval_resolve(param_env, unevaluated, span) {
|
||||
Ok(Some(val)) => Ok(self.tcx.mk_const(val, ty)),
|
||||
Ok(Some(val)) => Ok(ty::Const::new_value(self.tcx, val, ty)),
|
||||
Ok(None) => {
|
||||
let tcx = self.tcx;
|
||||
let def_id = unevaluated.def;
|
||||
|
@ -1964,7 +1964,8 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
|
|||
if ty.has_non_region_param() || ty.has_non_region_infer() {
|
||||
bug!("const `{c}`'s type should not reference params or types");
|
||||
}
|
||||
self.tcx.mk_const(
|
||||
ty::Const::new_placeholder(
|
||||
self.tcx,
|
||||
ty::PlaceholderConst {
|
||||
universe: ty::UniverseIndex::ROOT,
|
||||
bound: ty::BoundVar::from_u32({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue