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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 5 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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"))]

0 commit comments

Comments
 (0)