@@ -525,22 +525,19 @@ impl<'a> Parser<'a> {
525
525
/// If $e is something like `{}` or `if … {}`, then terminate the current
526
526
/// arm and parse a new arm.
527
527
fn expr_is_complete ( & self , e : & Expr ) -> bool {
528
+ // Surprising special case: even though braced macro calls like
529
+ // `m! {}` normally introduce a statement boundary when found at
530
+ // the head of a statement, in match arms they do not terminate
531
+ // the arm.
532
+ //
533
+ // let _ = { m! {} () }; // macro call followed by unit
534
+ //
535
+ // match ... {
536
+ // _ => m! {} (), // macro that expands to a function, which is then called
537
+ // }
538
+ //
528
539
self . restrictions . contains ( Restrictions :: STMT_EXPR )
529
- && match e. kind {
530
- // Surprising special case: even though braced macro calls like
531
- // `m! {}` normally introduce a statement boundary when found at
532
- // the head of a statement, in match arms they do not terminate
533
- // the arm.
534
- //
535
- // let _ = { m! {} () }; // macro call followed by unit
536
- //
537
- // match ... {
538
- // _ => m! {} (), // macro that expands to a function, which is then called
539
- // }
540
- //
541
- ExprKind :: MacCall ( _) => false ,
542
- _ => !classify:: expr_requires_semi_to_be_stmt ( e) ,
543
- }
540
+ && !classify:: expr_requires_comma_to_be_match_arm ( e)
544
541
}
545
542
546
543
/// Parses `x..y`, `x..=y`, and `x..`/`x..=`.
@@ -3203,21 +3200,19 @@ impl<'a> Parser<'a> {
3203
3200
err
3204
3201
} ) ?;
3205
3202
3206
- let require_comma = match expr. kind {
3207
- // Special case: braced macro calls require comma in a match
3208
- // arm, even though they do not require semicolon in a
3209
- // statement.
3210
- //
3211
- // m! {} // okay without semicolon
3212
- //
3213
- // match ... {
3214
- // _ => m! {}, // requires comma
3215
- // _ => ...
3216
- // }
3217
- //
3218
- ExprKind :: MacCall ( _) => true ,
3219
- _ => classify:: expr_requires_semi_to_be_stmt ( & expr) ,
3220
- } && this. token != token:: CloseDelim ( Delimiter :: Brace ) ;
3203
+ // Special case: braced macro calls require comma in a match
3204
+ // arm, even though they do not require semicolon in a
3205
+ // statement.
3206
+ //
3207
+ // m! {} // okay without semicolon
3208
+ //
3209
+ // match ... {
3210
+ // _ => m! {}, // requires comma
3211
+ // _ => ...
3212
+ // }
3213
+ //
3214
+ let require_comma = classify:: expr_requires_comma_to_be_match_arm ( & expr)
3215
+ && this. token != token:: CloseDelim ( Delimiter :: Brace ) ;
3221
3216
3222
3217
if !require_comma {
3223
3218
arm_body = Some ( expr) ;
0 commit comments