@@ -213,7 +213,9 @@ impl<'a> State<'a> {
213213
214214    fn  print_expr_call ( & mut  self ,  func :  & ast:: Expr ,  args :  & [ P < ast:: Expr > ] ,  fixup :  FixupContext )  { 
215215        let  needs_paren = match  func. kind  { 
216-             ast:: ExprKind :: Field ( ..)  => true , 
216+             // In order to call a named field, needs parens: `(self.fun)()` 
217+             // But not for an unnamed field: `self.0()` 
218+             ast:: ExprKind :: Field ( _,  name)  => !name. is_numeric ( ) , 
217219            _ => func. precedence ( )  < ExprPrecedence :: Unambiguous , 
218220        } ; 
219221
@@ -245,19 +247,21 @@ impl<'a> State<'a> {
245247        base_args :  & [ P < ast:: Expr > ] , 
246248        fixup :  FixupContext , 
247249    )  { 
248-         // Unlike in `print_expr_call`, no change to fixup here  because 
250+         // The fixup here is different than in `print_expr_call`  because 
249251        // statement boundaries never occur in front of a `.` (or `?`) token. 
250252        // 
251-         //     match () { _ => f }.method(); 
253+         // Needs parens: 
254+         // 
255+         //     (loop { break x; })(); 
256+         // 
257+         // Does not need parens: 
258+         // 
259+         //     loop { break x; }.method(); 
252260        // 
253-         // Parenthesizing only for precedence and not with regard to statement 
254-         // boundaries, `$receiver.method()` can be parsed back as a statement 
255-         // containing an expression if and only if `$receiver` can be parsed as 
256-         // a statement containing an expression. 
257261        self . print_expr_cond_paren ( 
258262            receiver, 
259263            receiver. precedence ( )  < ExprPrecedence :: Unambiguous , 
260-             fixup, 
264+             fixup. leftmost_subexpression_with_dot ( ) , 
261265        ) ; 
262266
263267        self . word ( "." ) ; 
@@ -503,7 +507,7 @@ impl<'a> State<'a> {
503507                        self . print_expr_cond_paren ( 
504508                            expr, 
505509                            expr. precedence ( )  < ExprPrecedence :: Unambiguous , 
506-                             fixup, 
510+                             fixup. leftmost_subexpression_with_dot ( ) , 
507511                        ) ; 
508512                        self . word_nbsp ( ".match" ) ; 
509513                    } 
@@ -567,7 +571,7 @@ impl<'a> State<'a> {
567571                self . print_expr_cond_paren ( 
568572                    expr, 
569573                    expr. precedence ( )  < ExprPrecedence :: Unambiguous , 
570-                     fixup, 
574+                     fixup. leftmost_subexpression_with_dot ( ) , 
571575                ) ; 
572576                self . word ( ".await" ) ; 
573577            } 
@@ -606,7 +610,7 @@ impl<'a> State<'a> {
606610                self . print_expr_cond_paren ( 
607611                    expr, 
608612                    expr. precedence ( )  < ExprPrecedence :: Unambiguous , 
609-                     fixup, 
613+                     fixup. leftmost_subexpression_with_dot ( ) , 
610614                ) ; 
611615                self . word ( "." ) ; 
612616                self . print_ident ( * ident) ; 
@@ -763,7 +767,11 @@ impl<'a> State<'a> {
763767                } 
764768            } 
765769            ast:: ExprKind :: Try ( e)  => { 
766-                 self . print_expr_cond_paren ( e,  e. precedence ( )  < ExprPrecedence :: Unambiguous ,  fixup) ; 
770+                 self . print_expr_cond_paren ( 
771+                     e, 
772+                     e. precedence ( )  < ExprPrecedence :: Unambiguous , 
773+                     fixup. leftmost_subexpression_with_dot ( ) , 
774+                 ) ; 
767775                self . word ( "?" ) 
768776            } 
769777            ast:: ExprKind :: TryBlock ( blk)  => { 
0 commit comments