From 589f6a7dc66d88739485a1f9044ab29c166420a0 Mon Sep 17 00:00:00 2001 From: Saleem Jaffer Date: Thu, 18 Jul 2019 14:52:30 +0530 Subject: [PATCH] tries to refactor InterpError in mir --- src/librustc/mir/interpret/error.rs | 43 +++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index c8f42b1c604a..d5caa3c8ce44 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -247,6 +247,7 @@ pub enum InterpError<'tcx, O> { DanglingPointerDeref, DoubleFree, InvalidMemoryAccess, + FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>), InvalidFunctionPointer, InvalidBool, InvalidDiscriminant(ScalarMaybeUndef), @@ -266,11 +267,13 @@ pub enum InterpError<'tcx, O> { Unimplemented(String), DerefFunctionPointer, ExecuteMemory, + // asd BoundsCheck { len: O, index: O }, Overflow(mir::BinOp), OverflowNeg, DivisionByZero, RemainderByZero, + // asd Intrinsic(String), InvalidChar(u128), StackFrameLimitReached, @@ -281,6 +284,29 @@ pub enum InterpError<'tcx, O> { required: 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), CalledClosureAsFunction, VtableForArgumentlessMethod, @@ -298,12 +324,7 @@ pub enum InterpError<'tcx, O> { HeapAllocZeroBytes, HeapAllocNonPowerOfTwoAlignment(u64), Unreachable, - Panic { - msg: Symbol, - line: u32, - col: u32, - file: Symbol, - }, + Panic(EvalErrorPanic<'tcx, O>), ReadFromReturnPointer, PathNotFound(Vec), UnimplementedTraitSelection, @@ -319,6 +340,16 @@ pub enum InterpError<'tcx, O> { 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>; impl<'tcx, O> InterpError<'tcx, O> {