renames EvalErrorKind to InterpError

This commit is contained in:
kenta7777 2019-04-02 01:02:18 +09:00
parent eab3eb38df
commit 3c8caaca7d
21 changed files with 73 additions and 73 deletions

View File

@ -43,7 +43,7 @@ pub type ConstEvalResult<'tcx> = Result<ty::Const<'tcx>, ErrorHandled>;
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct ConstEvalErr<'tcx> {
pub span: Span,
pub error: crate::mir::interpret::EvalErrorKind<'tcx, u64>,
pub error: crate::mir::interpret::InterpError<'tcx, u64>,
pub stacktrace: Vec<FrameInfo<'tcx>>,
}
@ -135,10 +135,10 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
lint_root: Option<hir::HirId>,
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
match self.error {
EvalErrorKind::Layout(LayoutError::Unknown(_)) |
EvalErrorKind::TooGeneric => return Err(ErrorHandled::TooGeneric),
EvalErrorKind::Layout(LayoutError::SizeOverflow(_)) |
EvalErrorKind::TypeckError => return Err(ErrorHandled::Reported),
InterpError::Layout(LayoutError::Unknown(_)) |
InterpError::TooGeneric => return Err(ErrorHandled::TooGeneric),
InterpError::Layout(LayoutError::SizeOverflow(_)) |
InterpError::TypeckError => return Err(ErrorHandled::Reported),
_ => {},
}
trace!("reporting const eval failure at {:?}", self.span);
@ -180,7 +180,7 @@ pub fn struct_error<'a, 'gcx, 'tcx>(
#[derive(Debug, Clone)]
pub struct EvalError<'tcx> {
pub kind: EvalErrorKind<'tcx, u64>,
pub kind: InterpError<'tcx, u64>,
pub backtrace: Option<Box<Backtrace>>,
}
@ -197,8 +197,8 @@ fn print_backtrace(backtrace: &mut Backtrace) {
eprintln!("\n\nAn error occurred in miri:\n{:?}", backtrace);
}
impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
fn from(kind: EvalErrorKind<'tcx, u64>) -> Self {
impl<'tcx> From<InterpError<'tcx, u64>> for EvalError<'tcx> {
fn from(kind: InterpError<'tcx, u64>) -> Self {
let backtrace = match env::var("RUST_CTFE_BACKTRACE") {
// matching RUST_BACKTRACE, we treat "0" the same as "not present".
Ok(ref val) if val != "0" => {
@ -221,10 +221,10 @@ impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
}
}
pub type AssertMessage<'tcx> = EvalErrorKind<'tcx, mir::Operand<'tcx>>;
pub type AssertMessage<'tcx> = InterpError<'tcx, mir::Operand<'tcx>>;
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum EvalErrorKind<'tcx, O> {
pub enum InterpError<'tcx, O> {
/// This variant is used by machines to signal their own errors that do not
/// match an existing variant.
MachineError(String),
@ -312,9 +312,9 @@ pub enum EvalErrorKind<'tcx, O> {
pub type EvalResult<'tcx, T = ()> = Result<T, EvalError<'tcx>>;
impl<'tcx, O> EvalErrorKind<'tcx, O> {
impl<'tcx, O> InterpError<'tcx, O> {
pub fn description(&self) -> &str {
use self::EvalErrorKind::*;
use self::InterpError::*;
match *self {
MachineError(ref inner) => inner,
FunctionAbiMismatch(..) | FunctionArgMismatch(..) | FunctionRetMismatch(..)
@ -450,15 +450,15 @@ impl<'tcx> fmt::Display for EvalError<'tcx> {
}
}
impl<'tcx> fmt::Display for EvalErrorKind<'tcx, u64> {
impl<'tcx> fmt::Display for InterpError<'tcx, u64> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl<'tcx, O: fmt::Debug> fmt::Debug for EvalErrorKind<'tcx, O> {
impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::EvalErrorKind::*;
use self::InterpError::*;
match *self {
PointerOutOfBounds { ptr, check, allocation_size } => {
write!(f, "Pointer must be in-bounds{} at offset {}, but is outside bounds of \

View File

@ -2,7 +2,7 @@
#[macro_export]
macro_rules! err {
($($tt:tt)*) => { Err($crate::mir::interpret::EvalErrorKind::$($tt)*.into()) };
($($tt:tt)*) => { Err($crate::mir::interpret::InterpError::$($tt)*.into()) };
}
mod error;
@ -11,7 +11,7 @@ mod allocation;
mod pointer;
pub use self::error::{
EvalError, EvalResult, EvalErrorKind, AssertMessage, ConstEvalErr, struct_error,
EvalError, EvalResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
};

View File

@ -5,7 +5,7 @@
use crate::hir::def::{CtorKind, Namespace};
use crate::hir::def_id::DefId;
use crate::hir::{self, HirId, InlineAsm};
use crate::mir::interpret::{ConstValue, EvalErrorKind, Scalar};
use crate::mir::interpret::{ConstValue, InterpError, Scalar};
use crate::mir::visit::MirVisitable;
use rustc_apfloat::ieee::{Double, Single};
use rustc_apfloat::Float;
@ -3226,8 +3226,8 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
target,
cleanup,
} => {
let msg = if let EvalErrorKind::BoundsCheck { ref len, ref index } = *msg {
EvalErrorKind::BoundsCheck {
let msg = if let InterpError::BoundsCheck { ref len, ref index } = *msg {
InterpError::BoundsCheck {
len: len.fold_with(folder),
index: index.fold_with(folder),
}
@ -3301,7 +3301,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
ref cond, ref msg, ..
} => {
if cond.visit_with(visitor) {
if let EvalErrorKind::BoundsCheck { ref len, ref index } = *msg {
if let InterpError::BoundsCheck { ref len, ref index } = *msg {
len.visit_with(visitor) || index.visit_with(visitor)
} else {
false

View File

@ -560,7 +560,7 @@ macro_rules! make_mir_visitor {
fn super_assert_message(&mut self,
msg: & $($mutability)? AssertMessage<'tcx>,
location: Location) {
use crate::mir::interpret::EvalErrorKind::*;
use crate::mir::interpret::InterpError::*;
if let BoundsCheck { len, index } = msg {
self.visit_operand(len, location);
self.visit_operand(index, location);

View File

@ -2,7 +2,7 @@ use rustc::middle::lang_items;
use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt};
use rustc::mir::{self, Place, PlaceBase, Static, StaticKind};
use rustc::mir::interpret::EvalErrorKind;
use rustc::mir::interpret::InterpError;
use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode};
use rustc_target::spec::abi::Abi;
use rustc_mir::monomorphize;
@ -365,7 +365,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// checked operation, just a comparison with the minimum
// value, so we have to check for the assert message.
if !bx.check_overflow() {
if let mir::interpret::EvalErrorKind::OverflowNeg = *msg {
if let mir::interpret::InterpError::OverflowNeg = *msg {
const_cond = Some(expected);
}
}
@ -400,7 +400,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// Put together the arguments to the panic entry point.
let (lang_item, args) = match *msg {
EvalErrorKind::BoundsCheck { ref len, ref index } => {
InterpError::BoundsCheck { ref len, ref index } => {
let len = self.codegen_operand(&mut bx, len).immediate();
let index = self.codegen_operand(&mut bx, index).immediate();

View File

@ -688,7 +688,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
cleanup: _,
} => {
self.consume_operand(ContextKind::Assert.new(loc), (cond, span), flow_state);
use rustc::mir::interpret::EvalErrorKind::BoundsCheck;
use rustc::mir::interpret::InterpError::BoundsCheck;
if let BoundsCheck { ref len, ref index } = *msg {
self.consume_operand(ContextKind::Assert.new(loc), (len, span), flow_state);
self.consume_operand(ContextKind::Assert.new(loc), (index, span), flow_state);

View File

@ -215,7 +215,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
cleanup: _,
} => {
self.consume_operand(ContextKind::Assert.new(location), cond);
use rustc::mir::interpret::EvalErrorKind::BoundsCheck;
use rustc::mir::interpret::InterpError::BoundsCheck;
if let BoundsCheck { ref len, ref index } = *msg {
self.consume_operand(ContextKind::Assert.new(location), len);
self.consume_operand(ContextKind::Assert.new(location), index);

View File

@ -28,7 +28,7 @@ use rustc::infer::canonical::QueryRegionConstraint;
use rustc::infer::outlives::env::RegionBoundPairs;
use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime, NLLRegionVariableOrigin};
use rustc::infer::type_variable::TypeVariableOrigin;
use rustc::mir::interpret::{EvalErrorKind::BoundsCheck, ConstValue};
use rustc::mir::interpret::{InterpError::BoundsCheck, ConstValue};
use rustc::mir::tcx::PlaceTy;
use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext, NonMutatingUseContext};
use rustc::mir::*;

View File

@ -4,7 +4,7 @@ use crate::build::expr::category::Category;
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use rustc::mir::interpret::EvalErrorKind::BoundsCheck;
use rustc::mir::interpret::InterpError::BoundsCheck;
use rustc::mir::*;
use rustc::ty::{CanonicalUserTypeAnnotation, Variance};

View File

@ -7,7 +7,7 @@ use crate::build::expr::category::{Category, RvalueFunc};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use rustc::middle::region;
use rustc::mir::interpret::EvalErrorKind;
use rustc::mir::interpret::InterpError;
use rustc::mir::*;
use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, UpvarSubsts};
use syntax_pos::Span;
@ -101,7 +101,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
block,
Operand::Move(is_min),
false,
EvalErrorKind::OverflowNeg,
InterpError::OverflowNeg,
expr_span,
);
}
@ -433,7 +433,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
let val = result_value.clone().field(val_fld, ty);
let of = result_value.field(of_fld, bool_ty);
let err = EvalErrorKind::Overflow(op);
let err = InterpError::Overflow(op);
block = self.assert(block, Operand::Move(of), false, err, span);
@ -444,9 +444,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
// and 2. there are two possible failure cases, divide-by-zero and overflow.
let (zero_err, overflow_err) = if op == BinOp::Div {
(EvalErrorKind::DivisionByZero, EvalErrorKind::Overflow(op))
(InterpError::DivisionByZero, InterpError::Overflow(op))
} else {
(EvalErrorKind::RemainderByZero, EvalErrorKind::Overflow(op))
(InterpError::RemainderByZero, InterpError::Overflow(op))
};
// Check for / 0

View File

@ -23,7 +23,7 @@ use syntax::source_map::{Span, DUMMY_SP};
use crate::interpret::{self,
PlaceTy, MPlaceTy, MemPlace, OpTy, ImmTy, Immediate, Scalar, Pointer,
RawConst, ConstValue,
EvalResult, EvalError, EvalErrorKind, GlobalId, InterpretCx, StackPopCleanup,
EvalResult, EvalError, InterpError, GlobalId, InterpretCx, StackPopCleanup,
Allocation, AllocId, MemoryKind,
snapshot, RefTracking,
};
@ -173,7 +173,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
impl<'tcx> Into<EvalError<'tcx>> for ConstEvalError {
fn into(self) -> EvalError<'tcx> {
EvalErrorKind::MachineError(self.to_string()).into()
InterpError::MachineError(self.to_string()).into()
}
}
@ -351,7 +351,7 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
Ok(Some(match ecx.load_mir(instance.def) {
Ok(mir) => mir,
Err(err) => {
if let EvalErrorKind::NoMirFor(ref path) = err.kind {
if let InterpError::NoMirFor(ref path) = err.kind {
return Err(
ConstEvalError::NeedsRfc(format!("calling extern function `{}`", path))
.into(),
@ -679,7 +679,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
// any other kind of error will be reported to the user as a deny-by-default lint
_ => if let Some(p) = cid.promoted {
let span = tcx.optimized_mir(def_id).promoted[p].span;
if let EvalErrorKind::ReferencedConstant = err.error {
if let InterpError::ReferencedConstant = err.error {
err.report_as_error(
tcx.at(span),
"evaluation of constant expression failed",

View File

@ -4,7 +4,7 @@ use syntax::ast::{FloatTy, IntTy, UintTy};
use rustc_apfloat::ieee::{Single, Double};
use rustc::mir::interpret::{
Scalar, EvalResult, Pointer, PointerArithmetic, EvalErrorKind, truncate
Scalar, EvalResult, Pointer, PointerArithmetic, InterpError, truncate
};
use rustc::mir::CastKind;
use rustc_apfloat::Float;
@ -85,7 +85,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
self.param_env,
def_id,
substs,
).ok_or_else(|| EvalErrorKind::TooGeneric.into());
).ok_or_else(|| InterpError::TooGeneric.into());
let fn_ptr = self.memory.create_fn_alloc(instance?).with_default_tag();
self.write_scalar(Scalar::Ptr(fn_ptr.into()), dest)?;
}

View File

@ -16,7 +16,7 @@ use rustc_data_structures::indexed_vec::IndexVec;
use rustc::mir::interpret::{
ErrorHandled,
GlobalId, Scalar, FrameInfo, AllocId,
EvalResult, EvalErrorKind,
EvalResult, InterpError,
truncate, sign_extend,
};
use rustc_data_structures::fx::FxHashMap;
@ -167,7 +167,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> LayoutOf
#[inline]
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
self.tcx.layout_of(self.param_env.and(ty))
.map_err(|layout| EvalErrorKind::Layout(layout).into())
.map_err(|layout| InterpError::Layout(layout).into())
}
}
@ -255,7 +255,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
self.param_env,
def_id,
substs,
).ok_or_else(|| EvalErrorKind::TooGeneric.into())
).ok_or_else(|| InterpError::TooGeneric.into())
}
pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
@ -647,8 +647,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
// `Memory::get_static_alloc` which has to use `const_eval_raw` to avoid cycles.
let val = self.tcx.const_eval_raw(param_env.and(gid)).map_err(|err| {
match err {
ErrorHandled::Reported => EvalErrorKind::ReferencedConstant,
ErrorHandled::TooGeneric => EvalErrorKind::TooGeneric,
ErrorHandled::Reported => InterpError::ReferencedConstant,
ErrorHandled::TooGeneric => InterpError::TooGeneric,
}
})?;
self.raw_const_to_mplace(val)
@ -670,7 +670,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
match self.stack[frame].locals[local].access() {
Err(err) => {
if let EvalErrorKind::DeadLocal = err.kind {
if let InterpError::DeadLocal = err.kind {
write!(msg, " is dead").unwrap();
} else {
panic!("Failed to access local: {:?}", err);

View File

@ -7,7 +7,7 @@ use rustc::ty;
use rustc::ty::layout::{LayoutOf, Primitive, Size};
use rustc::mir::BinOp;
use rustc::mir::interpret::{
EvalResult, EvalErrorKind, Scalar,
EvalResult, InterpError, Scalar,
};
use super::{
@ -87,7 +87,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
let bits = self.read_scalar(args[0])?.to_bits(layout_of.size)?;
let kind = match layout_of.abi {
ty::layout::Abi::Scalar(ref scalar) => scalar.value,
_ => Err(::rustc::mir::interpret::EvalErrorKind::TypeNotPrimitive(ty))?,
_ => Err(::rustc::mir::interpret::InterpError::TypeNotPrimitive(ty))?,
};
let out_val = if intrinsic_name.ends_with("_nonzero") {
if bits == 0 {
@ -248,7 +248,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
let file = Symbol::intern(self.read_str(file_place)?);
let line = self.read_scalar(line.into())?.to_u32()?;
let col = self.read_scalar(col.into())?.to_u32()?;
return Err(EvalErrorKind::Panic { msg, file, line, col }.into());
return Err(InterpError::Panic { msg, file, line, col }.into());
} else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() {
assert!(args.len() == 2);
// &'static str, &(&'static str, u32, u32)
@ -266,7 +266,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
let file = Symbol::intern(self.read_str(file_place)?);
let line = self.read_scalar(line.into())?.to_u32()?;
let col = self.read_scalar(col.into())?.to_u32()?;
return Err(EvalErrorKind::Panic { msg, file, line, col }.into());
return Err(InterpError::Panic { msg, file, line, col }.into());
} else {
return Ok(false);
}

View File

@ -19,7 +19,7 @@ use syntax::ast::Mutability;
use super::{
Pointer, AllocId, Allocation, GlobalId, AllocationExtra,
EvalResult, Scalar, EvalErrorKind, AllocKind, PointerArithmetic,
EvalResult, Scalar, InterpError, AllocKind, PointerArithmetic,
Machine, AllocMap, MayLeak, ErrorHandled, InboundsCheck,
};
@ -344,8 +344,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
// no need to report anything, the const_eval call takes care of that for statics
assert!(tcx.is_static(def_id).is_some());
match err {
ErrorHandled::Reported => EvalErrorKind::ReferencedConstant.into(),
ErrorHandled::TooGeneric => EvalErrorKind::TooGeneric.into(),
ErrorHandled::Reported => InterpError::ReferencedConstant.into(),
ErrorHandled::TooGeneric => InterpError::TooGeneric.into(),
}
}).map(|raw_const| {
let allocation = tcx.alloc_map.lock().unwrap_memory(raw_const.alloc_id);
@ -458,7 +458,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
trace!("reading fn ptr: {}", ptr.alloc_id);
match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
Some(AllocKind::Function(instance)) => Ok(instance),
_ => Err(EvalErrorKind::ExecuteMemory.into()),
_ => Err(InterpError::ExecuteMemory.into()),
}
}

View File

@ -9,7 +9,7 @@ use rustc::ty::layout::{self, Size, LayoutOf, TyLayout, HasDataLayout, IntegerEx
use rustc::mir::interpret::{
GlobalId, AllocId, InboundsCheck,
ConstValue, Pointer, Scalar,
EvalResult, EvalErrorKind,
EvalResult, InterpError,
sign_extend, truncate,
};
use super::{
@ -369,7 +369,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
let len = mplace.len(self)?;
let bytes = self.memory.read_bytes(mplace.ptr, Size::from_bytes(len as u64))?;
let str = ::std::str::from_utf8(bytes)
.map_err(|err| EvalErrorKind::ValidationFailure(err.to_string()))?;
.map_err(|err| InterpError::ValidationFailure(err.to_string()))?;
Ok(str)
}
@ -653,7 +653,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
.expect("tagged layout for non adt")
.discriminants(self.tcx.tcx)
.find(|(_, var)| var.val == real_discr)
.ok_or_else(|| EvalErrorKind::InvalidDiscriminant(raw_discr.erase_tag()))?;
.ok_or_else(|| InterpError::InvalidDiscriminant(raw_discr.erase_tag()))?;
(real_discr, index.0)
},
layout::DiscriminantKind::Niche {

View File

@ -12,7 +12,7 @@ use rustc::mir;
use rustc::mir::interpret::{
AllocId, Pointer, Scalar,
Relocations, Allocation, UndefMask,
EvalResult, EvalErrorKind,
EvalResult, InterpError,
};
use rustc::ty::{self, TyCtxt};
@ -78,7 +78,7 @@ impl<'a, 'mir, 'tcx> InfiniteLoopDetector<'a, 'mir, 'tcx>
}
// Second cycle
Err(EvalErrorKind::InfiniteLoop.into())
Err(InterpError::InfiniteLoop.into())
}
}

View File

@ -5,7 +5,7 @@ use rustc::ty::layout::{self, TyLayout, LayoutOf};
use syntax::source_map::Span;
use rustc_target::spec::abi::Abi;
use rustc::mir::interpret::{EvalResult, PointerArithmetic, EvalErrorKind, Scalar};
use rustc::mir::interpret::{EvalResult, PointerArithmetic, InterpError, Scalar};
use super::{
InterpretCx, Machine, Immediate, OpTy, ImmTy, PlaceTy, MPlaceTy, StackPopCleanup
};
@ -134,7 +134,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
self.goto_block(Some(target))?;
} else {
// Compute error message
use rustc::mir::interpret::EvalErrorKind::*;
use rustc::mir::interpret::InterpError::*;
return match *msg {
BoundsCheck { ref len, ref index } => {
let len = self.read_immediate(self.eval_operand(len, None)?)
@ -212,7 +212,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
return Ok(());
}
let caller_arg = caller_arg.next()
.ok_or_else(|| EvalErrorKind::FunctionArgCountMismatch)?;
.ok_or_else(|| InterpError::FunctionArgCountMismatch)?;
if rust_abi {
debug_assert!(!caller_arg.layout.is_zst(), "ZSTs must have been already filtered out");
}

View File

@ -7,7 +7,7 @@ use rustc::ty::layout::{self, Size, Align, TyLayout, LayoutOf, VariantIdx};
use rustc::ty;
use rustc_data_structures::fx::FxHashSet;
use rustc::mir::interpret::{
Scalar, AllocKind, EvalResult, EvalErrorKind,
Scalar, AllocKind, EvalResult, InterpError,
};
use super::{
@ -258,11 +258,11 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
match self.walk_value(op) {
Ok(()) => Ok(()),
Err(err) => match err.kind {
EvalErrorKind::InvalidDiscriminant(val) =>
InterpError::InvalidDiscriminant(val) =>
validation_failure!(
val, self.path, "a valid enum discriminant"
),
EvalErrorKind::ReadPointerAsBytes =>
InterpError::ReadPointerAsBytes =>
validation_failure!(
"a pointer", self.path, "plain (non-pointer) bytes"
),
@ -355,9 +355,9 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
Err(err) => {
error!("{:?} is not aligned to {:?}", ptr, align);
match err.kind {
EvalErrorKind::InvalidNullPointerUsage =>
InterpError::InvalidNullPointerUsage =>
return validation_failure!("NULL reference", self.path),
EvalErrorKind::AlignmentCheckFailed { required, has } =>
InterpError::AlignmentCheckFailed { required, has } =>
return validation_failure!(format!("unaligned reference \
(required {} byte alignment but found {})",
required.bytes(), has.bytes()), self.path),
@ -562,7 +562,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
Err(err) => {
// For some errors we might be able to provide extra information
match err.kind {
EvalErrorKind::ReadUndefBytes(offset) => {
InterpError::ReadUndefBytes(offset) => {
// Some byte was undefined, determine which
// element that byte belongs to so we can
// provide an index.

View File

@ -7,7 +7,7 @@ use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, Rvalue, Loc
use rustc::mir::{NullOp, UnOp, StatementKind, Statement, BasicBlock, LocalKind, Static, StaticKind};
use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext};
use rustc::mir::interpret::{EvalErrorKind, Scalar, GlobalId, EvalResult};
use rustc::mir::interpret::{InterpError, Scalar, GlobalId, EvalResult};
use rustc::ty::{TyCtxt, self, Instance};
use syntax::source_map::{Span, DUMMY_SP};
use rustc::ty::subst::InternalSubsts;
@ -144,7 +144,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
Ok(val) => Some(val),
Err(error) => {
let diagnostic = error_to_const_error(&self.ecx, error);
use rustc::mir::interpret::EvalErrorKind::*;
use rustc::mir::interpret::InterpError::*;
match diagnostic.error {
// don't report these, they make no sense in a const prop context
| MachineError(_)
@ -457,7 +457,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
)
} else {
if overflow {
let err = EvalErrorKind::Overflow(op).into();
let err = InterpError::Overflow(op).into();
let _: Option<()> = self.use_ecx(source_info, |_| Err(err));
return None;
}
@ -611,7 +611,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
.hir()
.as_local_hir_id(self.source.def_id())
.expect("some part of a failing const eval must be local");
use rustc::mir::interpret::EvalErrorKind::*;
use rustc::mir::interpret::InterpError::*;
let msg = match msg {
Overflow(_) |
OverflowNeg |

View File

@ -773,7 +773,7 @@ fn create_generator_resume_function<'a, 'tcx>(
let mut cases = create_cases(mir, &transform, |point| Some(point.resume));
use rustc::mir::interpret::EvalErrorKind::{
use rustc::mir::interpret::InterpError::{
GeneratorResumedAfterPanic,
GeneratorResumedAfterReturn,
};