@@ -1005,7 +1005,44 @@ impl<'a> Parser<'a> {
10051005 Ok ( self . parse_expr_tuple_field_access ( lo, base, symbol, suffix, None ) )
10061006 }
10071007 token:: Literal ( token:: Lit { kind : token:: Float , symbol, suffix } ) => {
1008- Ok ( self . parse_expr_tuple_field_access_float ( lo, base, symbol, suffix) )
1008+ Ok ( match self . break_up_float ( symbol, self . token . span ) {
1009+ // 1e2
1010+ DestructuredFloat :: Single ( sym, _sp) => {
1011+ self . parse_expr_tuple_field_access ( lo, base, sym, suffix, None )
1012+ }
1013+ // 1.
1014+ DestructuredFloat :: TrailingDot ( sym, ident_span, dot_span) => {
1015+ assert ! ( suffix. is_none( ) ) ;
1016+ self . token = Token :: new ( token:: Ident ( sym, IdentIsRaw :: No ) , ident_span) ;
1017+ let next_token = ( Token :: new ( token:: Dot , dot_span) , self . token_spacing ) ;
1018+ self . parse_expr_tuple_field_access ( lo, base, sym, None , Some ( next_token) )
1019+ }
1020+ // 1.2 | 1.2e3
1021+ DestructuredFloat :: MiddleDot (
1022+ symbol1,
1023+ ident1_span,
1024+ dot_span,
1025+ symbol2,
1026+ ident2_span,
1027+ ) => {
1028+ self . token = Token :: new ( token:: Ident ( symbol1, IdentIsRaw :: No ) , ident1_span) ;
1029+ // This needs to be `Spacing::Alone` to prevent regressions.
1030+ // See issue #76399 and PR #76285 for more details
1031+ let next_token1 = ( Token :: new ( token:: Dot , dot_span) , Spacing :: Alone ) ;
1032+ let base1 = self . parse_expr_tuple_field_access (
1033+ lo,
1034+ base,
1035+ symbol1,
1036+ None ,
1037+ Some ( next_token1) ,
1038+ ) ;
1039+ let next_token2 =
1040+ Token :: new ( token:: Ident ( symbol2, IdentIsRaw :: No ) , ident2_span) ;
1041+ self . bump_with ( ( next_token2, self . token_spacing ) ) ; // `.`
1042+ self . parse_expr_tuple_field_access ( lo, base1, symbol2, suffix, None )
1043+ }
1044+ DestructuredFloat :: Error => base,
1045+ } )
10091046 }
10101047 _ => {
10111048 self . error_unexpected_after_dot ( ) ;
@@ -1119,41 +1156,6 @@ impl<'a> Parser<'a> {
11191156 }
11201157 }
11211158
1122- fn parse_expr_tuple_field_access_float (
1123- & mut self ,
1124- lo : Span ,
1125- base : P < Expr > ,
1126- float : Symbol ,
1127- suffix : Option < Symbol > ,
1128- ) -> P < Expr > {
1129- match self . break_up_float ( float, self . token . span ) {
1130- // 1e2
1131- DestructuredFloat :: Single ( sym, _sp) => {
1132- self . parse_expr_tuple_field_access ( lo, base, sym, suffix, None )
1133- }
1134- // 1.
1135- DestructuredFloat :: TrailingDot ( sym, ident_span, dot_span) => {
1136- assert ! ( suffix. is_none( ) ) ;
1137- self . token = Token :: new ( token:: Ident ( sym, IdentIsRaw :: No ) , ident_span) ;
1138- let next_token = ( Token :: new ( token:: Dot , dot_span) , self . token_spacing ) ;
1139- self . parse_expr_tuple_field_access ( lo, base, sym, None , Some ( next_token) )
1140- }
1141- // 1.2 | 1.2e3
1142- DestructuredFloat :: MiddleDot ( symbol1, ident1_span, dot_span, symbol2, ident2_span) => {
1143- self . token = Token :: new ( token:: Ident ( symbol1, IdentIsRaw :: No ) , ident1_span) ;
1144- // This needs to be `Spacing::Alone` to prevent regressions.
1145- // See issue #76399 and PR #76285 for more details
1146- let next_token1 = ( Token :: new ( token:: Dot , dot_span) , Spacing :: Alone ) ;
1147- let base1 =
1148- self . parse_expr_tuple_field_access ( lo, base, symbol1, None , Some ( next_token1) ) ;
1149- let next_token2 = Token :: new ( token:: Ident ( symbol2, IdentIsRaw :: No ) , ident2_span) ;
1150- self . bump_with ( ( next_token2, self . token_spacing ) ) ; // `.`
1151- self . parse_expr_tuple_field_access ( lo, base1, symbol2, suffix, None )
1152- }
1153- DestructuredFloat :: Error => base,
1154- }
1155- }
1156-
11571159 /// Parse the field access used in offset_of, matched by `$(e:expr)+`.
11581160 /// Currently returns a list of idents. However, it should be possible in
11591161 /// future to also do array indices, which might be arbitrary expressions.
0 commit comments