From 0932452fa40178b6f8b93a2bab3b4ead4e2bb560 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Mon, 27 Feb 2023 13:17:29 +0000 Subject: [PATCH] Remove `box_syntax` from AST and use in tools --- compiler/rustc_ast/src/ast.rs | 6 +----- compiler/rustc_ast/src/mut_visit.rs | 1 - compiler/rustc_ast/src/util/classify.rs | 1 - compiler/rustc_ast/src/visit.rs | 1 - compiler/rustc_ast_lowering/src/expr.rs | 1 - compiler/rustc_ast_passes/src/feature_gate.rs | 9 --------- compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 4 ---- .../rustc_builtin_macros/src/assert/context.rs | 1 - compiler/rustc_feature/src/active.rs | 2 -- compiler/rustc_feature/src/removed.rs | 2 ++ compiler/rustc_parse/messages.ftl | 3 +++ compiler/rustc_parse/src/errors.rs | 13 +++++++++++++ compiler/rustc_parse/src/parser/expr.rs | 10 ---------- compiler/rustc_passes/src/hir_stats.rs | 2 +- .../src/language-features/box-patterns.md | 2 -- .../src/suspicious_operation_groupings.rs | 3 +-- src/tools/clippy/clippy_utils/src/ast_utils.rs | 2 +- src/tools/clippy/clippy_utils/src/sugg.rs | 1 - src/tools/rustfmt/src/closures.rs | 2 -- src/tools/rustfmt/src/expr.rs | 5 ----- src/tools/rustfmt/src/matches.rs | 1 - src/tools/rustfmt/src/utils.rs | 1 - tests/ui/feature-gates/feature-gate-box-expr.rs | 14 -------------- .../ui/feature-gates/feature-gate-box-expr.stderr | 12 ------------ tests/ui/feature-gates/feature-gate-box_syntax.rs | 6 ------ .../feature-gates/feature-gate-box_syntax.stderr | 12 ------------ tests/ui/parser/removed-syntax-box.rs | 10 ++++++++++ tests/ui/parser/removed-syntax-box.stderr | 8 ++++++++ 28 files changed, 40 insertions(+), 95 deletions(-) delete mode 100644 tests/ui/feature-gates/feature-gate-box-expr.rs delete mode 100644 tests/ui/feature-gates/feature-gate-box-expr.stderr delete mode 100644 tests/ui/feature-gates/feature-gate-box_syntax.rs delete mode 100644 tests/ui/feature-gates/feature-gate-box_syntax.stderr create mode 100644 tests/ui/parser/removed-syntax-box.rs create mode 100644 tests/ui/parser/removed-syntax-box.stderr diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 03c375c4666..6503bf2bab7 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1230,7 +1230,6 @@ pub fn to_ty(&self) -> Option> { pub fn precedence(&self) -> ExprPrecedence { match self.kind { - ExprKind::Box(_) => ExprPrecedence::Box, ExprKind::Array(_) => ExprPrecedence::Array, ExprKind::ConstBlock(_) => ExprPrecedence::ConstBlock, ExprKind::Call(..) => ExprPrecedence::Call, @@ -1291,8 +1290,7 @@ pub fn take(&mut self) -> Self { /// To a first-order approximation, is this a pattern? pub fn is_approximately_pattern(&self) -> bool { match &self.peel_parens().kind { - ExprKind::Box(_) - | ExprKind::Array(_) + ExprKind::Array(_) | ExprKind::Call(_, _) | ExprKind::Tup(_) | ExprKind::Lit(_) @@ -1363,8 +1361,6 @@ pub struct StructExpr { #[derive(Clone, Encodable, Decodable, Debug)] pub enum ExprKind { - /// A `box x` expression. - Box(P), /// An array (`[a, b, c, d]`) Array(ThinVec>), /// Allow anonymous constants from an inline `const` block diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 6fed0b660e8..45a5a3ecb53 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1316,7 +1316,6 @@ pub fn noop_visit_expr( vis: &mut T, ) { match kind { - ExprKind::Box(expr) => vis.visit_expr(expr), ExprKind::Array(exprs) => visit_thin_exprs(exprs, vis), ExprKind::ConstBlock(anon_const) => { vis.visit_anon_const(anon_const); diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs index cdc244c1218..607b77705cf 100644 --- a/compiler/rustc_ast/src/util/classify.rs +++ b/compiler/rustc_ast/src/util/classify.rs @@ -35,7 +35,6 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> { | Assign(_, e, _) | AssignOp(_, _, e) | Binary(_, _, e) - | Box(e) | Break(_, Some(e)) | Let(_, e, _) | Range(_, Some(e), _) diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index bdb1879ec20..9a4da6d4396 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -772,7 +772,6 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { walk_list!(visitor, visit_attribute, expression.attrs.iter()); match &expression.kind { - ExprKind::Box(subexpression) => visitor.visit_expr(subexpression), ExprKind::Array(subexpressions) => { walk_list!(visitor, visit_expr, subexpressions); } diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index ffb30b1b391..4390680c45a 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -70,7 +70,6 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> { self.lower_attrs(hir_id, &e.attrs); let kind = match &e.kind { - ExprKind::Box(inner) => hir::ExprKind::Box(self.lower_expr(inner)), ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)), ExprKind::ConstBlock(anon_const) => { let anon_const = self.lower_anon_const(anon_const); diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 96042ea3078..109f83d4d18 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -395,14 +395,6 @@ fn visit_stmt(&mut self, stmt: &'a ast::Stmt) { fn visit_expr(&mut self, e: &'a ast::Expr) { match e.kind { - ast::ExprKind::Box(_) => { - gate_feature_post!( - &self, - box_syntax, - e.span, - "box expression syntax is experimental; you can call `Box::new` instead" - ); - } ast::ExprKind::Type(..) => { if self.sess.parse_sess.span_diagnostic.err_count() == 0 { // To avoid noise about type ascription in common syntax errors, @@ -613,7 +605,6 @@ macro_rules! gate_all { gate_all!(box_patterns, "box pattern syntax is experimental"); gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental"); gate_all!(try_blocks, "`try` blocks are unstable"); - gate_all!(box_syntax, "box expression syntax is experimental; you can call `Box::new` instead"); gate_all!(type_ascription, "type ascription is experimental"); visit::walk_crate(&mut visitor, krate); diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index a4d91a95662..e2f63641ffa 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -296,10 +296,6 @@ pub(super) fn print_expr_outer_attr_style(&mut self, expr: &ast::Expr, is_inline self.ibox(INDENT_UNIT); self.ann.pre(self, AnnNode::Expr(expr)); match &expr.kind { - ast::ExprKind::Box(expr) => { - self.word_space("box"); - self.print_expr_maybe_paren(expr, parser::PREC_PREFIX); - } ast::ExprKind::Array(exprs) => { self.print_expr_vec(exprs); } diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index b0b4dda16af..5d8f4db76f9 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -290,7 +290,6 @@ fn manage_cond_expr(&mut self, expr: &mut P) { | ExprKind::Async(_, _, _) | ExprKind::Await(_) | ExprKind::Block(_, _) - | ExprKind::Box(_) | ExprKind::Break(_, _) | ExprKind::Closure(_) | ExprKind::ConstBlock(_) diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 2fa7bceb8bc..c893b34b4ac 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -200,8 +200,6 @@ pub fn set(&self, features: &mut Features, span: Span) { (active, auto_traits, "1.50.0", Some(13231), None), /// Allows using `box` in patterns (RFC 469). (active, box_patterns, "1.0.0", Some(29641), None), - /// Allows using the `box $expr` syntax. - (active, box_syntax, "1.0.0", Some(49733), None), /// Allows `#[doc(notable_trait)]`. /// Renamed from `doc_spotlight`. (active, doc_notable_trait, "1.52.0", Some(45040), None), diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 04d4f6cb14e..48d9fbfa6d2 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -52,6 +52,8 @@ macro_rules! declare_features { (removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")), (removed, await_macro, "1.38.0", Some(50547), None, Some("subsumed by `.await` syntax")), + /// Allows using the `box $expr` syntax. + (removed, box_syntax, "CURRENT_RUSTC_VERSION", Some(49733), None, Some("replaced with `#[rustc_box]`")), /// Allows capturing disjoint fields in a closure/generator (RFC 2229). (removed, capture_disjoint_fields, "1.49.0", Some(53488), None, Some("stabilized in Rust 2021")), /// Allows comparing raw pointers during const eval. diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index ab7931d74d7..c39ada95a4e 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -731,3 +731,6 @@ parse_unknown_start_of_token = unknown start of token: {$escaped} [one] once more *[other] {$repeats} more times } + +parse_box_syntax_removed = `box_syntax` has been removed + .suggestion = use `Box::new()` instead diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 63e5bc50513..af0c3026c66 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -2300,3 +2300,16 @@ pub fn new() -> Self { } } } + +#[derive(Diagnostic)] +#[diag(parse_box_syntax_removed)] +pub struct BoxSyntaxRemoved<'a> { + #[primary_span] + #[suggestion( + code = "Box::new({code})", + applicability = "machine-applicable", + style = "verbose" + )] + pub span: Span, + pub code: &'a str, +} diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index e00eda47c66..27516716286 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -607,9 +607,6 @@ macro_rules! make_it { let operand_expr = this.parse_expr_dot_or_call(Default::default())?; this.recover_from_prefix_increment(operand_expr, pre_span, starts_stmt) } - token::Ident(..) if this.token.is_keyword(kw::Box) => { - make_it!(this, attrs, |this, _| this.parse_expr_box(lo)) - } token::Ident(..) if this.may_recover() && this.is_mistaken_not_ident_negation() => { make_it!(this, attrs, |this, _| this.recover_not_expr(lo)) } @@ -636,13 +633,6 @@ fn recover_tilde_expr(&mut self, lo: Span) -> PResult<'a, (Span, ExprKind)> { self.parse_expr_unary(lo, UnOp::Not) } - /// Parse `box expr`. - fn parse_expr_box(&mut self, lo: Span) -> PResult<'a, (Span, ExprKind)> { - let (span, expr) = self.parse_expr_prefix_common(lo)?; - self.sess.gated_spans.gate(sym::box_syntax, span); - Ok((span, ExprKind::Box(expr))) - } - fn is_mistaken_not_ident_negation(&self) -> bool { let token_cannot_continue_expr = |t: &Token| match t.uninterpolate().kind { // These tokens can start an expression after `!`, but diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index 5e2d2d3e5a7..3e0d53029ef 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -565,7 +565,7 @@ fn visit_expr(&mut self, e: &'v ast::Expr) { record_variants!( (self, e, e.kind, Id::None, ast, Expr, ExprKind), [ - Box, Array, ConstBlock, Call, MethodCall, Tup, Binary, Unary, Lit, Cast, Type, Let, + Array, ConstBlock, Call, MethodCall, Tup, Binary, Unary, Lit, Cast, Type, Let, If, While, ForLoop, Loop, Match, Closure, Block, Async, Await, TryBlock, Assign, AssignOp, Field, Index, Range, Underscore, Path, AddrOf, Break, Continue, Ret, InlineAsm, FormatArgs, MacCall, Struct, Repeat, Paren, Try, Yield, Yeet, IncludedBytes, Err diff --git a/src/doc/unstable-book/src/language-features/box-patterns.md b/src/doc/unstable-book/src/language-features/box-patterns.md index 584f4295cba..a1ac09633b7 100644 --- a/src/doc/unstable-book/src/language-features/box-patterns.md +++ b/src/doc/unstable-book/src/language-features/box-patterns.md @@ -4,8 +4,6 @@ The tracking issue for this feature is: [#29641] [#29641]: https://github.com/rust-lang/rust/issues/29641 -See also [`box_syntax`](box-syntax.md) - ------------------------ Box patterns let you match on `Box`s: diff --git a/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs b/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs index e111c7d2291..8aa47b62ebf 100644 --- a/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs +++ b/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs @@ -596,8 +596,7 @@ fn ident_difference_expr_with_base_location( | (MethodCall(_), MethodCall(_)) | (Call(_, _), Call(_, _)) | (ConstBlock(_), ConstBlock(_)) - | (Array(_), Array(_)) - | (Box(_), Box(_)) => { + | (Array(_), Array(_)) => { // keep going }, _ => { diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs index d82098523e3..809d654603a 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs @@ -143,7 +143,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool { (Paren(l), _) => eq_expr(l, r), (_, Paren(r)) => eq_expr(l, r), (Err, Err) => true, - (Box(l), Box(r)) | (Try(l), Try(r)) | (Await(l), Await(r)) => eq_expr(l, r), + (Try(l), Try(r)) | (Await(l), Await(r)) => eq_expr(l, r), (Array(l), Array(r)) => over(l, r, |l, r| eq_expr(l, r)), (Tup(l), Tup(r)) => over(l, r, |l, r| eq_expr(l, r)), (Repeat(le, ls), Repeat(re, rs)) => eq_expr(le, re) && eq_expr(&ls.value, &rs.value), diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs index 07feadca2b0..85bf28b708b 100644 --- a/src/tools/clippy/clippy_utils/src/sugg.rs +++ b/src/tools/clippy/clippy_utils/src/sugg.rs @@ -188,7 +188,6 @@ pub fn ast( match expr.kind { _ if expr.span.ctxt() != ctxt => Sugg::NonParen(snippet_with_context(cx, expr.span, ctxt, default, app).0), ast::ExprKind::AddrOf(..) - | ast::ExprKind::Box(..) | ast::ExprKind::Closure { .. } | ast::ExprKind::If(..) | ast::ExprKind::Let(..) diff --git a/src/tools/rustfmt/src/closures.rs b/src/tools/rustfmt/src/closures.rs index 340113866c4..c95e9a97b43 100644 --- a/src/tools/rustfmt/src/closures.rs +++ b/src/tools/rustfmt/src/closures.rs @@ -195,7 +195,6 @@ fn allow_multi_line(expr: &ast::Expr) -> bool { | ast::ExprKind::Struct(..) => true, ast::ExprKind::AddrOf(_, _, ref expr) - | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) | ast::ExprKind::Cast(ref expr, _) => allow_multi_line(expr), @@ -441,7 +440,6 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool { ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true, ast::ExprKind::Loop(..) if version == Version::Two => true, ast::ExprKind::AddrOf(_, _, ref expr) - | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) | ast::ExprKind::Cast(ref expr, _) => is_block_closure_forced_inner(expr, version), diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index 3f0f217f890..7273402ec76 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -236,7 +236,6 @@ pub(crate) fn format_expr( ast::ExprKind::Yeet(Some(ref expr)) => { rewrite_unary_prefix(context, "do yeet ", &**expr, shape) } - ast::ExprKind::Box(ref expr) => rewrite_unary_prefix(context, "box ", &**expr, shape), ast::ExprKind::AddrOf(borrow_kind, mutability, ref expr) => { rewrite_expr_addrof(context, borrow_kind, mutability, expr, shape) } @@ -1299,7 +1298,6 @@ pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool { ast::ExprKind::Lit(..) => true, ast::ExprKind::Path(ref qself, ref path) => qself.is_none() && path.segments.len() <= 1, ast::ExprKind::AddrOf(_, _, ref expr) - | ast::ExprKind::Box(ref expr) | ast::ExprKind::Cast(ref expr, _) | ast::ExprKind::Field(ref expr, _) | ast::ExprKind::Try(ref expr) @@ -1361,7 +1359,6 @@ pub(crate) fn can_be_overflowed_expr( // Handle unary-like expressions ast::ExprKind::AddrOf(_, _, ref expr) - | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) | ast::ExprKind::Cast(ref expr, _) => can_be_overflowed_expr(context, expr, args_len), @@ -1373,7 +1370,6 @@ pub(crate) fn is_nested_call(expr: &ast::Expr) -> bool { match expr.kind { ast::ExprKind::Call(..) | ast::ExprKind::MacCall(..) => true, ast::ExprKind::AddrOf(_, _, ref expr) - | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) | ast::ExprKind::Cast(ref expr, _) => is_nested_call(expr), @@ -2133,7 +2129,6 @@ pub(crate) fn is_method_call(expr: &ast::Expr) -> bool { match expr.kind { ast::ExprKind::MethodCall(..) => true, ast::ExprKind::AddrOf(_, _, ref expr) - | ast::ExprKind::Box(ref expr) | ast::ExprKind::Cast(ref expr, _) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) => is_method_call(expr), diff --git a/src/tools/rustfmt/src/matches.rs b/src/tools/rustfmt/src/matches.rs index 85d9c5d2b9b..aac5e59b860 100644 --- a/src/tools/rustfmt/src/matches.rs +++ b/src/tools/rustfmt/src/matches.rs @@ -592,7 +592,6 @@ fn can_flatten_block_around_this(body: &ast::Expr) -> bool { | ast::ExprKind::Struct(..) | ast::ExprKind::Tup(..) => true, ast::ExprKind::AddrOf(_, _, ref expr) - | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) | ast::ExprKind::Index(ref expr, _) diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs index 1e89f3ae75f..a26375ee643 100644 --- a/src/tools/rustfmt/src/utils.rs +++ b/src/tools/rustfmt/src/utils.rs @@ -492,7 +492,6 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr | ast::ExprKind::Assign(..) | ast::ExprKind::AssignOp(..) | ast::ExprKind::Await(..) - | ast::ExprKind::Box(..) | ast::ExprKind::Break(..) | ast::ExprKind::Cast(..) | ast::ExprKind::Continue(..) diff --git a/tests/ui/feature-gates/feature-gate-box-expr.rs b/tests/ui/feature-gates/feature-gate-box-expr.rs deleted file mode 100644 index 870253d2f05..00000000000 --- a/tests/ui/feature-gates/feature-gate-box-expr.rs +++ /dev/null @@ -1,14 +0,0 @@ -// gate-test-box_syntax - -// Check that `box EXPR` is feature-gated. -// -// See also feature-gate-placement-expr.rs -// -// (Note that the two tests are separated since the checks appear to -// be performed at distinct phases, with an abort_if_errors call -// separating them.) - -fn main() { - let x = box 'c'; //~ ERROR box expression syntax is experimental - println!("x: {}", x); -} diff --git a/tests/ui/feature-gates/feature-gate-box-expr.stderr b/tests/ui/feature-gates/feature-gate-box-expr.stderr deleted file mode 100644 index af864b25f14..00000000000 --- a/tests/ui/feature-gates/feature-gate-box-expr.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: box expression syntax is experimental; you can call `Box::new` instead - --> $DIR/feature-gate-box-expr.rs:12:13 - | -LL | let x = box 'c'; - | ^^^^^^^ - | - = note: see issue #49733 for more information - = help: add `#![feature(box_syntax)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-box_syntax.rs b/tests/ui/feature-gates/feature-gate-box_syntax.rs deleted file mode 100644 index 778660cc0b5..00000000000 --- a/tests/ui/feature-gates/feature-gate-box_syntax.rs +++ /dev/null @@ -1,6 +0,0 @@ -// Test that the use of the box syntax is gated by `box_syntax` feature gate. - -fn main() { - let x = box 3; - //~^ ERROR box expression syntax is experimental; you can call `Box::new` instead -} diff --git a/tests/ui/feature-gates/feature-gate-box_syntax.stderr b/tests/ui/feature-gates/feature-gate-box_syntax.stderr deleted file mode 100644 index dcf8eeed7cf..00000000000 --- a/tests/ui/feature-gates/feature-gate-box_syntax.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: box expression syntax is experimental; you can call `Box::new` instead - --> $DIR/feature-gate-box_syntax.rs:4:13 - | -LL | let x = box 3; - | ^^^^^ - | - = note: see issue #49733 for more information - = help: add `#![feature(box_syntax)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/parser/removed-syntax-box.rs b/tests/ui/parser/removed-syntax-box.rs new file mode 100644 index 00000000000..b0e8eb0410e --- /dev/null +++ b/tests/ui/parser/removed-syntax-box.rs @@ -0,0 +1,10 @@ +fn main() { + struct T { + a: u8, + b: u8, + } + let _ = box () //~ ERROR expected expression, found reserved keyword `box` + let _ = box 1; + let _ = box T { a: 12, b: 18 }; + let _ = box [5; 30]; +} diff --git a/tests/ui/parser/removed-syntax-box.stderr b/tests/ui/parser/removed-syntax-box.stderr new file mode 100644 index 00000000000..8c8d5b3c4cb --- /dev/null +++ b/tests/ui/parser/removed-syntax-box.stderr @@ -0,0 +1,8 @@ +error: expected expression, found reserved keyword `box` + --> $DIR/removed-syntax-box.rs:6:13 + | +LL | let _ = box () + | ^^^ expected expression + +error: aborting due to previous error +