From 728e117166e1dab6f8333d61e1315172c558fce5 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 29 Dec 2023 17:15:34 -0800 Subject: [PATCH] Document MacCall special case in Parser::parse_arm --- compiler/rustc_parse/src/parser/expr.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 98b41013a2c65..bb0873a814dfa 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3182,6 +3182,17 @@ impl<'a> Parser<'a> { })?; let require_comma = match expr.kind { + // Special case: braced macro calls require comma in a match + // arm, even though they do not require semicolon in a + // statement. + // + // m! {} // okay without semicolon + // + // match ... { + // _ => m! {}, // requires comma + // _ => ... + // } + // ExprKind::MacCall(_) => true, _ => classify::expr_requires_semi_to_be_stmt(&expr), } && this.token != token::CloseDelim(Delimiter::Brace);