diff options
| author | bors <bors@rust-lang.org> | 2024-01-20 19:55:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-20 19:55:26 +0000 |
| commit | 038d115cd8659bbe4d5e9600839759f55dfcfb0c (patch) | |
| tree | 38a3eb678d48946c490d1c31e7b1fd9ff819a8be /compiler/rustc_parse/src/parser | |
| parent | 1828461982f37d1a0053d156cedad5522b0f8a97 (diff) | |
| parent | 774cd3afd5dad311f9be97f74eb6d1a89ad06d38 (diff) | |
| download | rust-038d115cd8659bbe4d5e9600839759f55dfcfb0c.tar.gz rust-038d115cd8659bbe4d5e9600839759f55dfcfb0c.zip | |
Auto merge of #120170 - GuillaumeGomez:rollup-edqdf30, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #119997 (Fix impl stripped in rustdoc HTML whereas it should not be in case the impl is implemented on a type alias) - #120000 (Ensure `callee_id`s are body owners) - #120063 (Remove special handling of `box` expressions from parser) - #120116 (Remove alignment-changing in-place collect) - #120138 (Increase vscode settings.json `git.detectSubmodulesLimit`) - #120169 (Spelling fix) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index f858706805d..ae3661a530b 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -33,7 +33,6 @@ use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded}; use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_span::source_map::{self, Spanned}; -use rustc_span::symbol::kw::PathRoot; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{BytePos, Pos, Span}; use thin_vec::{thin_vec, ThinVec}; @@ -642,26 +641,13 @@ impl<'a> Parser<'a> { } /// Parse `box expr` - this syntax has been removed, but we still parse this - /// for now to provide an automated way to fix usages of it - fn parse_expr_box(&mut self, lo: Span) -> PResult<'a, (Span, ExprKind)> { - let (span, expr) = self.parse_expr_prefix_common(lo)?; - let code = self.sess.source_map().span_to_snippet(span.with_lo(lo.hi())).unwrap(); - self.dcx().emit_err(errors::BoxSyntaxRemoved { span, code: code.trim() }); - // So typechecking works, parse `box <expr>` as `::std::boxed::Box::new(expr)` - let path = Path { - span, - segments: [ - PathSegment::from_ident(Ident::with_dummy_span(PathRoot)), - PathSegment::from_ident(Ident::with_dummy_span(sym::std)), - PathSegment::from_ident(Ident::from_str("boxed")), - PathSegment::from_ident(Ident::from_str("Box")), - PathSegment::from_ident(Ident::with_dummy_span(sym::new)), - ] - .into(), - tokens: None, - }; - let path = self.mk_expr(span, ExprKind::Path(None, path)); - Ok((span, self.mk_call(path, ThinVec::from([expr])))) + /// for now to provide a more useful error + fn parse_expr_box(&mut self, box_kw: Span) -> PResult<'a, (Span, ExprKind)> { + let (span, _) = self.parse_expr_prefix_common(box_kw)?; + let inner_span = span.with_lo(box_kw.hi()); + let code = self.sess.source_map().span_to_snippet(inner_span).unwrap(); + self.dcx().emit_err(errors::BoxSyntaxRemoved { span: span, code: code.trim() }); + Ok((span, ExprKind::Err)) } fn is_mistaken_not_ident_negation(&self) -> bool { |
