Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #22755 from A4-Tacks/match-ast-guard
internal: match_ast macro supports guard
| -rw-r--r-- | crates/syntax/src/lib.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index ab24ed9231..614678536a 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -270,12 +270,12 @@ macro_rules! match_ast { (match $node:ident { $($tt:tt)* }) => { $crate::match_ast!(match ($node) { $($tt)* }) }; (match ($node:expr) { - $( $( $path:ident )::+ ($it:pat) => $res:expr, )* + $( $( $path:ident )::+ ($it:pat) $(if $guard:expr)? => $res:expr, )* _ => $catch_all:expr $(,)? }) => {{ #[allow(clippy::question_mark, reason = "if `$catch_all` is `return None` Clippy can mark this")] { - $( if let Some($it) = $($path::)+cast($node.clone()) { $res } else )* + $( if let Some($it) = $($path::)+cast($node.clone()) $(&& $guard)? { $res } else )* { $catch_all } } }}; |