alters the panic variant of InterpError
This commit is contained in:
parent
589f6a7dc6
commit
fd352b02e1
3 changed files with 25 additions and 42 deletions
|
@ -228,6 +228,24 @@ impl<'tcx> From<InterpError<'tcx, u64>> for InterpErrorInfo<'tcx> {
|
||||||
|
|
||||||
pub type AssertMessage<'tcx> = InterpError<'tcx, mir::Operand<'tcx>>;
|
pub type AssertMessage<'tcx> = InterpError<'tcx, mir::Operand<'tcx>>;
|
||||||
|
|
||||||
|
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||||
|
pub enum EvalErrorPanic<O> {
|
||||||
|
Panic {
|
||||||
|
msg: Symbol,
|
||||||
|
line: u32,
|
||||||
|
col: u32,
|
||||||
|
file: Symbol,
|
||||||
|
},
|
||||||
|
BoundsCheck {
|
||||||
|
len: O,
|
||||||
|
index: O,
|
||||||
|
},
|
||||||
|
Overflow(mir::BinOp),
|
||||||
|
OverflowNeg,
|
||||||
|
DivisionByZero,
|
||||||
|
RemainderByZero,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||||
pub enum InterpError<'tcx, O> {
|
pub enum InterpError<'tcx, O> {
|
||||||
/// This variant is used by machines to signal their own errors that do not
|
/// This variant is used by machines to signal their own errors that do not
|
||||||
|
@ -247,7 +265,6 @@ pub enum InterpError<'tcx, O> {
|
||||||
DanglingPointerDeref,
|
DanglingPointerDeref,
|
||||||
DoubleFree,
|
DoubleFree,
|
||||||
InvalidMemoryAccess,
|
InvalidMemoryAccess,
|
||||||
FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>),
|
|
||||||
InvalidFunctionPointer,
|
InvalidFunctionPointer,
|
||||||
InvalidBool,
|
InvalidBool,
|
||||||
InvalidDiscriminant(ScalarMaybeUndef),
|
InvalidDiscriminant(ScalarMaybeUndef),
|
||||||
|
@ -267,13 +284,11 @@ pub enum InterpError<'tcx, O> {
|
||||||
Unimplemented(String),
|
Unimplemented(String),
|
||||||
DerefFunctionPointer,
|
DerefFunctionPointer,
|
||||||
ExecuteMemory,
|
ExecuteMemory,
|
||||||
// asd
|
|
||||||
BoundsCheck { len: O, index: O },
|
BoundsCheck { len: O, index: O },
|
||||||
Overflow(mir::BinOp),
|
Overflow(mir::BinOp),
|
||||||
OverflowNeg,
|
OverflowNeg,
|
||||||
DivisionByZero,
|
DivisionByZero,
|
||||||
RemainderByZero,
|
RemainderByZero,
|
||||||
// asd
|
|
||||||
Intrinsic(String),
|
Intrinsic(String),
|
||||||
InvalidChar(u128),
|
InvalidChar(u128),
|
||||||
StackFrameLimitReached,
|
StackFrameLimitReached,
|
||||||
|
@ -284,29 +299,6 @@ pub enum InterpError<'tcx, O> {
|
||||||
required: Align,
|
required: Align,
|
||||||
has: Align,
|
has: Align,
|
||||||
},
|
},
|
||||||
MemoryLockViolation {
|
|
||||||
ptr: Pointer,
|
|
||||||
len: u64,
|
|
||||||
frame: usize,
|
|
||||||
access: AccessKind,
|
|
||||||
lock: Lock,
|
|
||||||
},
|
|
||||||
MemoryAcquireConflict {
|
|
||||||
ptr: Pointer,
|
|
||||||
len: u64,
|
|
||||||
kind: AccessKind,
|
|
||||||
lock: Lock,
|
|
||||||
},
|
|
||||||
InvalidMemoryLockRelease {
|
|
||||||
ptr: Pointer,
|
|
||||||
len: u64,
|
|
||||||
frame: usize,
|
|
||||||
lock: Lock,
|
|
||||||
},
|
|
||||||
DeallocatedLockedMemory {
|
|
||||||
ptr: Pointer,
|
|
||||||
lock: Lock,
|
|
||||||
},
|
|
||||||
ValidationFailure(String),
|
ValidationFailure(String),
|
||||||
CalledClosureAsFunction,
|
CalledClosureAsFunction,
|
||||||
VtableForArgumentlessMethod,
|
VtableForArgumentlessMethod,
|
||||||
|
@ -324,7 +316,7 @@ pub enum InterpError<'tcx, O> {
|
||||||
HeapAllocZeroBytes,
|
HeapAllocZeroBytes,
|
||||||
HeapAllocNonPowerOfTwoAlignment(u64),
|
HeapAllocNonPowerOfTwoAlignment(u64),
|
||||||
Unreachable,
|
Unreachable,
|
||||||
Panic(EvalErrorPanic<'tcx, O>),
|
Panic(EvalErrorPanic<O>),
|
||||||
ReadFromReturnPointer,
|
ReadFromReturnPointer,
|
||||||
PathNotFound(Vec<String>),
|
PathNotFound(Vec<String>),
|
||||||
UnimplementedTraitSelection,
|
UnimplementedTraitSelection,
|
||||||
|
@ -340,15 +332,6 @@ pub enum InterpError<'tcx, O> {
|
||||||
InfiniteLoop,
|
InfiniteLoop,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
|
||||||
pub enum EvalErrorPanic<'tcx, O> {
|
|
||||||
Panic,
|
|
||||||
BoundsCheck { len: O, index: O },
|
|
||||||
Overflow(mir::BinOp),
|
|
||||||
OverflowNeg,
|
|
||||||
DivisionByZero,
|
|
||||||
RemainderByZero,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
|
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
|
||||||
|
|
||||||
|
@ -549,8 +532,8 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
|
||||||
write!(f, "incorrect alloc info: expected size {} and align {}, \
|
write!(f, "incorrect alloc info: expected size {} and align {}, \
|
||||||
got size {} and align {}",
|
got size {} and align {}",
|
||||||
size.bytes(), align.bytes(), size2.bytes(), align2.bytes()),
|
size.bytes(), align.bytes(), size2.bytes(), align2.bytes()),
|
||||||
Panic { ref msg, line, col, ref file } =>
|
Panic { .. } =>
|
||||||
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
|
write!(f, "the evaluated program panicked"),
|
||||||
InvalidDiscriminant(val) =>
|
InvalidDiscriminant(val) =>
|
||||||
write!(f, "encountered invalid enum discriminant {}", val),
|
write!(f, "encountered invalid enum discriminant {}", val),
|
||||||
Exit(code) =>
|
Exit(code) =>
|
||||||
|
|
|
@ -12,7 +12,7 @@ mod pointer;
|
||||||
|
|
||||||
pub use self::error::{
|
pub use self::error::{
|
||||||
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
|
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
|
||||||
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
|
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, EvalErrorPanic
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};
|
pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};
|
||||||
|
|
|
@ -7,7 +7,7 @@ use rustc::ty;
|
||||||
use rustc::ty::layout::{LayoutOf, Primitive, Size};
|
use rustc::ty::layout::{LayoutOf, Primitive, Size};
|
||||||
use rustc::mir::BinOp;
|
use rustc::mir::BinOp;
|
||||||
use rustc::mir::interpret::{
|
use rustc::mir::interpret::{
|
||||||
InterpResult, InterpError, Scalar,
|
InterpResult, InterpError, Scalar, EvalErrorPanic,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -261,7 +261,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
let file = Symbol::intern(self.read_str(file_place)?);
|
let file = Symbol::intern(self.read_str(file_place)?);
|
||||||
let line = self.read_scalar(line.into())?.to_u32()?;
|
let line = self.read_scalar(line.into())?.to_u32()?;
|
||||||
let col = self.read_scalar(col.into())?.to_u32()?;
|
let col = self.read_scalar(col.into())?.to_u32()?;
|
||||||
return Err(InterpError::Panic { msg, file, line, col }.into());
|
return Err(InterpError::Panic(EvalErrorPanic::Panic { msg, file, line, col }).into());
|
||||||
} else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() {
|
} else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() {
|
||||||
assert!(args.len() == 2);
|
assert!(args.len() == 2);
|
||||||
// &'static str, &(&'static str, u32, u32)
|
// &'static str, &(&'static str, u32, u32)
|
||||||
|
@ -279,7 +279,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
let file = Symbol::intern(self.read_str(file_place)?);
|
let file = Symbol::intern(self.read_str(file_place)?);
|
||||||
let line = self.read_scalar(line.into())?.to_u32()?;
|
let line = self.read_scalar(line.into())?.to_u32()?;
|
||||||
let col = self.read_scalar(col.into())?.to_u32()?;
|
let col = self.read_scalar(col.into())?.to_u32()?;
|
||||||
return Err(InterpError::Panic { msg, file, line, col }.into());
|
return Err(InterpError::Panic(EvalErrorPanic::Panic { msg, file, line, col }).into());
|
||||||
} else {
|
} else {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue