diff options
| author | bors <bors@rust-lang.org> | 2023-08-05 06:22:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-05 06:22:33 +0000 |
| commit | 3d9e8f16b31586f1d4f9e9a0b9cd626d63454ed8 (patch) | |
| tree | 0594fecff57824ca58e21237eac1ef2ce2d377a2 /compiler/rustc_parse/src/parser | |
| parent | 646f5643aba41e0dfd62fc9d5cdfa955e4e6fa2a (diff) | |
| parent | 621aeeb096d8e4f3eb656259fc286a1f32862ed3 (diff) | |
| download | rust-3d9e8f16b31586f1d4f9e9a0b9cd626d63454ed8.tar.gz rust-3d9e8f16b31586f1d4f9e9a0b9cd626d63454ed8.zip | |
Auto merge of #3014 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index c0459789805..e409c7c6781 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -857,7 +857,7 @@ impl<'a> Parser<'a> { let msg = format!( "cast cannot be followed by {}", match with_postfix.kind { - ExprKind::Index(_, _) => "indexing", + ExprKind::Index(..) => "indexing", ExprKind::Try(_) => "`?`", ExprKind::Field(_, _) => "a field access", ExprKind::MethodCall(_) => "a method call", @@ -1304,7 +1304,10 @@ impl<'a> Parser<'a> { let index = self.parse_expr()?; self.suggest_missing_semicolon_before_array(prev_span, open_delim_span)?; self.expect(&token::CloseDelim(Delimiter::Bracket))?; - Ok(self.mk_expr(lo.to(self.prev_token.span), self.mk_index(base, index))) + Ok(self.mk_expr( + lo.to(self.prev_token.span), + self.mk_index(base, index, open_delim_span.to(self.prev_token.span)), + )) } /// Assuming we have just parsed `.`, continue parsing into an expression. @@ -3366,8 +3369,8 @@ impl<'a> Parser<'a> { ExprKind::Binary(binop, lhs, rhs) } - fn mk_index(&self, expr: P<Expr>, idx: P<Expr>) -> ExprKind { - ExprKind::Index(expr, idx) + fn mk_index(&self, expr: P<Expr>, idx: P<Expr>, brackets_span: Span) -> ExprKind { + ExprKind::Index(expr, idx, brackets_span) } fn mk_call(&self, f: P<Expr>, args: ThinVec<P<Expr>>) -> ExprKind { |
