diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-03-13 15:45:27 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-03-25 13:05:59 +1100 |
| commit | 90eeb3d6817303469059041ef7c8c57f3508f476 (patch) | |
| tree | c31ec45032097e264c473969a5ff6c8a15747516 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 42066b029f3009518e2ba8c7bd20f5781b180b8f (diff) | |
| download | rust-90eeb3d6817303469059041ef7c8c57f3508f476.tar.gz rust-90eeb3d6817303469059041ef7c8c57f3508f476.zip | |
Remove `next_token` handling from `parse_expr_tuple_field_access`.
It's clearer at the call site.
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index cf7771f87a8..50589ad3f12 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1002,20 +1002,22 @@ impl<'a> Parser<'a> { match self.token.uninterpolate().kind { token::Ident(..) => self.parse_dot_suffix(base, lo), token::Literal(token::Lit { kind: token::Integer, symbol, suffix }) => { - Ok(self.parse_expr_tuple_field_access(lo, base, symbol, suffix, None)) + self.bump(); + Ok(self.parse_expr_tuple_field_access(lo, base, symbol, suffix)) } token::Literal(token::Lit { kind: token::Float, symbol, suffix }) => { Ok(match self.break_up_float(symbol, self.token.span) { // 1e2 DestructuredFloat::Single(sym, _sp) => { - self.parse_expr_tuple_field_access(lo, base, sym, suffix, None) + self.bump(); + self.parse_expr_tuple_field_access(lo, base, sym, suffix) } // 1. DestructuredFloat::TrailingDot(sym, ident_span, dot_span) => { assert!(suffix.is_none()); self.token = Token::new(token::Ident(sym, IdentIsRaw::No), ident_span); - let next_token = (Token::new(token::Dot, dot_span), self.token_spacing); - self.parse_expr_tuple_field_access(lo, base, sym, None, Some(next_token)) + self.bump_with((Token::new(token::Dot, dot_span), self.token_spacing)); + self.parse_expr_tuple_field_access(lo, base, sym, None) } // 1.2 | 1.2e3 DestructuredFloat::MiddleDot( @@ -1028,18 +1030,13 @@ impl<'a> Parser<'a> { self.token = Token::new(token::Ident(symbol1, IdentIsRaw::No), ident1_span); // This needs to be `Spacing::Alone` to prevent regressions. // See issue #76399 and PR #76285 for more details - let next_token1 = (Token::new(token::Dot, dot_span), Spacing::Alone); - let base1 = self.parse_expr_tuple_field_access( - lo, - base, - symbol1, - None, - Some(next_token1), - ); + self.bump_with((Token::new(token::Dot, dot_span), Spacing::Alone)); + let base1 = self.parse_expr_tuple_field_access(lo, base, symbol1, None); let next_token2 = Token::new(token::Ident(symbol2, IdentIsRaw::No), ident2_span); self.bump_with((next_token2, self.token_spacing)); // `.` - self.parse_expr_tuple_field_access(lo, base1, symbol2, suffix, None) + self.bump(); + self.parse_expr_tuple_field_access(lo, base1, symbol2, suffix) } DestructuredFloat::Error => base, }) @@ -1263,12 +1260,7 @@ impl<'a> Parser<'a> { base: P<Expr>, field: Symbol, suffix: Option<Symbol>, - next_token: Option<(Token, Spacing)>, ) -> P<Expr> { - match next_token { - Some(next_token) => self.bump_with(next_token), - None => self.bump(), - } let span = self.prev_token.span; let field = ExprKind::Field(base, Ident::new(field, span)); if let Some(suffix) = suffix { |
