Rollup merge of #97935 - nnethercote:rename-ConstS-val-as-kind, r=lcnr
Rename the `ConstS::val` field as `kind`. And likewise for the `Const::val` method. Because its type is called `ConstKind`. Also `val` is a confusing name because `ConstKind` is an enum with seven variants, one of which is called `Value`. Also, this gives consistency with `TyS` and `PredicateS` which have `kind` fields. The commit also renames a few `Const` variables from `val` to `c`, to avoid confusion with the `ConstKind::Value` variant. r? `@BoxyUwU`
This commit is contained in:
commit
9e5c5c57e9
74 changed files with 173 additions and 169 deletions
|
@ -209,7 +209,7 @@ fn check_opaque_type_parameter_valid(
|
|||
GenericArgKind::Lifetime(lt) => {
|
||||
matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
|
||||
}
|
||||
GenericArgKind::Const(ct) => matches!(ct.val(), ty::ConstKind::Param(_)),
|
||||
GenericArgKind::Const(ct) => matches!(ct.kind(), ty::ConstKind::Param(_)),
|
||||
};
|
||||
|
||||
if arg_is_param {
|
||||
|
@ -452,7 +452,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
|
|||
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||
trace!("checking const {:?}", ct);
|
||||
// Find a const parameter
|
||||
match ct.val() {
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Param(..) => {
|
||||
// Look it up in the substitution list.
|
||||
match self.map.get(&ct.into()).map(|k| k.unpack()) {
|
||||
|
|
|
@ -828,7 +828,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
}
|
||||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||
let evaluate = |c: ty::Const<'tcx>| {
|
||||
if let ty::ConstKind::Unevaluated(unevaluated) = c.val() {
|
||||
if let ty::ConstKind::Unevaluated(unevaluated) = c.kind() {
|
||||
match select.infcx().const_eval_resolve(
|
||||
obligation.param_env,
|
||||
unevaluated,
|
||||
|
|
|
@ -245,7 +245,7 @@ impl<'tcx> AbstractConst<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
ct: ty::Const<'tcx>,
|
||||
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
|
||||
match ct.val() {
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv.shrink()),
|
||||
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => Err(reported),
|
||||
_ => Ok(None),
|
||||
|
@ -414,7 +414,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||
|
||||
for n in self.nodes.iter() {
|
||||
if let Node::Leaf(ct) = n {
|
||||
if let ty::ConstKind::Unevaluated(ct) = ct.val() {
|
||||
if let ty::ConstKind::Unevaluated(ct) = ct.kind() {
|
||||
// `AbstractConst`s should not contain any promoteds as they require references which
|
||||
// are not allowed.
|
||||
assert_eq!(ct.promoted, None);
|
||||
|
@ -457,7 +457,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||
let uneval = ty::Unevaluated::new(ty::WithOptConstParam::unknown(def_id), substs);
|
||||
|
||||
let constant = self.tcx.mk_const(ty::ConstS {
|
||||
val: ty::ConstKind::Unevaluated(uneval),
|
||||
kind: ty::ConstKind::Unevaluated(uneval),
|
||||
ty: node.ty,
|
||||
});
|
||||
|
||||
|
@ -466,7 +466,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||
|
||||
ExprKind::ConstParam {param, ..} => {
|
||||
let const_param = self.tcx.mk_const(ty::ConstS {
|
||||
val: ty::ConstKind::Param(*param),
|
||||
kind: ty::ConstKind::Param(*param),
|
||||
ty: node.ty,
|
||||
});
|
||||
self.nodes.push(Node::Leaf(const_param))
|
||||
|
@ -748,7 +748,7 @@ impl<'tcx> ConstUnifyCtxt<'tcx> {
|
|||
return false;
|
||||
}
|
||||
|
||||
match (a_ct.val(), b_ct.val()) {
|
||||
match (a_ct.kind(), b_ct.kind()) {
|
||||
// We can just unify errors with everything to reduce the amount of
|
||||
// emitted errors here.
|
||||
(ty::ConstKind::Error(_), _) | (_, ty::ConstKind::Error(_)) => true,
|
||||
|
|
|
@ -234,7 +234,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// Arrays give us `[]`, `[{ty}; _]` and `[{ty}; N]`
|
||||
if let ty::Array(aty, len) = self_ty.kind() {
|
||||
flags.push((sym::_Self, Some("[]".to_string())));
|
||||
let len = len.val().try_to_value().and_then(|v| v.try_to_machine_usize(self.tcx));
|
||||
let len = len.kind().try_to_value().and_then(|v| v.try_to_machine_usize(self.tcx));
|
||||
flags.push((sym::_Self, Some(format!("[{}; _]", aty))));
|
||||
if let Some(n) = len {
|
||||
flags.push((sym::_Self, Some(format!("[{}; {}]", aty, n))));
|
||||
|
|
|
@ -578,7 +578,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
|||
//
|
||||
// Let's just see where this breaks :shrug:
|
||||
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
|
||||
(c1.val(), c2.val())
|
||||
(c1.kind(), c2.kind())
|
||||
{
|
||||
if infcx.try_unify_abstract_consts(
|
||||
a.shrink(),
|
||||
|
@ -593,7 +593,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
|||
let stalled_on = &mut pending_obligation.stalled_on;
|
||||
|
||||
let mut evaluate = |c: Const<'tcx>| {
|
||||
if let ty::ConstKind::Unevaluated(unevaluated) = c.val() {
|
||||
if let ty::ConstKind::Unevaluated(unevaluated) = c.kind() {
|
||||
match self.selcx.infcx().const_eval_resolve(
|
||||
obligation.param_env,
|
||||
unevaluated,
|
||||
|
|
|
@ -742,7 +742,7 @@ impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||
match ct.val() {
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Bound(debruijn, _)
|
||||
if debruijn.as_usize() + 1
|
||||
> self.current_index.as_usize() + self.universe_indices.len() =>
|
||||
|
@ -758,7 +758,7 @@ impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
|
|||
self.mapped_consts.insert(p, bound_const);
|
||||
self.infcx
|
||||
.tcx
|
||||
.mk_const(ty::ConstS { val: ty::ConstKind::Placeholder(p), ty: ct.ty() })
|
||||
.mk_const(ty::ConstS { kind: ty::ConstKind::Placeholder(p), ty: ct.ty() })
|
||||
}
|
||||
_ if ct.has_vars_bound_at_or_above(self.current_index) => ct.super_fold_with(self),
|
||||
_ => ct,
|
||||
|
@ -878,7 +878,7 @@ impl<'tcx> TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||
if let ty::ConstKind::Placeholder(p) = ct.val() {
|
||||
if let ty::ConstKind::Placeholder(p) = ct.kind() {
|
||||
let replace_var = self.mapped_consts.get(&p);
|
||||
match replace_var {
|
||||
Some(replace_var) => {
|
||||
|
@ -891,7 +891,7 @@ impl<'tcx> TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> {
|
|||
self.universe_indices.len() - index + self.current_index.as_usize() - 1,
|
||||
);
|
||||
self.tcx().mk_const(ty::ConstS {
|
||||
val: ty::ConstKind::Bound(db, *replace_var),
|
||||
kind: ty::ConstKind::Bound(db, *replace_var),
|
||||
ty: ct.ty(),
|
||||
})
|
||||
}
|
||||
|
@ -2018,8 +2018,8 @@ fn confirm_impl_candidate<'cx, 'tcx>(
|
|||
let identity_substs =
|
||||
crate::traits::InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
|
||||
let did = ty::WithOptConstParam::unknown(assoc_ty.item.def_id);
|
||||
let val = ty::ConstKind::Unevaluated(ty::Unevaluated::new(did, identity_substs));
|
||||
tcx.mk_const(ty::ConstS { ty, val }).into()
|
||||
let kind = ty::ConstKind::Unevaluated(ty::Unevaluated::new(did, identity_substs));
|
||||
tcx.mk_const(ty::ConstS { ty, kind }).into()
|
||||
} else {
|
||||
ty.into()
|
||||
};
|
||||
|
|
|
@ -141,7 +141,7 @@ impl<'tcx> TypeVisitor<'tcx> for MaxEscapingBoundVarVisitor {
|
|||
}
|
||||
|
||||
fn visit_const(&mut self, ct: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match ct.val() {
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Bound(debruijn, _) if debruijn >= self.outer_index => {
|
||||
self.escaping =
|
||||
self.escaping.max(debruijn.as_usize() - self.outer_index.as_usize());
|
||||
|
@ -337,7 +337,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
|||
Ok(match constant {
|
||||
mir::ConstantKind::Ty(c) => {
|
||||
let const_folded = c.try_fold_with(self)?;
|
||||
match const_folded.val() {
|
||||
match const_folded.kind() {
|
||||
ty::ConstKind::Value(cv) => {
|
||||
// FIXME With Valtrees we need to convert `cv: ValTree`
|
||||
// to a `ConstValue` here.
|
||||
|
|
|
@ -542,7 +542,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
bound_vars.push(bound_var);
|
||||
tcx.mk_const(ty::ConstS {
|
||||
ty: tcx.type_of(param.def_id),
|
||||
val: ty::ConstKind::Bound(
|
||||
kind: ty::ConstKind::Bound(
|
||||
ty::INNERMOST,
|
||||
ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
),
|
||||
|
@ -989,7 +989,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// Lifetimes aren't allowed to change during unsizing.
|
||||
GenericArgKind::Lifetime(_) => None,
|
||||
|
||||
GenericArgKind::Const(ct) => match ct.val() {
|
||||
GenericArgKind::Const(ct) => match ct.kind() {
|
||||
ty::ConstKind::Param(p) => Some(p.index),
|
||||
_ => None,
|
||||
},
|
||||
|
|
|
@ -622,7 +622,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
//
|
||||
// Let's just see where this breaks :shrug:
|
||||
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
|
||||
(c1.val(), c2.val())
|
||||
(c1.kind(), c2.kind())
|
||||
{
|
||||
if self.infcx.try_unify_abstract_consts(
|
||||
a.shrink(),
|
||||
|
@ -635,7 +635,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
let evaluate = |c: ty::Const<'tcx>| {
|
||||
if let ty::ConstKind::Unevaluated(unevaluated) = c.val() {
|
||||
if let ty::ConstKind::Unevaluated(unevaluated) = c.kind() {
|
||||
self.infcx
|
||||
.const_eval_resolve(
|
||||
obligation.param_env,
|
||||
|
|
|
@ -41,7 +41,7 @@ pub fn obligations<'a, 'tcx>(
|
|||
.into()
|
||||
}
|
||||
GenericArgKind::Const(ct) => {
|
||||
match ct.val() {
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Infer(infer) => {
|
||||
let resolved = infcx.shallow_resolve(infer);
|
||||
if resolved == infer {
|
||||
|
@ -51,7 +51,7 @@ pub fn obligations<'a, 'tcx>(
|
|||
|
||||
infcx
|
||||
.tcx
|
||||
.mk_const(ty::ConstS { val: ty::ConstKind::Infer(resolved), ty: ct.ty() })
|
||||
.mk_const(ty::ConstS { kind: ty::ConstKind::Infer(resolved), ty: ct.ty() })
|
||||
}
|
||||
_ => ct,
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
GenericArgKind::Lifetime(_) => continue,
|
||||
|
||||
GenericArgKind::Const(constant) => {
|
||||
match constant.val() {
|
||||
match constant.kind() {
|
||||
ty::ConstKind::Unevaluated(uv) => {
|
||||
let obligations = self.nominal_obligations(uv.def.did, uv.substs);
|
||||
self.out.extend(obligations);
|
||||
|
@ -460,7 +460,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
let cause = self.cause(traits::MiscObligation);
|
||||
|
||||
let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
|
||||
val: ty::ConstKind::Infer(resolved),
|
||||
kind: ty::ConstKind::Infer(resolved),
|
||||
ty: constant.ty(),
|
||||
});
|
||||
self.out.push(traits::Obligation::with_depth(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue