Skip to content

Commit 90eeb3d

Browse files
committed
Remove next_token handling from parse_expr_tuple_field_access.
It's clearer at the call site.
1 parent 42066b0 commit 90eeb3d

File tree

1 file changed

+10
-18
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+10
-18
lines changed

compiler/rustc_parse/src/parser/expr.rs

+10-18
Original file line numberDiff line numberDiff line change
@@ -1002,20 +1002,22 @@ impl<'a> Parser<'a> {
10021002
match self.token.uninterpolate().kind {
10031003
token::Ident(..) => self.parse_dot_suffix(base, lo),
10041004
token::Literal(token::Lit { kind: token::Integer, symbol, suffix }) => {
1005-
Ok(self.parse_expr_tuple_field_access(lo, base, symbol, suffix, None))
1005+
self.bump();
1006+
Ok(self.parse_expr_tuple_field_access(lo, base, symbol, suffix))
10061007
}
10071008
token::Literal(token::Lit { kind: token::Float, symbol, suffix }) => {
10081009
Ok(match self.break_up_float(symbol, self.token.span) {
10091010
// 1e2
10101011
DestructuredFloat::Single(sym, _sp) => {
1011-
self.parse_expr_tuple_field_access(lo, base, sym, suffix, None)
1012+
self.bump();
1013+
self.parse_expr_tuple_field_access(lo, base, sym, suffix)
10121014
}
10131015
// 1.
10141016
DestructuredFloat::TrailingDot(sym, ident_span, dot_span) => {
10151017
assert!(suffix.is_none());
10161018
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+
self.bump_with((Token::new(token::Dot, dot_span), self.token_spacing));
1020+
self.parse_expr_tuple_field_access(lo, base, sym, None)
10191021
}
10201022
// 1.2 | 1.2e3
10211023
DestructuredFloat::MiddleDot(
@@ -1028,18 +1030,13 @@ impl<'a> Parser<'a> {
10281030
self.token = Token::new(token::Ident(symbol1, IdentIsRaw::No), ident1_span);
10291031
// This needs to be `Spacing::Alone` to prevent regressions.
10301032
// 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-
);
1033+
self.bump_with((Token::new(token::Dot, dot_span), Spacing::Alone));
1034+
let base1 = self.parse_expr_tuple_field_access(lo, base, symbol1, None);
10391035
let next_token2 =
10401036
Token::new(token::Ident(symbol2, IdentIsRaw::No), ident2_span);
10411037
self.bump_with((next_token2, self.token_spacing)); // `.`
1042-
self.parse_expr_tuple_field_access(lo, base1, symbol2, suffix, None)
1038+
self.bump();
1039+
self.parse_expr_tuple_field_access(lo, base1, symbol2, suffix)
10431040
}
10441041
DestructuredFloat::Error => base,
10451042
})
@@ -1263,12 +1260,7 @@ impl<'a> Parser<'a> {
12631260
base: P<Expr>,
12641261
field: Symbol,
12651262
suffix: Option<Symbol>,
1266-
next_token: Option<(Token, Spacing)>,
12671263
) -> P<Expr> {
1268-
match next_token {
1269-
Some(next_token) => self.bump_with(next_token),
1270-
None => self.bump(),
1271-
}
12721264
let span = self.prev_token.span;
12731265
let field = ExprKind::Field(base, Ident::new(field, span));
12741266
if let Some(suffix) = suffix {

0 commit comments

Comments
 (0)