]> git.lizzy.rs Git - rust.git/commitdiff
Don't duplicate body of try_validation.
authorjumbatm <jumbatm@gmail.com>
Thu, 23 Apr 2020 12:52:27 +0000 (22:52 +1000)
committerjumbatm <jumbatm@gmail.com>
Fri, 1 May 2020 11:52:43 +0000 (21:52 +1000)
src/librustc_mir/interpret/validity.rs

index 1e4c9367f6a6cd54b217a5c3b25ea551bffbae4e..42cdb1dc2a651a3318d40464312833b90aca06f7 100644 (file)
@@ -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)?,
         }