@@ -284,11 +284,6 @@ pub enum InterpError<'tcx, O> {
284284 Unimplemented ( String ) ,
285285 DerefFunctionPointer ,
286286 ExecuteMemory ,
287- BoundsCheck { len : O , index : O } ,
288- Overflow ( mir:: BinOp ) ,
289- OverflowNeg ,
290- DivisionByZero ,
291- RemainderByZero ,
292287 Intrinsic ( String ) ,
293288 InvalidChar ( u128 ) ,
294289 StackFrameLimitReached ,
@@ -332,7 +327,6 @@ pub enum InterpError<'tcx, O> {
332327 InfiniteLoop ,
333328}
334329
335-
336330pub type InterpResult < ' tcx , T = ( ) > = Result < T , InterpErrorInfo < ' tcx > > ;
337331
338332impl < ' tcx , O > InterpError < ' tcx , O > {
@@ -383,8 +377,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
383377 "tried to dereference a function pointer" ,
384378 ExecuteMemory =>
385379 "tried to treat a memory pointer as a function pointer" ,
386- BoundsCheck { ..} =>
387- "array index out of bounds" ,
388380 Intrinsic ( ..) =>
389381 "intrinsic failed" ,
390382 NoMirFor ( ..) =>
@@ -436,8 +428,32 @@ impl<'tcx, O> InterpError<'tcx, O> {
436428 two",
437429 Unreachable =>
438430 "entered unreachable code" ,
439- Panic { .. } =>
431+ Panic ( EvalErrorPanic :: Panic { .. } ) =>
440432 "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" ,
441457 ReadFromReturnPointer =>
442458 "tried to read from the return pointer" ,
443459 PathNotFound ( _) =>
@@ -450,17 +466,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
450466 "encountered overly generic constant" ,
451467 ReferencedConstant =>
452468 "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" ,
464469 GeneratorResumedAfterReturn => "generator resumed after completion" ,
465470 GeneratorResumedAfterPanic => "generator resumed after panicking" ,
466471 InfiniteLoop =>
@@ -507,8 +512,6 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
507512 callee_ty, caller_ty) ,
508513 FunctionArgCountMismatch =>
509514 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) ,
512515 ReallocatedWrongMemoryKind ( ref old, ref new) =>
513516 write ! ( f, "tried to reallocate memory from {} to {}" , old, new) ,
514517 DeallocatedWrongMemoryKind ( ref old, ref new) =>
@@ -532,8 +535,10 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
532535 write ! ( f, "incorrect alloc info: expected size {} and align {}, \
533536 got size {} and align {}",
534537 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) ,
537542 InvalidDiscriminant ( val) =>
538543 write ! ( f, "encountered invalid enum discriminant {}" , val) ,
539544 Exit ( code) =>
0 commit comments