about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/mir/interpret/mod.rs71
-rw-r--r--src/librustc_mir/interpret/eval_context.rs4
-rw-r--r--src/librustc_mir/transform/const_prop.rs8
3 files changed, 43 insertions, 40 deletions
diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs
index 8feb04ffe88..f3ed4ffab7d 100644
--- a/src/librustc/mir/interpret/mod.rs
+++ b/src/librustc/mir/interpret/mod.rs
@@ -1,35 +1,15 @@
 //! An interpreter for MIR used in CTFE and by miri
 
 #[macro_export]
-macro_rules! throw_unsup {
-    ($($tt:tt)*) => { return Err(err_unsup!($($tt)*).into()) };
-}
-
-#[macro_export]
-macro_rules! throw_inval {
-    ($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
-}
-
-#[macro_export]
-macro_rules! throw_ub {
+macro_rules! err_unsup {
     ($($tt:tt)*) => {
-        return Err($crate::mir::interpret::InterpError::UndefinedBehaviour(
-            $crate::mir::interpret::UndefinedBehaviourInfo::$($tt)*
-        ).into())
+        $crate::mir::interpret::InterpError::Unsupported(
+            $crate::mir::interpret::UnsupportedOpInfo::$($tt)*
+        )
     };
 }
 
 #[macro_export]
-macro_rules! throw_panic {
-    ($($tt:tt)*) => { return Err(err_panic!($($tt)*).into()) };
-}
-
-#[macro_export]
-macro_rules! throw_exhaust {
-    ($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
-}
-
-#[macro_export]
 macro_rules! err_inval {
     ($($tt:tt)*) => {
         $crate::mir::interpret::InterpError::InvalidProgram(
@@ -39,10 +19,19 @@ macro_rules! err_inval {
 }
 
 #[macro_export]
-macro_rules! err_unsup {
+macro_rules! err_ub {
     ($($tt:tt)*) => {
-        $crate::mir::interpret::InterpError::Unsupported(
-            $crate::mir::interpret::UnsupportedOpInfo::$($tt)*
+        $crate::mir::interpret::InterpError::UndefinedBehaviour(
+            $crate::mir::interpret::UndefinedBehaviourInfo::$($tt)*
+        )
+    };
+}
+
+#[macro_export]
+macro_rules! err_panic {
+    ($($tt:tt)*) => {
+        $crate::mir::interpret::InterpError::Panic(
+            $crate::mir::interpret::PanicInfo::$($tt)*
         )
     };
 }
@@ -57,14 +46,34 @@ macro_rules! err_exhaust {
 }
 
 #[macro_export]
-macro_rules! err_panic {
+macro_rules! throw_unsup {
+    ($($tt:tt)*) => { return Err(err_unsup!($($tt)*).into()) };
+}
+
+#[macro_export]
+macro_rules! throw_inval {
+    ($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
+}
+
+#[macro_export]
+macro_rules! throw_ub {
     ($($tt:tt)*) => {
-        $crate::mir::interpret::InterpError::Panic(
-            $crate::mir::interpret::PanicInfo::$($tt)*
-        )
+        return Err($crate::mir::interpret::InterpError::UndefinedBehaviour(
+            $crate::mir::interpret::UndefinedBehaviourInfo::$($tt)*
+        ).into())
     };
 }
 
+#[macro_export]
+macro_rules! throw_panic {
+    ($($tt:tt)*) => { return Err(err_panic!($($tt)*).into()) };
+}
+
+#[macro_export]
+macro_rules! throw_exhaust {
+    ($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
+}
+
 mod error;
 mod value;
 mod allocation;
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 7ab99976b40..f10d7fb9651 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -191,9 +191,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> {
     fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
         self.tcx
             .layout_of(self.param_env.and(ty))
-            .map_err(|layout| {
-                err_inval!(Layout(layout)).into()
-            })
+            .map_err(|layout| err_inval!(Layout(layout)).into())
     }
 }
 
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs
index 164a268004d..5783f53316c 100644
--- a/src/librustc_mir/transform/const_prop.rs
+++ b/src/librustc_mir/transform/const_prop.rs
@@ -259,12 +259,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
                 use rustc::mir::interpret::InterpError::*;
                 match diagnostic.error {
                     Exit(_) => bug!("the CTFE program cannot exit"),
-                    | Unsupported(_) => {},
-                    | UndefinedBehaviour(_) => {},
-                    | InvalidProgram(_) => {},
-                    | ResourceExhaustion(_) => {},
-                    | Panic(_)
-                    => {
+                    Panic(_) => {
                         diagnostic.report_as_lint(
                             self.ecx.tcx,
                             "this expression will panic at runtime",
@@ -272,6 +267,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
                             None,
                         );
                     }
+                    _ => {},
                 }
                 None
             },