about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-04-21 02:38:15 +0000
committerbors <bors@rust-lang.org>2019-04-21 02:38:15 +0000
commit9224be5fa39f6170f6e046342976efee5453a1ff (patch)
treeaab4571691ae59b5485b3e2994cca8560d789814
parentc3a71943545516557f40f93d30c1512f1f16ff64 (diff)
parent79b91b7cdddcb45d2909d950a2e47f3be522ef64 (diff)
downloadrust-9224be5fa39f6170f6e046342976efee5453a1ff.tar.gz
rust-9224be5fa39f6170f6e046342976efee5453a1ff.zip
Auto merge of #60116 - RalfJung:miri-exit, r=oli-obk
add Miri error variant for process exit

This is to support https://github.com/rust-lang/miri/pull/702

r? @oli-obk
-rw-r--r--src/librustc/mir/interpret/error.rs8
-rw-r--r--src/librustc_mir/transform/const_prop.rs1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index b9c4d312adb..5c6fc6f49f0 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -229,6 +229,10 @@ pub enum InterpError<'tcx, O> {
     /// match an existing variant.
     MachineError(String),
 
+    /// Not actually an interpreter error -- used to signal that execution has exited
+    /// with the given status code.  Used by Miri, but not by CTFE.
+    Exit(i32),
+
     FunctionAbiMismatch(Abi, Abi),
     FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
     FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>),
@@ -317,6 +321,8 @@ impl<'tcx, O> InterpError<'tcx, O> {
         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 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
                 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()),
         }
     }
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs
index e0ff71cbe52..b5bdc9e1c8c 100644
--- a/src/librustc_mir/transform/const_prop.rs
+++ b/src/librustc_mir/transform/const_prop.rs
@@ -148,6 +148,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
                 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(..)