Skip to content

Commit ba8cda2

Browse files
committed
Auto merge of #87781 - est31:remove_box, r=oli-obk
Remove box syntax from compiler and tools Removes box syntax from the compiler and tools. In #49733, the future of box syntax is uncertain and the use in the compiler was listed as one of the reasons to keep it. Removal of box syntax [might affect the code generated](#49646 (comment)) and slow down the compiler so I'd recommend doing a perf run on this.
2 parents 896f058 + 0f08183 commit ba8cda2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+549
-505
lines changed

compiler/rustc_ast/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
99
test(attr(deny(warnings)))
1010
)]
11-
#![feature(box_syntax)]
1211
#![feature(box_patterns)]
1312
#![cfg_attr(bootstrap, feature(const_fn_transmute))]
1413
#![feature(crate_visibility_modifier)]

compiler/rustc_ast/src/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct P<T: ?Sized> {
3737
/// Construct a `P<T>` from a `T` value.
3838
#[allow(non_snake_case)]
3939
pub fn P<T: 'static>(value: T) -> P<T> {
40-
P { ptr: box value }
40+
P { ptr: Box::new(value) }
4141
}
4242

4343
impl<T: 'static> P<T> {

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,12 @@ impl<'a> TraitDef<'a> {
527527
tokens: None,
528528
},
529529
attrs: Vec::new(),
530-
kind: ast::AssocItemKind::TyAlias(box ast::TyAliasKind(
530+
kind: ast::AssocItemKind::TyAlias(Box::new(ast::TyAliasKind(
531531
ast::Defaultness::Final,
532532
Generics::default(),
533533
Vec::new(),
534534
Some(type_def.to_ty(cx, self.span, type_ident, generics)),
535-
)),
535+
))),
536536
tokens: None,
537537
})
538538
});
@@ -698,7 +698,7 @@ impl<'a> TraitDef<'a> {
698698
self.span,
699699
Ident::invalid(),
700700
a,
701-
ast::ItemKind::Impl(box ast::ImplKind {
701+
ast::ItemKind::Impl(Box::new(ast::ImplKind {
702702
unsafety,
703703
polarity: ast::ImplPolarity::Positive,
704704
defaultness: ast::Defaultness::Final,
@@ -707,7 +707,7 @@ impl<'a> TraitDef<'a> {
707707
of_trait: opt_trait_ref,
708708
self_ty: self_type,
709709
items: methods.into_iter().chain(associated_types).collect(),
710-
}),
710+
})),
711711
)
712712
}
713713

@@ -940,7 +940,12 @@ impl<'a> MethodDef<'a> {
940940
tokens: None,
941941
},
942942
ident: method_ident,
943-
kind: ast::AssocItemKind::Fn(box ast::FnKind(def, sig, fn_generics, Some(body_block))),
943+
kind: ast::AssocItemKind::Fn(Box::new(ast::FnKind(
944+
def,
945+
sig,
946+
fn_generics,
947+
Some(body_block),
948+
))),
944949
tokens: None,
945950
})
946951
}

compiler/rustc_builtin_macros/src/deriving/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn inject_impl_of_structural_trait(
179179
span,
180180
Ident::invalid(),
181181
attrs,
182-
ItemKind::Impl(box ImplKind {
182+
ItemKind::Impl(Box::new(ImplKind {
183183
unsafety: ast::Unsafe::No,
184184
polarity: ast::ImplPolarity::Positive,
185185
defaultness: ast::Defaultness::Final,
@@ -188,7 +188,7 @@ fn inject_impl_of_structural_trait(
188188
of_trait: Some(trait_ref),
189189
self_ty: self_type,
190190
items: Vec::new(),
191-
}),
191+
})),
192192
);
193193

194194
push(Annotatable::Item(newitem));

compiler/rustc_builtin_macros/src/global_allocator.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ impl AllocFnFactory<'_, '_> {
8585
let header = FnHeader { unsafety: Unsafe::Yes(self.span), ..FnHeader::default() };
8686
let sig = FnSig { decl, header, span: self.span };
8787
let block = Some(self.cx.block_expr(output_expr));
88-
let kind =
89-
ItemKind::Fn(box FnKind(ast::Defaultness::Final, sig, Generics::default(), block));
88+
let kind = ItemKind::Fn(Box::new(FnKind(
89+
ast::Defaultness::Final,
90+
sig,
91+
Generics::default(),
92+
block,
93+
)));
9094
let item = self.cx.item(
9195
self.span,
9296
Ident::from_str_and_span(&self.kind.fn_name(method.name), self.span),

compiler/rustc_builtin_macros/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
55
#![feature(box_patterns)]
6-
#![feature(box_syntax)]
76
#![feature(bool_to_option)]
87
#![feature(crate_visibility_modifier)]
98
#![feature(decl_macro)]

compiler/rustc_builtin_macros/src/test_harness.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,12 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
315315
let decl = ecx.fn_decl(vec![], ast::FnRetTy::Ty(main_ret_ty));
316316
let sig = ast::FnSig { decl, header: ast::FnHeader::default(), span: sp };
317317
let def = ast::Defaultness::Final;
318-
let main =
319-
ast::ItemKind::Fn(box ast::FnKind(def, sig, ast::Generics::default(), Some(main_body)));
318+
let main = ast::ItemKind::Fn(Box::new(ast::FnKind(
319+
def,
320+
sig,
321+
ast::Generics::default(),
322+
Some(main_body),
323+
)));
320324

321325
// Honor the reexport_test_harness_main attribute
322326
let main_id = match cx.reexport_test_harness_main {

compiler/rustc_codegen_cranelift/example/alloc_example.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(start, box_syntax, core_intrinsics, alloc_prelude, alloc_error_handler)]
1+
#![feature(start, core_intrinsics, alloc_prelude, alloc_error_handler)]
22
#![no_std]
33

44
extern crate alloc;

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(no_core, lang_items, box_syntax, never_type, linkage, extern_types, thread_local)]
1+
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local)]
22
#![no_core]
33
#![allow(dead_code, non_camel_case_types)]
44

compiler/rustc_codegen_cranelift/example/mod_bench.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(start, box_syntax, core_intrinsics, lang_items)]
1+
#![feature(start, core_intrinsics, lang_items)]
22
#![no_std]
33

44
#[cfg_attr(unix, link(name = "c"))]

compiler/rustc_infer/src/infer/equate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
105105
b: ty::Region<'tcx>,
106106
) -> RelateResult<'tcx, ty::Region<'tcx>> {
107107
debug!("{}.regions({:?}, {:?})", self.tag(), a, b);
108-
let origin = Subtype(box self.fields.trace.clone());
108+
let origin = Subtype(Box::new(self.fields.trace.clone()));
109109
self.fields
110110
.infcx
111111
.inner

compiler/rustc_infer/src/infer/glb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
6767
) -> RelateResult<'tcx, ty::Region<'tcx>> {
6868
debug!("{}.regions({:?}, {:?})", self.tag(), a, b);
6969

70-
let origin = Subtype(box self.fields.trace.clone());
70+
let origin = Subtype(Box::new(self.fields.trace.clone()));
7171
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions(
7272
self.tcx(),
7373
origin,

compiler/rustc_infer/src/infer/lub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl TypeRelation<'tcx> for Lub<'combine, 'infcx, 'tcx> {
6767
) -> RelateResult<'tcx, ty::Region<'tcx>> {
6868
debug!("{}.regions({:?}, {:?})", self.tag(), a, b);
6969

70-
let origin = Subtype(box self.fields.trace.clone());
70+
let origin = Subtype(Box::new(self.fields.trace.clone()));
7171
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions(
7272
self.tcx(),
7373
origin,

compiler/rustc_infer/src/infer/sub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
142142
// FIXME -- we have more fine-grained information available
143143
// from the "cause" field, we could perhaps give more tailored
144144
// error messages.
145-
let origin = SubregionOrigin::Subtype(box self.fields.trace.clone());
145+
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
146146
self.fields
147147
.infcx
148148
.inner

compiler/rustc_infer/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1616
#![feature(bool_to_option)]
1717
#![feature(box_patterns)]
18-
#![feature(box_syntax)]
1918
#![feature(extend_one)]
2019
#![feature(iter_zip)]
2120
#![feature(never_type)]

compiler/rustc_lint/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![cfg_attr(test, feature(test))]
3030
#![feature(array_windows)]
3131
#![feature(bool_to_option)]
32-
#![feature(box_syntax)]
3332
#![feature(box_patterns)]
3433
#![feature(crate_visibility_modifier)]
3534
#![feature(format_args_capture)]
@@ -246,7 +245,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
246245
macro_rules! register_pass {
247246
($method:ident, $ty:ident, $constructor:expr) => {
248247
store.register_lints(&$ty::get_lints());
249-
store.$method(|| box $constructor);
248+
store.$method(|| Box::new($constructor));
250249
};
251250
}
252251

@@ -478,13 +477,13 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
478477

479478
fn register_internals(store: &mut LintStore) {
480479
store.register_lints(&LintPassImpl::get_lints());
481-
store.register_early_pass(|| box LintPassImpl);
480+
store.register_early_pass(|| Box::new(LintPassImpl));
482481
store.register_lints(&DefaultHashTypes::get_lints());
483-
store.register_late_pass(|| box DefaultHashTypes);
482+
store.register_late_pass(|| Box::new(DefaultHashTypes));
484483
store.register_lints(&ExistingDocKeyword::get_lints());
485-
store.register_late_pass(|| box ExistingDocKeyword);
484+
store.register_late_pass(|| Box::new(ExistingDocKeyword));
486485
store.register_lints(&TyTyKind::get_lints());
487-
store.register_late_pass(|| box TyTyKind);
486+
store.register_late_pass(|| Box::new(TyTyKind));
488487
store.register_group(
489488
false,
490489
"rustc::internal",

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![feature(backtrace)]
3030
#![feature(bool_to_option)]
3131
#![feature(box_patterns)]
32-
#![feature(box_syntax)]
3332
#![feature(core_intrinsics)]
3433
#![feature(discriminant_kind)]
3534
#![feature(never_type)]

compiler/rustc_middle/src/mir/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2061,11 +2061,11 @@ impl<'tcx> Operand<'tcx> {
20612061
span: Span,
20622062
) -> Self {
20632063
let ty = tcx.type_of(def_id).subst(tcx, substs);
2064-
Operand::Constant(box Constant {
2064+
Operand::Constant(Box::new(Constant {
20652065
span,
20662066
user_ty: None,
20672067
literal: ConstantKind::Ty(ty::Const::zero_sized(tcx, ty)),
2068-
})
2068+
}))
20692069
}
20702070

20712071
pub fn is_move(&self) -> bool {
@@ -2092,11 +2092,11 @@ impl<'tcx> Operand<'tcx> {
20922092
};
20932093
scalar_size == type_size
20942094
});
2095-
Operand::Constant(box Constant {
2095+
Operand::Constant(Box::new(Constant {
20962096
span,
20972097
user_ty: None,
20982098
literal: ConstantKind::Val(ConstValue::Scalar(val), ty),
2099-
})
2099+
}))
21002100
}
21012101

21022102
pub fn to_copy(&self) -> Self {

compiler/rustc_middle/src/mir/type_foldable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
182182
Len(place) => Len(place.fold_with(folder)),
183183
Cast(kind, op, ty) => Cast(kind, op.fold_with(folder), ty.fold_with(folder)),
184184
BinaryOp(op, box (rhs, lhs)) => {
185-
BinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder)))
185+
BinaryOp(op, Box::new((rhs.fold_with(folder), lhs.fold_with(folder))))
186186
}
187187
CheckedBinaryOp(op, box (rhs, lhs)) => {
188-
CheckedBinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder)))
188+
CheckedBinaryOp(op, Box::new((rhs.fold_with(folder), lhs.fold_with(folder))))
189189
}
190190
UnaryOp(op, val) => UnaryOp(op, val.fold_with(folder)),
191191
Discriminant(place) => Discriminant(place.fold_with(folder)),

compiler/rustc_mir/src/borrow_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ fn do_mir_borrowck<'a, 'tcx>(
464464

465465
let body_with_facts = if return_body_with_facts {
466466
let output_facts = mbcx.polonius_output.expect("Polonius output was not computed");
467-
Some(box BodyWithBorrowckFacts {
467+
Some(Box::new(BodyWithBorrowckFacts {
468468
body: body_owned,
469469
input_facts: *polonius_input.expect("Polonius input facts were not generated"),
470470
output_facts,
471471
location_table: location_table_owned,
472-
})
472+
}))
473473
} else {
474474
None
475475
};

compiler/rustc_mir/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Rust MIR: a lowered representation of Rust.
1111
#![cfg_attr(bootstrap, feature(bindings_after_at))]
1212
#![feature(bool_to_option)]
1313
#![feature(box_patterns)]
14-
#![feature(box_syntax)]
1514
#![feature(crate_visibility_modifier)]
1615
#![feature(decl_macro)]
1716
#![feature(exact_size_is_empty)]

0 commit comments

Comments
 (0)