Skip to content

Commit 589f6a7

Browse files
committed
tries to refactor InterpError in mir
1 parent efb7457 commit 589f6a7

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

src/librustc/mir/interpret/error.rs

+37-6
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ pub enum InterpError<'tcx, O> {
247247
DanglingPointerDeref,
248248
DoubleFree,
249249
InvalidMemoryAccess,
250+
FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>),
250251
InvalidFunctionPointer,
251252
InvalidBool,
252253
InvalidDiscriminant(ScalarMaybeUndef),
@@ -266,11 +267,13 @@ pub enum InterpError<'tcx, O> {
266267
Unimplemented(String),
267268
DerefFunctionPointer,
268269
ExecuteMemory,
270+
// asd
269271
BoundsCheck { len: O, index: O },
270272
Overflow(mir::BinOp),
271273
OverflowNeg,
272274
DivisionByZero,
273275
RemainderByZero,
276+
// asd
274277
Intrinsic(String),
275278
InvalidChar(u128),
276279
StackFrameLimitReached,
@@ -281,6 +284,29 @@ pub enum InterpError<'tcx, O> {
281284
required: Align,
282285
has: Align,
283286
},
287+
MemoryLockViolation {
288+
ptr: Pointer,
289+
len: u64,
290+
frame: usize,
291+
access: AccessKind,
292+
lock: Lock,
293+
},
294+
MemoryAcquireConflict {
295+
ptr: Pointer,
296+
len: u64,
297+
kind: AccessKind,
298+
lock: Lock,
299+
},
300+
InvalidMemoryLockRelease {
301+
ptr: Pointer,
302+
len: u64,
303+
frame: usize,
304+
lock: Lock,
305+
},
306+
DeallocatedLockedMemory {
307+
ptr: Pointer,
308+
lock: Lock,
309+
},
284310
ValidationFailure(String),
285311
CalledClosureAsFunction,
286312
VtableForArgumentlessMethod,
@@ -298,12 +324,7 @@ pub enum InterpError<'tcx, O> {
298324
HeapAllocZeroBytes,
299325
HeapAllocNonPowerOfTwoAlignment(u64),
300326
Unreachable,
301-
Panic {
302-
msg: Symbol,
303-
line: u32,
304-
col: u32,
305-
file: Symbol,
306-
},
327+
Panic(EvalErrorPanic<'tcx, O>),
307328
ReadFromReturnPointer,
308329
PathNotFound(Vec<String>),
309330
UnimplementedTraitSelection,
@@ -319,6 +340,16 @@ pub enum InterpError<'tcx, O> {
319340
InfiniteLoop,
320341
}
321342

343+
#[derive(Clone, RustcEncodable, RustcDecodable)]
344+
pub enum EvalErrorPanic<'tcx, O> {
345+
Panic,
346+
BoundsCheck { len: O, index: O },
347+
Overflow(mir::BinOp),
348+
OverflowNeg,
349+
DivisionByZero,
350+
RemainderByZero,
351+
}
352+
322353
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
323354

324355
impl<'tcx, O> InterpError<'tcx, O> {

0 commit comments

Comments
 (0)