Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d8a79d1

Browse files
authored
Unrolled build for rust-lang#120063
Rollup merge of rust-lang#120063 - clubby789:remove-box-handling, r=Nilstrieb Remove special handling of `box` expressions from parser rust-lang#108471 added a temporary hack to parse `box expr`. It's been almost a year since then, so I think it's safe to remove the special handling. As a drive-by cleanup, move `parser/removed-syntax*` tests to their own directory.
2 parents 1828461 + 3f7c784 commit d8a79d1

38 files changed

+7
-21
lines changed

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded};
3333
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
3434
use rustc_session::lint::BuiltinLintDiagnostics;
3535
use rustc_span::source_map::{self, Spanned};
36-
use rustc_span::symbol::kw::PathRoot;
3736
use rustc_span::symbol::{kw, sym, Ident, Symbol};
3837
use rustc_span::{BytePos, Pos, Span};
3938
use thin_vec::{thin_vec, ThinVec};
@@ -642,26 +641,13 @@ impl<'a> Parser<'a> {
642641
}
643642

644643
/// Parse `box expr` - this syntax has been removed, but we still parse this
645-
/// for now to provide an automated way to fix usages of it
646-
fn parse_expr_box(&mut self, lo: Span) -> PResult<'a, (Span, ExprKind)> {
647-
let (span, expr) = self.parse_expr_prefix_common(lo)?;
648-
let code = self.sess.source_map().span_to_snippet(span.with_lo(lo.hi())).unwrap();
649-
self.dcx().emit_err(errors::BoxSyntaxRemoved { span, code: code.trim() });
650-
// So typechecking works, parse `box <expr>` as `::std::boxed::Box::new(expr)`
651-
let path = Path {
652-
span,
653-
segments: [
654-
PathSegment::from_ident(Ident::with_dummy_span(PathRoot)),
655-
PathSegment::from_ident(Ident::with_dummy_span(sym::std)),
656-
PathSegment::from_ident(Ident::from_str("boxed")),
657-
PathSegment::from_ident(Ident::from_str("Box")),
658-
PathSegment::from_ident(Ident::with_dummy_span(sym::new)),
659-
]
660-
.into(),
661-
tokens: None,
662-
};
663-
let path = self.mk_expr(span, ExprKind::Path(None, path));
664-
Ok((span, self.mk_call(path, ThinVec::from([expr]))))
644+
/// for now to provide a more useful error
645+
fn parse_expr_box(&mut self, box_kw: Span) -> PResult<'a, (Span, ExprKind)> {
646+
let (span, _) = self.parse_expr_prefix_common(box_kw)?;
647+
let inner_span = span.with_lo(box_kw.hi());
648+
let code = self.sess.source_map().span_to_snippet(inner_span).unwrap();
649+
self.dcx().emit_err(errors::BoxSyntaxRemoved { span: span, code: code.trim() });
650+
Ok((span, ExprKind::Err))
665651
}
666652

667653
fn is_mistaken_not_ident_negation(&self) -> bool {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)