Skip to content

Commit 0932452

Browse files
committed
Remove box_syntax from AST and use in tools
1 parent dd7df04 commit 0932452

File tree

28 files changed

+40
-95
lines changed

28 files changed

+40
-95
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,6 @@ impl Expr {
12301230

12311231
pub fn precedence(&self) -> ExprPrecedence {
12321232
match self.kind {
1233-
ExprKind::Box(_) => ExprPrecedence::Box,
12341233
ExprKind::Array(_) => ExprPrecedence::Array,
12351234
ExprKind::ConstBlock(_) => ExprPrecedence::ConstBlock,
12361235
ExprKind::Call(..) => ExprPrecedence::Call,
@@ -1291,8 +1290,7 @@ impl Expr {
12911290
/// To a first-order approximation, is this a pattern?
12921291
pub fn is_approximately_pattern(&self) -> bool {
12931292
match &self.peel_parens().kind {
1294-
ExprKind::Box(_)
1295-
| ExprKind::Array(_)
1293+
ExprKind::Array(_)
12961294
| ExprKind::Call(_, _)
12971295
| ExprKind::Tup(_)
12981296
| ExprKind::Lit(_)
@@ -1363,8 +1361,6 @@ pub struct StructExpr {
13631361

13641362
#[derive(Clone, Encodable, Decodable, Debug)]
13651363
pub enum ExprKind {
1366-
/// A `box x` expression.
1367-
Box(P<Expr>),
13681364
/// An array (`[a, b, c, d]`)
13691365
Array(ThinVec<P<Expr>>),
13701366
/// Allow anonymous constants from an inline `const` block

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,6 @@ pub fn noop_visit_expr<T: MutVisitor>(
13161316
vis: &mut T,
13171317
) {
13181318
match kind {
1319-
ExprKind::Box(expr) => vis.visit_expr(expr),
13201319
ExprKind::Array(exprs) => visit_thin_exprs(exprs, vis),
13211320
ExprKind::ConstBlock(anon_const) => {
13221321
vis.visit_anon_const(anon_const);

compiler/rustc_ast/src/util/classify.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> {
3535
| Assign(_, e, _)
3636
| AssignOp(_, _, e)
3737
| Binary(_, _, e)
38-
| Box(e)
3938
| Break(_, Some(e))
4039
| Let(_, e, _)
4140
| Range(_, Some(e), _)

compiler/rustc_ast/src/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,6 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
772772
walk_list!(visitor, visit_attribute, expression.attrs.iter());
773773

774774
match &expression.kind {
775-
ExprKind::Box(subexpression) => visitor.visit_expr(subexpression),
776775
ExprKind::Array(subexpressions) => {
777776
walk_list!(visitor, visit_expr, subexpressions);
778777
}

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
7070
self.lower_attrs(hir_id, &e.attrs);
7171

7272
let kind = match &e.kind {
73-
ExprKind::Box(inner) => hir::ExprKind::Box(self.lower_expr(inner)),
7473
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
7574
ExprKind::ConstBlock(anon_const) => {
7675
let anon_const = self.lower_anon_const(anon_const);

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
395395

396396
fn visit_expr(&mut self, e: &'a ast::Expr) {
397397
match e.kind {
398-
ast::ExprKind::Box(_) => {
399-
gate_feature_post!(
400-
&self,
401-
box_syntax,
402-
e.span,
403-
"box expression syntax is experimental; you can call `Box::new` instead"
404-
);
405-
}
406398
ast::ExprKind::Type(..) => {
407399
if self.sess.parse_sess.span_diagnostic.err_count() == 0 {
408400
// To avoid noise about type ascription in common syntax errors,
@@ -613,7 +605,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
613605
gate_all!(box_patterns, "box pattern syntax is experimental");
614606
gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental");
615607
gate_all!(try_blocks, "`try` blocks are unstable");
616-
gate_all!(box_syntax, "box expression syntax is experimental; you can call `Box::new` instead");
617608
gate_all!(type_ascription, "type ascription is experimental");
618609

619610
visit::walk_crate(&mut visitor, krate);

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,6 @@ impl<'a> State<'a> {
296296
self.ibox(INDENT_UNIT);
297297
self.ann.pre(self, AnnNode::Expr(expr));
298298
match &expr.kind {
299-
ast::ExprKind::Box(expr) => {
300-
self.word_space("box");
301-
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX);
302-
}
303299
ast::ExprKind::Array(exprs) => {
304300
self.print_expr_vec(exprs);
305301
}

compiler/rustc_builtin_macros/src/assert/context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ impl<'cx, 'a> Context<'cx, 'a> {
290290
| ExprKind::Async(_, _, _)
291291
| ExprKind::Await(_)
292292
| ExprKind::Block(_, _)
293-
| ExprKind::Box(_)
294293
| ExprKind::Break(_, _)
295294
| ExprKind::Closure(_)
296295
| ExprKind::ConstBlock(_)

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ declare_features! (
200200
(active, auto_traits, "1.50.0", Some(13231), None),
201201
/// Allows using `box` in patterns (RFC 469).
202202
(active, box_patterns, "1.0.0", Some(29641), None),
203-
/// Allows using the `box $expr` syntax.
204-
(active, box_syntax, "1.0.0", Some(49733), None),
205203
/// Allows `#[doc(notable_trait)]`.
206204
/// Renamed from `doc_spotlight`.
207205
(active, doc_notable_trait, "1.52.0", Some(45040), None),

compiler/rustc_feature/src/removed.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ declare_features! (
5252
(removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")),
5353
(removed, await_macro, "1.38.0", Some(50547), None,
5454
Some("subsumed by `.await` syntax")),
55+
/// Allows using the `box $expr` syntax.
56+
(removed, box_syntax, "CURRENT_RUSTC_VERSION", Some(49733), None, Some("replaced with `#[rustc_box]`")),
5557
/// Allows capturing disjoint fields in a closure/generator (RFC 2229).
5658
(removed, capture_disjoint_fields, "1.49.0", Some(53488), None, Some("stabilized in Rust 2021")),
5759
/// Allows comparing raw pointers during const eval.

0 commit comments

Comments
 (0)