@@ -703,20 +703,7 @@ impl<'a> Parser<'a> {
703703
704704 // expr.f
705705 if self . eat ( & token:: Dot ) {
706- match self . token . kind {
707- token:: Ident ( ..) => {
708- e = self . parse_dot_suffix ( e, lo) ?;
709- }
710- token:: Literal ( token:: Lit { kind : token:: Integer , symbol, suffix } ) => {
711- e = self . parse_tuple_field_access_expr ( lo, e, symbol, suffix) ;
712- }
713- token:: Literal ( token:: Lit { kind : token:: Float , symbol, .. } ) => {
714- if let Some ( err) = self . recover_field_access_by_float_lit ( lo, & e, symbol) {
715- err?
716- }
717- }
718- _ => self . error_unexpected_after_dot ( ) ,
719- }
706+ e = self . parse_dot_suffix_expr ( lo, e) ?;
720707 continue ;
721708 }
722709 if self . expr_is_complete ( & e) {
@@ -731,6 +718,22 @@ impl<'a> Parser<'a> {
731718 return Ok ( e) ;
732719 }
733720
721+ fn parse_dot_suffix_expr ( & mut self , lo : Span , base : P < Expr > ) -> PResult < ' a , P < Expr > > {
722+ match self . token . kind {
723+ token:: Ident ( ..) => self . parse_dot_suffix ( base, lo) ,
724+ token:: Literal ( token:: Lit { kind : token:: Integer , symbol, suffix } ) => {
725+ Ok ( self . parse_tuple_field_access_expr ( lo, base, symbol, suffix) )
726+ }
727+ token:: Literal ( token:: Lit { kind : token:: Float , symbol, .. } ) => {
728+ self . recover_field_access_by_float_lit ( lo, base, symbol)
729+ }
730+ _ => {
731+ self . error_unexpected_after_dot ( ) ;
732+ Ok ( base)
733+ }
734+ }
735+ }
736+
734737 fn error_unexpected_after_dot ( & self ) {
735738 // FIXME Could factor this out into non_fatal_unexpected or something.
736739 let actual = self . this_token_to_string ( ) ;
@@ -740,9 +743,9 @@ impl<'a> Parser<'a> {
740743 fn recover_field_access_by_float_lit (
741744 & mut self ,
742745 lo : Span ,
743- base : & P < Expr > ,
746+ base : P < Expr > ,
744747 sym : Symbol ,
745- ) -> Option < PResult < ' a , ( ) > > {
748+ ) -> PResult < ' a , P < Expr > > {
746749 self . bump ( ) ;
747750
748751 let fstr = sym. as_str ( ) ;
@@ -752,7 +755,13 @@ impl<'a> Parser<'a> {
752755 err. span_label ( self . prev_span , "unexpected token" ) ;
753756
754757 if fstr. chars ( ) . all ( |x| "0123456789." . contains ( x) ) {
755- let float = fstr. parse :: < f64 > ( ) . ok ( ) ?;
758+ let float = match fstr. parse :: < f64 > ( ) {
759+ Ok ( f) => f,
760+ Err ( _) => {
761+ err. emit ( ) ;
762+ return Ok ( base) ;
763+ }
764+ } ;
756765 let sugg = pprust:: to_string ( |s| {
757766 s. popen ( ) ;
758767 s. print_expr ( & base) ;
@@ -769,7 +778,7 @@ impl<'a> Parser<'a> {
769778 Applicability :: MachineApplicable ,
770779 ) ;
771780 }
772- Some ( Err ( err) )
781+ Err ( err)
773782 }
774783
775784 fn parse_tuple_field_access_expr (
0 commit comments