address review again
This commit is contained in:
parent
ba00189d8e
commit
6af8fb7936
20 changed files with 119 additions and 520 deletions
|
@ -564,8 +564,16 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
throw_inval!(AlreadyReported(reported))
|
||||
}
|
||||
ty::ConstKind::Unevaluated(uv) => {
|
||||
// NOTE: We evaluate to a `ValTree` here as a check to ensure
|
||||
// we're working with valid constants, even though we never need it.
|
||||
let instance = self.resolve(uv.def, uv.substs)?;
|
||||
Ok(self.eval_to_allocation(GlobalId { instance, promoted: None })?.into())
|
||||
let cid = GlobalId { instance, promoted: None };
|
||||
let _valtree = self
|
||||
.tcx
|
||||
.eval_to_valtree(self.param_env.and(cid))?
|
||||
.unwrap_or_else(|| bug!("unable to create ValTree for {:?}", uv));
|
||||
|
||||
Ok(self.eval_to_allocation(cid)?.into())
|
||||
}
|
||||
ty::ConstKind::Bound(..) | ty::ConstKind::Infer(..) => {
|
||||
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", c)
|
||||
|
@ -578,16 +586,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Tries to evaluate an unevaluated constant from the MIR (and not the type-system).
|
||||
#[inline]
|
||||
pub fn uneval_to_op(
|
||||
&self,
|
||||
uneval: &ty::Unevaluated<'tcx>,
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
|
||||
let instance = self.resolve(uneval.def, uneval.substs)?;
|
||||
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uneval.promoted })?.into())
|
||||
}
|
||||
|
||||
pub fn mir_const_to_op(
|
||||
&self,
|
||||
val: &mir::ConstantKind<'tcx>,
|
||||
|
@ -596,7 +594,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
match val {
|
||||
mir::ConstantKind::Ty(ct) => self.const_to_op(*ct, layout),
|
||||
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(*val, *ty, layout),
|
||||
mir::ConstantKind::Unevaluated(uv, _) => self.uneval_to_op(uv),
|
||||
mir::ConstantKind::Unevaluated(uv, _) => {
|
||||
let instance = self.resolve(uv.def, uv.substs)?;
|
||||
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -346,6 +346,8 @@ where
|
|||
};
|
||||
|
||||
// Check the qualifs of the value of `const` items.
|
||||
// FIXME(valtrees): check whether const qualifs should behave the same
|
||||
// way for type and mir constants.
|
||||
let uneval = match constant.literal {
|
||||
ConstantKind::Ty(ct) if matches!(ct.kind(), ty::ConstKind::Unevaluated(_)) => {
|
||||
let ty::ConstKind::Unevaluated(uv) = ct.kind() else { unreachable!() };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue