@@ -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
@@ -383,9 +383,8 @@ impl<'a> Parser<'a> {
383
383
Ok ( lhs)
384
384
}
385
385
386
- #[ allow( non_snake_case) ]
387
- fn should_continue_as_assoc_expr_FIXME ( & mut self , lhs : & Expr ) -> bool {
388
- match ( self . expr_is_complete_FIXME ( lhs) , AssocOp :: from_token ( & self . token ) ) {
386
+ fn should_continue_as_assoc_expr ( & mut self , lhs : & Expr ) -> bool {
387
+ match ( self . expr_is_complete ( lhs) , AssocOp :: from_token ( & self . token ) ) {
389
388
// Semi-statement forms are odd:
390
389
// See https://github.com/rust-lang/rust/issues/29071
391
390
( true , None ) => false ,
@@ -497,10 +496,48 @@ impl<'a> Parser<'a> {
497
496
}
498
497
499
498
/// Checks if this expression is a successfully parsed statement.
500
- #[ allow( non_snake_case) ]
501
- fn expr_is_complete_FIXME ( & self , e : & Expr ) -> bool {
499
+ ///
500
+ /// This determines whether to continue parsing more of an expression in a
501
+ /// match arm (false) vs continue to the next arm (true).
502
+ ///
503
+ /// ```ignore (illustrative)
504
+ /// match ... {
505
+ /// // Is this calling $e as a function, or is it the start of a new arm
506
+ /// // with a tuple pattern?
507
+ /// _ => $e (
508
+ /// ^ )
509
+ ///
510
+ /// // Is this an Index operation, or new arm with a slice pattern?
511
+ /// _ => $e [
512
+ /// ^ ]
513
+ ///
514
+ /// // Is this a binary operator, or leading vert in a new arm? Same for
515
+ /// // other punctuation which can either be a binary operator in
516
+ /// // expression or unary operator in pattern, such as `&` and `-`.
517
+ /// _ => $e |
518
+ /// ^
519
+ /// }
520
+ /// ```
521
+ ///
522
+ /// If $e is something like `path::to` or `(…)`, continue parsing the same
523
+ /// arm.
524
+ ///
525
+ /// If $e is something like `{}` or `if … {}`, then terminate the current
526
+ /// arm and parse a new arm.
527
+ fn expr_is_complete ( & self , e : & Expr ) -> bool {
502
528
self . restrictions . contains ( Restrictions :: STMT_EXPR )
503
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
+ //
504
541
ExprKind :: MacCall ( _) => false ,
505
542
_ => !classify:: expr_requires_semi_to_be_stmt ( e) ,
506
543
}
@@ -1014,7 +1051,7 @@ impl<'a> Parser<'a> {
1014
1051
e = self . parse_dot_suffix_expr ( lo, e) ?;
1015
1052
continue ;
1016
1053
}
1017
- if self . expr_is_complete_FIXME ( & e) {
1054
+ if self . expr_is_complete ( & e) {
1018
1055
return Ok ( e) ;
1019
1056
}
1020
1057
e = match self . token . kind {
0 commit comments