@@ -284,11 +284,6 @@ pub enum InterpError<'tcx, O> {
284
284
Unimplemented ( String ) ,
285
285
DerefFunctionPointer ,
286
286
ExecuteMemory ,
287
- BoundsCheck { len : O , index : O } ,
288
- Overflow ( mir:: BinOp ) ,
289
- OverflowNeg ,
290
- DivisionByZero ,
291
- RemainderByZero ,
292
287
Intrinsic ( String ) ,
293
288
InvalidChar ( u128 ) ,
294
289
StackFrameLimitReached ,
@@ -332,7 +327,6 @@ pub enum InterpError<'tcx, O> {
332
327
InfiniteLoop ,
333
328
}
334
329
335
-
336
330
pub type InterpResult < ' tcx , T = ( ) > = Result < T , InterpErrorInfo < ' tcx > > ;
337
331
338
332
impl < ' tcx , O > InterpError < ' tcx , O > {
@@ -383,8 +377,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
383
377
"tried to dereference a function pointer" ,
384
378
ExecuteMemory =>
385
379
"tried to treat a memory pointer as a function pointer" ,
386
- BoundsCheck { ..} =>
387
- "array index out of bounds" ,
388
380
Intrinsic ( ..) =>
389
381
"intrinsic failed" ,
390
382
NoMirFor ( ..) =>
@@ -436,8 +428,32 @@ impl<'tcx, O> InterpError<'tcx, O> {
436
428
two",
437
429
Unreachable =>
438
430
"entered unreachable code" ,
439
- Panic { .. } =>
431
+ Panic ( EvalErrorPanic :: Panic { .. } ) =>
440
432
"the evaluated program panicked" ,
433
+ Panic ( EvalErrorPanic :: BoundsCheck { ..} ) =>
434
+ "array index out of bounds" ,
435
+ Panic ( EvalErrorPanic :: Overflow ( mir:: BinOp :: Add ) ) =>
436
+ "attempt to add with overflow" ,
437
+ Panic ( EvalErrorPanic :: Overflow ( mir:: BinOp :: Sub ) ) =>
438
+ "attempt to subtract with overflow" ,
439
+ Panic ( EvalErrorPanic :: Overflow ( mir:: BinOp :: Mul ) ) =>
440
+ "attempt to multiply with overflow" ,
441
+ Panic ( EvalErrorPanic :: Overflow ( mir:: BinOp :: Div ) ) =>
442
+ "attempt to divide with overflow" ,
443
+ Panic ( EvalErrorPanic :: Overflow ( mir:: BinOp :: Rem ) ) =>
444
+ "attempt to calculate the remainder with overflow" ,
445
+ Panic ( EvalErrorPanic :: OverflowNeg ) =>
446
+ "attempt to negate with overflow" ,
447
+ Panic ( EvalErrorPanic :: Overflow ( mir:: BinOp :: Shr ) ) =>
448
+ "attempt to shift right with overflow" ,
449
+ Panic ( EvalErrorPanic :: Overflow ( mir:: BinOp :: Shl ) ) =>
450
+ "attempt to shift left with overflow" ,
451
+ Panic ( EvalErrorPanic :: Overflow ( op) ) =>
452
+ bug ! ( "{:?} cannot overflow" , op) ,
453
+ Panic ( EvalErrorPanic :: DivisionByZero ) =>
454
+ "attempt to divide by zero" ,
455
+ Panic ( EvalErrorPanic :: RemainderByZero ) =>
456
+ "attempt to calculate the remainder with a divisor of zero" ,
441
457
ReadFromReturnPointer =>
442
458
"tried to read from the return pointer" ,
443
459
PathNotFound ( _) =>
@@ -450,17 +466,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
450
466
"encountered overly generic constant" ,
451
467
ReferencedConstant =>
452
468
"referenced constant has errors" ,
453
- Overflow ( mir:: BinOp :: Add ) => "attempt to add with overflow" ,
454
- Overflow ( mir:: BinOp :: Sub ) => "attempt to subtract with overflow" ,
455
- Overflow ( mir:: BinOp :: Mul ) => "attempt to multiply with overflow" ,
456
- Overflow ( mir:: BinOp :: Div ) => "attempt to divide with overflow" ,
457
- Overflow ( mir:: BinOp :: Rem ) => "attempt to calculate the remainder with overflow" ,
458
- OverflowNeg => "attempt to negate with overflow" ,
459
- Overflow ( mir:: BinOp :: Shr ) => "attempt to shift right with overflow" ,
460
- Overflow ( mir:: BinOp :: Shl ) => "attempt to shift left with overflow" ,
461
- Overflow ( op) => bug ! ( "{:?} cannot overflow" , op) ,
462
- DivisionByZero => "attempt to divide by zero" ,
463
- RemainderByZero => "attempt to calculate the remainder with a divisor of zero" ,
464
469
GeneratorResumedAfterReturn => "generator resumed after completion" ,
465
470
GeneratorResumedAfterPanic => "generator resumed after panicking" ,
466
471
InfiniteLoop =>
@@ -507,8 +512,6 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
507
512
callee_ty, caller_ty) ,
508
513
FunctionArgCountMismatch =>
509
514
write ! ( f, "tried to call a function with incorrect number of arguments" ) ,
510
- BoundsCheck { ref len, ref index } =>
511
- write ! ( f, "index out of bounds: the len is {:?} but the index is {:?}" , len, index) ,
512
515
ReallocatedWrongMemoryKind ( ref old, ref new) =>
513
516
write ! ( f, "tried to reallocate memory from {} to {}" , old, new) ,
514
517
DeallocatedWrongMemoryKind ( ref old, ref new) =>
@@ -532,8 +535,10 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
532
535
write ! ( f, "incorrect alloc info: expected size {} and align {}, \
533
536
got size {} and align {}",
534
537
size. bytes( ) , align. bytes( ) , size2. bytes( ) , align2. bytes( ) ) ,
535
- Panic { .. } =>
536
- write ! ( f, "the evaluated program panicked" ) ,
538
+ Panic ( EvalErrorPanic :: Panic { ref msg, line, col, ref file } ) =>
539
+ write ! ( f, "the evaluated program panicked at '{}', {}:{}:{}" , msg, file, line, col) ,
540
+ Panic ( EvalErrorPanic :: BoundsCheck { ref len, ref index } ) =>
541
+ write ! ( f, "index out of bounds: the len is {:?} but the index is {:?}" , len, index) ,
537
542
InvalidDiscriminant ( val) =>
538
543
write ! ( f, "encountered invalid enum discriminant {}" , val) ,
539
544
Exit ( code) =>
0 commit comments