about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjumbatm <jumbatm@gmail.com>2020-04-23 22:52:27 +1000
committerjumbatm <jumbatm@gmail.com>2020-05-01 21:52:43 +1000
commite66e37cbf1806f4e0b7a9e6935c8198b3a6c4b2f (patch)
treea64b21114cea862bd27ddd0d652db7d5ae82e0b5
parent326d38fa09cfdf9e611b8828604a7a05c7f55c85 (diff)
downloadrust-e66e37cbf1806f4e0b7a9e6935c8198b3a6c4b2f.tar.gz
rust-e66e37cbf1806f4e0b7a9e6935c8198b3a6c4b2f.zip
Don't duplicate body of try_validation.
-rw-r--r--src/librustc_mir/interpret/validity.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index 1e4c9367f6a..42cdb1dc2a6 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -39,12 +39,7 @@ macro_rules! throw_validation_failure {
 /// Returns a validation failure for any Err value of $e.
 macro_rules! try_validation {
     ($e:expr, $what:expr, $where:expr $(, $details:expr )?) => {{
-        match $e {
-            Ok(x) => x,
-            // We catch the error and turn it into a validation failure. We are okay with
-            // allocation here as this can only slow down builds that fail anyway.
-            Err(_) => throw_validation_failure!($what, $where $(, $details)?),
-        }
+        try_validation_pat!($e, _, $what, $where $(, $details )?)
     }};
 }
 /// Like try_validation, but will throw a validation error if any of the patterns in $p are
@@ -60,6 +55,8 @@ macro_rules! try_validation_pat {
     ($e:expr, $( $p:pat )|*, $what:expr, $where:expr $(, $details:expr )?) => {{
         match $e {
             Ok(x) => x,
+            // We catch the error and turn it into a validation failure. We are okay with
+            // allocation here as this can only slow down builds that fail anyway.
             $( Err($p) )|* if true => throw_validation_failure!($what, $where $(, $details)?),
             Err(e) =>  Err::<!, _>(e)?,
         }