Skip to content

Commit 9edb92e

Browse files
Merge pull request rust-lang#22755 from A4-Tacks/match-ast-guard
internal: match_ast macro supports guard
2 parents 888b2b3 + 3027de4 commit 9edb92e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

crates/syntax/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ macro_rules! match_ast {
270270
(match $node:ident { $($tt:tt)* }) => { $crate::match_ast!(match ($node) { $($tt)* }) };
271271

272272
(match ($node:expr) {
273-
$( $( $path:ident )::+ ($it:pat) => $res:expr, )*
273+
$( $( $path:ident )::+ ($it:pat) $(if $guard:expr)? => $res:expr, )*
274274
_ => $catch_all:expr $(,)?
275275
}) => {{
276276
#[allow(clippy::question_mark, reason = "if `$catch_all` is `return None` Clippy can mark this")]
277277
{
278-
$( if let Some($it) = $($path::)+cast($node.clone()) { $res } else )*
278+
$( if let Some($it) = $($path::)+cast($node.clone()) $(&& $guard)? { $res } else )*
279279
{ $catch_all }
280280
}
281281
}};

0 commit comments

Comments
 (0)