@@ -229,6 +229,10 @@ pub enum InterpError<'tcx, O> {
229229 /// match an existing variant.
230230 MachineError ( String ) ,
231231
232+ /// Not actually an interprer error -- used to signal that execution has exited
233+ /// with the given status code.
234+ Exit ( i32 ) ,
235+
232236 FunctionAbiMismatch ( Abi , Abi ) ,
233237 FunctionArgMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
234238 FunctionRetMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
@@ -317,6 +321,8 @@ impl<'tcx, O> InterpError<'tcx, O> {
317321 use self :: InterpError :: * ;
318322 match * self {
319323 MachineError ( ref inner) => inner,
324+ Exit ( ..) =>
325+ "exited" ,
320326 FunctionAbiMismatch ( ..) | FunctionArgMismatch ( ..) | FunctionRetMismatch ( ..)
321327 | FunctionArgCountMismatch =>
322328 "tried to call a function through a function pointer of incompatible type" ,
@@ -515,6 +521,8 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
515521 write ! ( f, "the evaluated program panicked at '{}', {}:{}:{}" , msg, file, line, col) ,
516522 InvalidDiscriminant ( val) =>
517523 write ! ( f, "encountered invalid enum discriminant {}" , val) ,
524+ Exit ( code) =>
525+ write ! ( f, "exited with status code {}" , code) ,
518526 _ => write ! ( f, "{}" , self . description( ) ) ,
519527 }
520528 }
0 commit comments