@@ -511,22 +511,19 @@ impl<'a> Parser<'a> {
511
511
/// If $e is something like `{}` or `if … {}`, then terminate the current
512
512
/// arm and parse a new arm.
513
513
fn expr_is_complete ( & self , e : & Expr ) -> bool {
514
+ // Surprising special case: even though braced macro calls like
515
+ // `m! {}` normally introduce a statement boundary when found at
516
+ // the head of a statement, in match arms they do not terminate
517
+ // the arm.
518
+ //
519
+ // let _ = { m! {} () }; // macro call followed by unit
520
+ //
521
+ // match ... {
522
+ // _ => m! {} (), // macro that expands to a function, which is then called
523
+ // }
524
+ //
514
525
self . restrictions . contains ( Restrictions :: STMT_EXPR )
515
- && match e. kind {
516
- // Surprising special case: even though braced macro calls like
517
- // `m! {}` normally introduce a statement boundary when found at
518
- // the head of a statement, in match arms they do not terminate
519
- // the arm.
520
- //
521
- // let _ = { m! {} () }; // macro call followed by unit
522
- //
523
- // match ... {
524
- // _ => m! {} (), // macro that expands to a function, which is then called
525
- // }
526
- //
527
- ExprKind :: MacCall ( _) => false ,
528
- _ => !classify:: expr_requires_semi_to_be_stmt ( e) ,
529
- }
526
+ && !classify:: expr_requires_comma_to_be_match_arm ( e)
530
527
}
531
528
532
529
/// Parses `x..y`, `x..=y`, and `x..`/`x..=`.
@@ -3181,21 +3178,19 @@ impl<'a> Parser<'a> {
3181
3178
err
3182
3179
} ) ?;
3183
3180
3184
- let require_comma = match expr. kind {
3185
- // Special case: braced macro calls require comma in a match
3186
- // arm, even though they do not require semicolon in a
3187
- // statement.
3188
- //
3189
- // m! {} // okay without semicolon
3190
- //
3191
- // match ... {
3192
- // _ => m! {}, // requires comma
3193
- // _ => ...
3194
- // }
3195
- //
3196
- ExprKind :: MacCall ( _) => true ,
3197
- _ => classify:: expr_requires_semi_to_be_stmt ( & expr) ,
3198
- } && this. token != token:: CloseDelim ( Delimiter :: Brace ) ;
3181
+ // Special case: braced macro calls require comma in a match
3182
+ // arm, even though they do not require semicolon in a
3183
+ // statement.
3184
+ //
3185
+ // m! {} // okay without semicolon
3186
+ //
3187
+ // match ... {
3188
+ // _ => m! {}, // requires comma
3189
+ // _ => ...
3190
+ // }
3191
+ //
3192
+ let require_comma = classify:: expr_requires_comma_to_be_match_arm ( & expr)
3193
+ && this. token != token:: CloseDelim ( Delimiter :: Brace ) ;
3199
3194
3200
3195
if !require_comma {
3201
3196
arm_body = Some ( expr) ;
0 commit comments