]> git.lizzy.rs Git - rust.git/commitdiff
tries to refactor InterpError in mir
authorSaleem Jaffer <ssaleem1992@gmail.com>
Thu, 18 Jul 2019 09:22:30 +0000 (14:52 +0530)
committerSaleem Jaffer <ssaleem1992@gmail.com>
Thu, 18 Jul 2019 09:22:30 +0000 (14:52 +0530)
src/librustc/mir/interpret/error.rs

index c8f42b1c604a587b2315e135ae6b51b6eb0d0676..d5caa3c8ce442ab2578de93acad00f6ae5b4ad81 100644 (file)
@@ -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<String>),
     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<T, InterpErrorInfo<'tcx>>;
 
 impl<'tcx, O> InterpError<'tcx, O> {