#[inline(always)]
pub fn cur_frame(&self) -> usize {
- assert!(self.stack.len() > 0);
+ assert!(!self.stack.is_empty());
self.stack.len() - 1
}
// Check if this brought us over the size limit.
if size.bytes() >= self.tcx.data_layout().obj_size_bound() {
- throw_ub_format!(
- "wide pointer metadata contains invalid information: \
- total size is bigger than largest supported object"
- );
+ throw_ub!(InvalidMeta("total size is bigger than largest supported object"));
}
Ok(Some((size, align)))
}
// Make sure the slice is not too big.
let size = elem.size.checked_mul(len, &*self.tcx).ok_or_else(|| {
- err_ub_format!(
- "invalid slice: \
- total size is bigger than largest supported object"
- )
+ err_ub!(InvalidMeta("slice is bigger than largest supported object"))
})?;
Ok(Some((size, elem.align.abi)))
}
return_place: Option<PlaceTy<'tcx, M::PointerTag>>,
return_to_block: StackPopCleanup,
) -> InterpResult<'tcx> {
- if self.stack.len() > 0 {
+ if !self.stack.is_empty() {
info!("PAUSING({}) {}", self.cur_frame(), self.frame().instance);
}
::log_settings::settings().indentation += 1;
);
if cur_unwinding {
// Follow the unwind edge.
- let unwind = next_block.expect("Encounted StackPopCleanup::None when unwinding!");
+ let unwind = next_block.expect("Encountered StackPopCleanup::None when unwinding!");
self.unwind_to_block(unwind);
} else {
// Follow the normal return edge.
// invariant -- that is, unless a function somehow has a ptr to
// its return place... but the way MIR is currently generated, the
// return place is always a local and then this cannot happen.
- self.validate_operand(self.place_to_op(return_place)?, vec![], None)?;
+ self.validate_operand(self.place_to_op(return_place)?)?;
}
} else {
// Uh, that shouldn't happen... the function did not intend to return
}
}
- if self.stack.len() > 0 {
+ if !self.stack.is_empty() {
info!(
"CONTINUING({}) {} (unwinding = {})",
self.cur_frame(),
pub(super) fn const_eval(
&self,
gid: GlobalId<'tcx>,
+ ty: Ty<'tcx>,
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
// For statics we pick `ParamEnv::reveal_all`, because statics don't have generics
// and thus don't care about the parameter environment. While we could just use
} else {
self.param_env
};
- let val = if let Some(promoted) = gid.promoted {
- self.tcx.const_eval_promoted(param_env, gid.instance, promoted)?
- } else {
- self.tcx.const_eval_instance(param_env, gid.instance, Some(self.tcx.span))?
- };
+ 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
// 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
// `ecx.const_eval`.
- self.eval_const_to_op(val, None)
+ let const_ = ty::Const { val: ty::ConstKind::Value(val), ty };
+ self.eval_const_to_op(&const_, None)
}
pub fn const_eval_raw(