about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-23 19:04:52 +0100
committerGitHub <noreply@github.com>2020-03-23 19:04:52 +0100
commit8cb3daa368f6b8aaa790fa3da6c8330222cc49a6 (patch)
tree92555e870fcfea66ce25557ab77936cdf40d521c
parent560eae31c549238b0a501c9800ffefebaf5e0b5a (diff)
parent4803f2946e3de024087d2c847b99ca7faf896135 (diff)
downloadrust-8cb3daa368f6b8aaa790fa3da6c8330222cc49a6.tar.gz
rust-8cb3daa368f6b8aaa790fa3da6c8330222cc49a6.zip
Rollup merge of #70299 - RalfJung:err_machine_stop, r=oli-obk
add err_machine_stop macro

We have that for all other error kinds, but here I somehow forgot it.

r? @oli-obk
-rw-r--r--src/librustc/mir/interpret/mod.rs11
-rw-r--r--src/librustc_mir/const_eval/error.rs4
2 files changed, 10 insertions, 5 deletions
diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs
index dfe5adb1bbf..a2f7a2d847e 100644
--- a/src/librustc/mir/interpret/mod.rs
+++ b/src/librustc/mir/interpret/mod.rs
@@ -46,6 +46,13 @@ macro_rules! err_exhaust {
     };
 }
 
+#[macro_export]
+macro_rules! err_machine_stop {
+    ($($tt:tt)*) => {
+        $crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*))
+    };
+}
+
 // In the `throw_*` macros, avoid `return` to make them work with `try {}`.
 #[macro_export]
 macro_rules! throw_unsup {
@@ -79,9 +86,7 @@ macro_rules! throw_exhaust {
 
 #[macro_export]
 macro_rules! throw_machine_stop {
-    ($($tt:tt)*) => {
-        Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
-    };
+    ($($tt:tt)*) => { Err::<!, _>(err_machine_stop!($($tt)*))? };
 }
 
 mod allocation;
diff --git a/src/librustc_mir/const_eval/error.rs b/src/librustc_mir/const_eval/error.rs
index 63ad9ec8cae..dc23eba643e 100644
--- a/src/librustc_mir/const_eval/error.rs
+++ b/src/librustc_mir/const_eval/error.rs
@@ -5,7 +5,7 @@ use rustc::mir::AssertKind;
 use rustc_span::Symbol;
 
 use super::InterpCx;
-use crate::interpret::{ConstEvalErr, InterpError, InterpErrorInfo, Machine};
+use crate::interpret::{ConstEvalErr, InterpErrorInfo, Machine};
 
 /// The CTFE machine has some custom error kinds.
 #[derive(Clone, Debug)]
@@ -21,7 +21,7 @@ pub enum ConstEvalErrKind {
 // handle these.
 impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind {
     fn into(self) -> InterpErrorInfo<'tcx> {
-        InterpError::MachineStop(Box::new(self.to_string())).into()
+        err_machine_stop!(self.to_string()).into()
     }
 }