]> git.lizzy.rs Git - rust.git/commitdiff
code review fixes
authorSaleem Jaffer <ssaleem1992@gmail.com>
Thu, 1 Aug 2019 04:19:01 +0000 (09:49 +0530)
committerSaleem Jaffer <ssaleem1992@gmail.com>
Thu, 1 Aug 2019 04:19:01 +0000 (09:49 +0530)
src/librustc/mir/interpret/mod.rs
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/transform/const_prop.rs

index 8feb04ffe88dbf37a10c9546337632817af9f240..f3ed4ffab7d0fc0a9846a58ac083bdb6479ca41d 100644 (file)
@@ -1,34 +1,14 @@
 //! 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)*) => {
@@ -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;
index 7ab99976b404b0081f344a34da0bea3a97ca302f..f10d7fb96511601cddbb4f79e60ec9fc0cbe3c26 100644 (file)
@@ -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())
     }
 }
 
index 164a268004d2d0a4bc558cff759280d33c0e1859..5783f53316c57580e61a9e08ebaa1aba47d4a54d 100644 (file)
@@ -259,12 +259,7 @@ fn use_ecx<F, T>(
                 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 @@ fn use_ecx<F, T>(
                             None,
                         );
                     }
+                    _ => {},
                 }
                 None
             },