@@ -1002,22 +1002,25 @@ impl<'a> Parser<'a> {
1002
1002
match self . token . uninterpolate ( ) . kind {
1003
1003
token:: Ident ( ..) => self . parse_dot_suffix ( base, lo) ,
1004
1004
token:: Literal ( token:: Lit { kind : token:: Integer , symbol, suffix } ) => {
1005
+ let ident_span = self . token . span ;
1005
1006
self . bump ( ) ;
1006
- Ok ( self . parse_expr_tuple_field_access ( lo, base, symbol, suffix) )
1007
+ Ok ( self . mk_expr_tuple_field_access ( lo, ident_span , base, symbol, suffix) )
1007
1008
}
1008
1009
token:: Literal ( token:: Lit { kind : token:: Float , symbol, suffix } ) => {
1009
1010
Ok ( match self . break_up_float ( symbol, self . token . span ) {
1010
1011
// 1e2
1011
1012
DestructuredFloat :: Single ( sym, _sp) => {
1013
+ let ident_span = self . token . span ;
1012
1014
self . bump ( ) ;
1013
- self . parse_expr_tuple_field_access ( lo, base, sym, suffix)
1015
+ self . mk_expr_tuple_field_access ( lo, ident_span , base, sym, suffix)
1014
1016
}
1015
1017
// 1.
1016
1018
DestructuredFloat :: TrailingDot ( sym, ident_span, dot_span) => {
1017
1019
assert ! ( suffix. is_none( ) ) ;
1018
1020
self . token = Token :: new ( token:: Ident ( sym, IdentIsRaw :: No ) , ident_span) ;
1021
+ let ident_span = self . token . span ;
1019
1022
self . bump_with ( ( Token :: new ( token:: Dot , dot_span) , self . token_spacing ) ) ;
1020
- self . parse_expr_tuple_field_access ( lo, base, sym, None )
1023
+ self . mk_expr_tuple_field_access ( lo, ident_span , base, sym, None )
1021
1024
}
1022
1025
// 1.2 | 1.2e3
1023
1026
DestructuredFloat :: MiddleDot (
@@ -1030,13 +1033,16 @@ impl<'a> Parser<'a> {
1030
1033
self . token = Token :: new ( token:: Ident ( symbol1, IdentIsRaw :: No ) , ident1_span) ;
1031
1034
// This needs to be `Spacing::Alone` to prevent regressions.
1032
1035
// See issue #76399 and PR #76285 for more details
1036
+ let ident_span = self . token . span ;
1033
1037
self . bump_with ( ( Token :: new ( token:: Dot , dot_span) , Spacing :: Alone ) ) ;
1034
- let base1 = self . parse_expr_tuple_field_access ( lo, base, symbol1, None ) ;
1038
+ let base1 =
1039
+ self . mk_expr_tuple_field_access ( lo, ident_span, base, symbol1, None ) ;
1035
1040
let next_token2 =
1036
1041
Token :: new ( token:: Ident ( symbol2, IdentIsRaw :: No ) , ident2_span) ;
1037
1042
self . bump_with ( ( next_token2, self . token_spacing ) ) ; // `.`
1043
+ let ident_span = self . token . span ;
1038
1044
self . bump ( ) ;
1039
- self . parse_expr_tuple_field_access ( lo, base1, symbol2, suffix)
1045
+ self . mk_expr_tuple_field_access ( lo, ident_span , base1, symbol2, suffix)
1040
1046
}
1041
1047
DestructuredFloat :: Error => base,
1042
1048
} )
@@ -1254,19 +1260,18 @@ impl<'a> Parser<'a> {
1254
1260
Ok ( fields. into_iter ( ) . collect ( ) )
1255
1261
}
1256
1262
1257
- fn parse_expr_tuple_field_access (
1263
+ fn mk_expr_tuple_field_access (
1258
1264
& mut self ,
1259
1265
lo : Span ,
1266
+ ident_span : Span ,
1260
1267
base : P < Expr > ,
1261
1268
field : Symbol ,
1262
1269
suffix : Option < Symbol > ,
1263
1270
) -> P < Expr > {
1264
- let span = self . prev_token . span ;
1265
- let field = ExprKind :: Field ( base, Ident :: new ( field, span) ) ;
1266
1271
if let Some ( suffix) = suffix {
1267
- self . expect_no_tuple_index_suffix ( span , suffix) ;
1272
+ self . expect_no_tuple_index_suffix ( ident_span , suffix) ;
1268
1273
}
1269
- self . mk_expr ( lo. to ( span ) , field)
1274
+ self . mk_expr ( lo. to ( ident_span ) , ExprKind :: Field ( base , Ident :: new ( field, ident_span ) ) )
1270
1275
}
1271
1276
1272
1277
/// Parse a function call expression, `expr(...)`.
0 commit comments