rename eval_const_to_op -> const_to_op
This commit is contained in:
parent
1df9f44db7
commit
b8fd0f6a13
4 changed files with 8 additions and 12 deletions
|
@ -41,7 +41,7 @@ pub(crate) fn destructure_const<'tcx>(
|
|||
) -> mir::DestructuredConst<'tcx> {
|
||||
trace!("destructure_const: {:?}", val);
|
||||
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
|
||||
let op = ecx.eval_const_to_op(val, None).unwrap();
|
||||
let op = ecx.const_to_op(val, None).unwrap();
|
||||
|
||||
// We go to `usize` as we cannot allocate anything bigger anyway.
|
||||
let (field_count, variant, down) = match val.ty.kind {
|
||||
|
|
|
@ -848,12 +848,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
};
|
||||
let val = self.tcx.const_eval_global_id(param_env, gid, Some(self.tcx.span))?;
|
||||
|
||||
// Even though `ecx.const_eval` is called from `eval_const_to_op` we can never have a
|
||||
// Even though `ecx.const_eval` is called from `const_to_op` we can never have a
|
||||
// recursion deeper than one level, because the `tcx.const_eval` above is guaranteed to not
|
||||
// return `ConstValue::Unevaluated`, which is the only way that `eval_const_to_op` will call
|
||||
// return `ConstValue::Unevaluated`, which is the only way that `const_to_op` will call
|
||||
// `ecx.const_eval`.
|
||||
let const_ = ty::Const { val: ty::ConstKind::Value(val), ty };
|
||||
self.eval_const_to_op(&const_, None)
|
||||
self.const_to_op(&const_, None)
|
||||
}
|
||||
|
||||
pub fn const_eval_raw(
|
||||
|
|
|
@ -517,7 +517,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
Constant(ref constant) => {
|
||||
let val =
|
||||
self.subst_from_current_frame_and_normalize_erasing_regions(constant.literal);
|
||||
self.eval_const_to_op(val, layout)?
|
||||
self.const_to_op(val, layout)?
|
||||
}
|
||||
};
|
||||
trace!("{:?}: {:?}", mir_op, *op);
|
||||
|
@ -536,7 +536,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// in patterns via the `const_eval` module
|
||||
/// The `val` and `layout` are assumed to already be in our interpreter
|
||||
/// "universe" (param_env).
|
||||
crate fn eval_const_to_op(
|
||||
crate fn const_to_op(
|
||||
&self,
|
||||
val: &ty::Const<'tcx>,
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
|
@ -559,16 +559,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// potentially requiring the current static to be evaluated again. This is not a
|
||||
// problem here, because we are building an operand which means an actual read is
|
||||
// happening.
|
||||
//
|
||||
// The machine callback `adjust_global_const` below is guaranteed to
|
||||
// be called for all constants because `const_eval` calls
|
||||
// `eval_const_to_op` recursively.
|
||||
return Ok(self.const_eval(GlobalId { instance, promoted }, val.ty)?);
|
||||
}
|
||||
ty::ConstKind::Infer(..)
|
||||
| ty::ConstKind::Bound(..)
|
||||
| ty::ConstKind::Placeholder(..) => {
|
||||
span_bug!(self.cur_span(), "eval_const_to_op: Unexpected ConstKind {:?}", val)
|
||||
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", val)
|
||||
}
|
||||
ty::ConstKind::Value(val_val) => val_val,
|
||||
};
|
||||
|
|
|
@ -436,7 +436,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||
return None;
|
||||
}
|
||||
|
||||
match self.ecx.eval_const_to_op(c.literal, None) {
|
||||
match self.ecx.const_to_op(c.literal, None) {
|
||||
Ok(op) => Some(op),
|
||||
Err(error) => {
|
||||
let tcx = self.ecx.tcx.at(c.span);
|
||||
|
|
Loading…
Reference in a new issue