about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-03-09 10:45:20 +0100
committerRalf Jung <post@ralfj.de>2020-03-09 11:06:55 +0100
commit8a8870fbae1bf601ac4d29d6c0c407a352caea57 (patch)
tree1c81730e86001cb72e688defa461956759007ba0
parent48975946565e9a0adedb39a308db2fd2eeaa2839 (diff)
downloadrust-8a8870fbae1bf601ac4d29d6c0c407a352caea57.tar.gz
rust-8a8870fbae1bf601ac4d29d6c0c407a352caea57.zip
miri: add machine hook for Abort terminator
-rw-r--r--src/librustc_mir/interpret/machine.rs5
-rw-r--r--src/librustc_mir/interpret/terminator.rs9
2 files changed, 12 insertions, 2 deletions
diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs
index 6615cc608fb..64a34fc7dd9 100644
--- a/src/librustc_mir/interpret/machine.rs
+++ b/src/librustc_mir/interpret/machine.rs
@@ -170,6 +170,11 @@ pub trait Machine<'mir, 'tcx>: Sized {
         unwind: Option<mir::BasicBlock>,
     ) -> InterpResult<'tcx>;
 
+    /// Called to evaluate `Abort` MIR terminator.
+    fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
+        throw_unsup_format!("aborting execution is not supported");
+    }
+
     /// Called for all binary operations where the LHS has pointer type.
     ///
     /// Returns a (value, overflowed) pair if the operation succeeded
diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs
index 85fd502c69c..95d5276565f 100644
--- a/src/librustc_mir/interpret/terminator.rs
+++ b/src/librustc_mir/interpret/terminator.rs
@@ -99,6 +99,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                 }
             }
 
+            Abort => {
+                M::abort(self)?;
+            }
+
             // When we encounter Resume, we've finished unwinding
             // cleanup for the current stack frame. We pop it in order
             // to continue unwinding the next frame
@@ -118,8 +122,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             | FalseEdges { .. }
             | FalseUnwind { .. }
             | Yield { .. }
-            | GeneratorDrop
-            | Abort => bug!("{:#?} should have been eliminated by MIR pass", terminator.kind),
+            | GeneratorDrop => {
+                bug!("{:#?} should have been eliminated by MIR pass", terminator.kind)
+            }
         }
 
         Ok(())