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.
This commit is contained in:
parent
ca122c7ebb
commit
93e4b6ef06
74 changed files with 173 additions and 169 deletions
|
@ -197,7 +197,7 @@ pub(crate) fn deref_const<'tcx>(
|
|||
},
|
||||
};
|
||||
|
||||
tcx.mk_const(ty::ConstS { val: ty::ConstKind::Value(op_to_const(&ecx, &mplace.into())), ty })
|
||||
tcx.mk_const(ty::ConstS { kind: ty::ConstKind::Value(op_to_const(&ecx, &mplace.into())), ty })
|
||||
}
|
||||
|
||||
#[instrument(skip(tcx), level = "debug")]
|
||||
|
|
|
@ -622,10 +622,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
/// "universe" (param_env).
|
||||
pub fn const_to_op(
|
||||
&self,
|
||||
val: ty::Const<'tcx>,
|
||||
c: ty::Const<'tcx>,
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
|
||||
match val.val() {
|
||||
match c.kind() {
|
||||
ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) => throw_inval!(TooGeneric),
|
||||
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => {
|
||||
throw_inval!(AlreadyReported(reported))
|
||||
|
@ -635,9 +635,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())
|
||||
}
|
||||
ty::ConstKind::Infer(..) | ty::ConstKind::Placeholder(..) => {
|
||||
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", val)
|
||||
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", c)
|
||||
}
|
||||
ty::ConstKind::Value(val_val) => self.const_val_to_op(val_val, val.ty(), layout),
|
||||
ty::ConstKind::Value(val) => self.const_val_to_op(val, c.ty(), layout),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ where
|
|||
assert!(matches!(ty.kind(), ty::Param(_)))
|
||||
}
|
||||
ty::subst::GenericArgKind::Const(ct) => {
|
||||
assert!(matches!(ct.val(), ty::ConstKind::Param(_)))
|
||||
assert!(matches!(ct.kind(), ty::ConstKind::Param(_)))
|
||||
}
|
||||
ty::subst::GenericArgKind::Lifetime(..) => (),
|
||||
},
|
||||
|
@ -69,7 +69,7 @@ where
|
|||
}
|
||||
|
||||
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match c.val() {
|
||||
match c.kind() {
|
||||
ty::ConstKind::Param(..) => ControlFlow::Break(FoundParam),
|
||||
_ => c.super_visit_with(self),
|
||||
}
|
||||
|
|
|
@ -353,7 +353,8 @@ where
|
|||
|
||||
// Check the qualifs of the value of `const` items.
|
||||
if let Some(ct) = constant.literal.const_for_ty() {
|
||||
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) = ct.val() {
|
||||
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) = ct.kind()
|
||||
{
|
||||
// Use qualifs of the type for the promoted. Promoteds in MIR body should be possible
|
||||
// only for `NeedsNonConstDrop` with precise drop checking. This is the only const
|
||||
// check performed after the promotion. Verify that with an assertion.
|
||||
|
|
|
@ -842,7 +842,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
|||
literal: tcx
|
||||
.mk_const(ty::ConstS {
|
||||
ty,
|
||||
val: ty::ConstKind::Unevaluated(ty::Unevaluated {
|
||||
kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
|
||||
def,
|
||||
substs: InternalSubsts::for_item(tcx, def.did, |param, _| {
|
||||
if let ty::GenericParamDefKind::Lifetime = param.kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue