about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2023-12-29 17:15:34 -0800
committerDavid Tolnay <dtolnay@gmail.com>2024-05-11 15:49:51 -0700
commit728e117166e1dab6f8333d61e1315172c558fce5 (patch)
tree7fe42456740cbfaf12164d1b1f9d9c671f026d3d /compiler/rustc_parse/src/parser/expr.rs
parent9dbe33d256e6b3919d2fc0a6561b78d2ed3c628c (diff)
downloadrust-728e117166e1dab6f8333d61e1315172c558fce5.tar.gz
rust-728e117166e1dab6f8333d61e1315172c558fce5.zip
Document MacCall special case in Parser::parse_arm
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 98b41013a2c..bb0873a814d 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);