]> git.lizzy.rs Git - rust.git/commitdiff
add Miri error variant for process exit
authorRalf Jung <post@ralfj.de>
Fri, 19 Apr 2019 16:48:02 +0000 (18:48 +0200)
committerRalf Jung <post@ralfj.de>
Fri, 19 Apr 2019 16:48:02 +0000 (18:48 +0200)
src/librustc/mir/interpret/error.rs
src/librustc_mir/transform/const_prop.rs

index b9c4d312adb7b1ea09d8db0b3fc4a5c59c135672..cfc91a98e44f5522650cb2c9c9848c7426895ae4 100644 (file)
@@ -229,6 +229,10 @@ pub enum InterpError<'tcx, O> {
     /// match an existing variant.
     MachineError(String),
 
+    /// Not actually an interprer error -- used to signal that execution has exited
+    /// with the given status code.
+    Exit(i32),
+
     FunctionAbiMismatch(Abi, Abi),
     FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
     FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>),
@@ -317,6 +321,8 @@ pub fn description(&self) -> &str {
         use self::InterpError::*;
         match *self {
             MachineError(ref inner) => inner,
+            Exit(..) =>
+                "exited",
             FunctionAbiMismatch(..) | FunctionArgMismatch(..) | FunctionRetMismatch(..)
             | FunctionArgCountMismatch =>
                 "tried to call a function through a function pointer of incompatible type",
@@ -515,6 +521,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                 write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
             InvalidDiscriminant(val) =>
                 write!(f, "encountered invalid enum discriminant {}", val),
+            Exit(code) =>
+                write!(f, "exited with status code {}", code),
             _ => write!(f, "{}", self.description()),
         }
     }
index e0ff71cbe52f82bb3358dfe9610cf25b4f5caa0e..b5bdc9e1c8c6e61f9ce0e8736c145e483fa7fde5 100644 (file)
@@ -148,6 +148,7 @@ fn use_ecx<F, T>(
                 match diagnostic.error {
                     // don't report these, they make no sense in a const prop context
                     | MachineError(_)
+                    | Exit(_)
                     // at runtime these transformations might make sense
                     // FIXME: figure out the rules and start linting
                     | FunctionAbiMismatch(..)