@@ -708,12 +708,7 @@ impl<'a> Parser<'a> {
708
708
e = self . parse_dot_suffix ( e, lo) ?;
709
709
}
710
710
token:: Literal ( token:: Lit { kind : token:: Integer , symbol, suffix } ) => {
711
- let span = self . token . span ;
712
- self . bump ( ) ;
713
- let field = ExprKind :: Field ( e, Ident :: new ( symbol, span) ) ;
714
- e = self . mk_expr ( lo. to ( span) , field, AttrVec :: new ( ) ) ;
715
-
716
- self . expect_no_suffix ( span, "a tuple index" , suffix) ;
711
+ e = self . parse_tuple_field_access_expr ( lo, e, symbol, suffix) ;
717
712
}
718
713
token:: Literal ( token:: Lit { kind : token:: Float , symbol, .. } ) => {
719
714
self . bump ( ) ;
@@ -756,14 +751,28 @@ impl<'a> Parser<'a> {
756
751
break ;
757
752
}
758
753
match self . token . kind {
759
- token:: OpenDelim ( token:: Paren ) => e = Ok ( self . parse_fn_call_expr ( lo, e) ) ,
754
+ token:: OpenDelim ( token:: Paren ) => e = self . parse_fn_call_expr ( lo, e) ,
760
755
token:: OpenDelim ( token:: Bracket ) => e = self . parse_index_expr ( lo, e) ?,
761
756
_ => return Ok ( e) ,
762
757
}
763
758
}
764
759
return Ok ( e) ;
765
760
}
766
761
762
+ fn parse_tuple_field_access_expr (
763
+ & mut self ,
764
+ lo : Span ,
765
+ base : P < Expr > ,
766
+ field : Symbol ,
767
+ suffix : Option < Symbol > ,
768
+ ) -> P < Expr > {
769
+ let span = self . token . span ;
770
+ self . bump ( ) ;
771
+ let field = ExprKind :: Field ( base, Ident :: new ( field, span) ) ;
772
+ self . expect_no_suffix ( span, "a tuple index" , suffix) ;
773
+ self . mk_expr ( lo. to ( span) , field, AttrVec :: new ( ) )
774
+ }
775
+
767
776
/// Parse a function call expression, `expr(...)`.
768
777
fn parse_fn_call_expr ( & mut self , lo : Span , fun : P < Expr > ) -> P < Expr > {
769
778
let seq = self . parse_paren_expr_seq ( ) . map ( |args| {
0 commit comments