@@ -191,7 +191,7 @@ impl<'a> Parser<'a> {
191
191
}
192
192
} ;
193
193
194
- if !self . should_continue_as_assoc_expr_FIXME ( & lhs) {
194
+ if !self . should_continue_as_assoc_expr ( & lhs) {
195
195
return Ok ( lhs) ;
196
196
}
197
197
@@ -382,9 +382,8 @@ impl<'a> Parser<'a> {
382
382
Ok ( lhs)
383
383
}
384
384
385
- #[ allow( non_snake_case) ]
386
- fn should_continue_as_assoc_expr_FIXME ( & mut self , lhs : & Expr ) -> bool {
387
- match ( self . expr_is_complete_FIXME ( lhs) , AssocOp :: from_token ( & self . token ) ) {
385
+ fn should_continue_as_assoc_expr ( & mut self , lhs : & Expr ) -> bool {
386
+ match ( self . expr_is_complete ( lhs) , AssocOp :: from_token ( & self . token ) ) {
388
387
// Semi-statement forms are odd:
389
388
// See https://github.com/rust-lang/rust/issues/29071
390
389
( true , None ) => false ,
@@ -469,10 +468,48 @@ impl<'a> Parser<'a> {
469
468
}
470
469
471
470
/// Checks if this expression is a successfully parsed statement.
472
- #[ allow( non_snake_case) ]
473
- fn expr_is_complete_FIXME ( & self , e : & Expr ) -> bool {
471
+ ///
472
+ /// This determines whether to continue parsing more of an expression in a
473
+ /// match arm (false) vs continue to the next arm (true).
474
+ ///
475
+ /// ```ignore (illustrative)
476
+ /// match ... {
477
+ /// // Is this calling $e as a function, or is it the start of a new arm
478
+ /// // with a tuple pattern?
479
+ /// _ => $e (
480
+ /// ^ )
481
+ ///
482
+ /// // Is this an Index operation, or new arm with a slice pattern?
483
+ /// _ => $e [
484
+ /// ^ ]
485
+ ///
486
+ /// // Is this a binary operator, or leading vert in a new arm? Same for
487
+ /// // other punctuation which can either be a binary operator in
488
+ /// // expression or unary operator in pattern, such as `&` and `-`.
489
+ /// _ => $e |
490
+ /// ^
491
+ /// }
492
+ /// ```
493
+ ///
494
+ /// If $e is something like `path::to` or `(…)`, continue parsing the same
495
+ /// arm.
496
+ ///
497
+ /// If $e is something like `{}` or `if … {}`, then terminate the current
498
+ /// arm and parse a new arm.
499
+ fn expr_is_complete ( & self , e : & Expr ) -> bool {
474
500
self . restrictions . contains ( Restrictions :: STMT_EXPR )
475
501
&& match e. kind {
502
+ // Surprising special case: even though braced macro calls like
503
+ // `m! {}` normally introduce a statement boundary when found at
504
+ // the head of a statement, in match arms they do not terminate
505
+ // the arm.
506
+ //
507
+ // let _ = { m! {} () }; // macro call followed by unit
508
+ //
509
+ // match ... {
510
+ // _ => m! {} (), // macro that expands to a function, which is then called
511
+ // }
512
+ //
476
513
ExprKind :: MacCall ( _) => false ,
477
514
_ => !classify:: expr_requires_semi_to_be_stmt ( e) ,
478
515
}
@@ -980,7 +1017,7 @@ impl<'a> Parser<'a> {
980
1017
e = self . parse_dot_suffix_expr ( lo, e) ?;
981
1018
continue ;
982
1019
}
983
- if self . expr_is_complete_FIXME ( & e) {
1020
+ if self . expr_is_complete ( & e) {
984
1021
return Ok ( e) ;
985
1022
}
986
1023
e = match self . token . kind {
0 commit comments