@@ -190,7 +190,7 @@ impl<'a> Parser<'a> {
190
190
}
191
191
} ;
192
192
193
- if !self . should_continue_as_assoc_expr_FIXME ( & lhs) {
193
+ if !self . should_continue_as_assoc_expr ( & lhs) {
194
194
return Ok ( lhs) ;
195
195
}
196
196
@@ -381,9 +381,8 @@ impl<'a> Parser<'a> {
381
381
Ok ( lhs)
382
382
}
383
383
384
- #[ allow( non_snake_case) ]
385
- fn should_continue_as_assoc_expr_FIXME ( & mut self , lhs : & Expr ) -> bool {
386
- match ( self . expr_is_complete_FIXME ( lhs) , AssocOp :: from_token ( & self . token ) ) {
384
+ fn should_continue_as_assoc_expr ( & mut self , lhs : & Expr ) -> bool {
385
+ match ( self . expr_is_complete ( lhs) , AssocOp :: from_token ( & self . token ) ) {
387
386
// Semi-statement forms are odd:
388
387
// See https://github.com/rust-lang/rust/issues/29071
389
388
( true , None ) => false ,
@@ -483,10 +482,48 @@ impl<'a> Parser<'a> {
483
482
}
484
483
485
484
/// Checks if this expression is a successfully parsed statement.
486
- #[ allow( non_snake_case) ]
487
- fn expr_is_complete_FIXME ( & self , e : & Expr ) -> bool {
485
+ ///
486
+ /// This determines whether to continue parsing more of an expression in a
487
+ /// match arm (false) vs continue to the next arm (true).
488
+ ///
489
+ /// ```ignore (illustrative)
490
+ /// match ... {
491
+ /// // Is this calling $e as a function, or is it the start of a new arm
492
+ /// // with a tuple pattern?
493
+ /// _ => $e (
494
+ /// ^ )
495
+ ///
496
+ /// // Is this an Index operation, or new arm with a slice pattern?
497
+ /// _ => $e [
498
+ /// ^ ]
499
+ ///
500
+ /// // Is this a binary operator, or leading vert in a new arm? Same for
501
+ /// // other punctuation which can either be a binary operator in
502
+ /// // expression or unary operator in pattern, such as `&` and `-`.
503
+ /// _ => $e |
504
+ /// ^
505
+ /// }
506
+ /// ```
507
+ ///
508
+ /// If $e is something like `path::to` or `(…)`, continue parsing the same
509
+ /// arm.
510
+ ///
511
+ /// If $e is something like `{}` or `if … {}`, then terminate the current
512
+ /// arm and parse a new arm.
513
+ fn expr_is_complete ( & self , e : & Expr ) -> bool {
488
514
self . restrictions . contains ( Restrictions :: STMT_EXPR )
489
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
+ //
490
527
ExprKind :: MacCall ( _) => false ,
491
528
_ => !classify:: expr_requires_semi_to_be_stmt ( e) ,
492
529
}
@@ -992,7 +1029,7 @@ impl<'a> Parser<'a> {
992
1029
e = self . parse_dot_suffix_expr ( lo, e) ?;
993
1030
continue ;
994
1031
}
995
- if self . expr_is_complete_FIXME ( & e) {
1032
+ if self . expr_is_complete ( & e) {
996
1033
return Ok ( e) ;
997
1034
}
998
1035
e = match self . token . kind {
0 commit comments