Skip to content

Commit 756d4bb

Browse files
committed
Use box syntax everywhere
Result of running: rg -l "Box::new" compiler/ | rg '.rs$' | rg -v 'cranelift' | xargs sed -i 's/Box::new(/box (/'
1 parent 25b7648 commit 756d4bb

File tree

83 files changed

+237
-237
lines changed

Some content is hidden

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

83 files changed

+237
-237
lines changed

compiler/rustc_arena/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub fn bench_copy(b: &mut Bencher) {
9393
#[bench]
9494
pub fn bench_copy_nonarena(b: &mut Bencher) {
9595
b.iter(|| {
96-
let _: Box<_> = Box::new(Point { x: 1, y: 2, z: 3 });
96+
let _: Box<_> = box (Point { x: 1, y: 2, z: 3 });
9797
})
9898
}
9999

@@ -227,6 +227,6 @@ pub fn bench_noncopy(b: &mut Bencher) {
227227
pub fn bench_noncopy_nonarena(b: &mut Bencher) {
228228
b.iter(|| {
229229
let _: Box<_> =
230-
Box::new(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] });
230+
box (Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] });
231231
})
232232
}

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub struct LazyTokenStream(Lrc<Box<dyn CreateTokenStream>>);
141141

142142
impl LazyTokenStream {
143143
pub fn new(inner: impl CreateTokenStream + 'static) -> LazyTokenStream {
144-
LazyTokenStream(Lrc::new(Box::new(inner)))
144+
LazyTokenStream(Lrc::new(box (inner)))
145145
}
146146

147147
pub fn create_token_stream(&self) -> AttrAnnotatedTokenStream {

compiler/rustc_builtin_macros/src/concat_idents.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ pub fn expand_concat_idents<'cx>(
6666
}
6767
}
6868

69-
Box::new(ConcatIdentsResult { ident })
69+
box (ConcatIdentsResult { ident })
7070
}

compiler/rustc_builtin_macros/src/deriving/clone.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ pub fn expand_deriving_clone(
4545
{
4646
bounds = vec![];
4747
is_shallow = true;
48-
substructure = combine_substructure(Box::new(|c, s, sub| {
48+
substructure = combine_substructure(box (|c, s, sub| {
4949
cs_clone_shallow("Clone", c, s, sub, false)
5050
}));
5151
} else {
5252
bounds = vec![];
5353
is_shallow = false;
5454
substructure =
55-
combine_substructure(Box::new(|c, s, sub| cs_clone("Clone", c, s, sub)));
55+
combine_substructure(box (|c, s, sub| cs_clone("Clone", c, s, sub)));
5656
}
5757
}
5858
ItemKind::Union(..) => {
5959
bounds = vec![Literal(path_std!(marker::Copy))];
6060
is_shallow = true;
61-
substructure = combine_substructure(Box::new(|c, s, sub| {
61+
substructure = combine_substructure(box (|c, s, sub| {
6262
cs_clone_shallow("Clone", c, s, sub, true)
6363
}));
6464
}
6565
_ => {
6666
bounds = vec![];
6767
is_shallow = false;
6868
substructure =
69-
combine_substructure(Box::new(|c, s, sub| cs_clone("Clone", c, s, sub)));
69+
combine_substructure(box (|c, s, sub| cs_clone("Clone", c, s, sub)));
7070
}
7171
},
7272

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn expand_deriving_eq(
3838
attributes: attrs,
3939
is_unsafe: false,
4040
unify_fieldless_variants: true,
41-
combine_substructure: combine_substructure(Box::new(|a, b, c| {
41+
combine_substructure: combine_substructure(box (|a, b, c| {
4242
cs_total_eq_assert(a, b, c)
4343
})),
4444
}],

compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn expand_deriving_ord(
3434
attributes: attrs,
3535
is_unsafe: false,
3636
unify_fieldless_variants: true,
37-
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))),
37+
combine_substructure: combine_substructure(box (|a, b, c| cs_cmp(a, b, c))),
3838
}],
3939
associated_types: Vec::new(),
4040
};
@@ -100,7 +100,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
100100
cx.expr_match(span, new, vec![eq_arm, neq_arm])
101101
},
102102
cx.expr_path(equals_path.clone()),
103-
Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| {
103+
box (|cx, span, (self_args, tag_tuple), _non_self_args| {
104104
if self_args.len() != 2 {
105105
cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`")
106106
} else {

compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn expand_deriving_partial_eq(
4949
None => cx.expr_bool(span, base),
5050
}
5151
},
52-
Box::new(|cx, span, _, _| cx.expr_bool(span, !base)),
52+
box (|cx, span, _, _| cx.expr_bool(span, !base)),
5353
cx,
5454
span,
5555
substr,
@@ -76,7 +76,7 @@ pub fn expand_deriving_partial_eq(
7676
attributes: attrs,
7777
is_unsafe: false,
7878
unify_fieldless_variants: true,
79-
combine_substructure: combine_substructure(Box::new(|a, b, c| $f(a, b, c))),
79+
combine_substructure: combine_substructure(box (|a, b, c| $f(a, b, c))),
8080
}
8181
}};
8282
}

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn expand_deriving_partial_ord(
1919
let ret_ty = Literal(Path::new_(
2020
pathvec_std!(option::Option),
2121
None,
22-
vec![Box::new(ordering_ty)],
22+
vec![box (ordering_ty)],
2323
PathKind::Std,
2424
));
2525

@@ -35,7 +35,7 @@ pub fn expand_deriving_partial_ord(
3535
attributes: attrs,
3636
is_unsafe: false,
3737
unify_fieldless_variants: true,
38-
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
38+
combine_substructure: combine_substructure(box (|cx, span, substr| {
3939
cs_partial_cmp(cx, span, substr)
4040
})),
4141
};
@@ -103,7 +103,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
103103
cx.expr_match(span, new, vec![eq_arm, neq_arm])
104104
},
105105
equals_expr,
106-
Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| {
106+
box (|cx, span, (self_args, tag_tuple), _non_self_args| {
107107
if self_args.len() != 2 {
108108
cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
109109
} else {

compiler/rustc_builtin_macros/src/deriving/debug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn expand_deriving_debug(
2121
) {
2222
// &mut ::std::fmt::Formatter
2323
let fmtr =
24-
Ptr(Box::new(Literal(path_std!(fmt::Formatter))), Borrowed(None, ast::Mutability::Mut));
24+
Ptr(box (Literal(path_std!(fmt::Formatter))), Borrowed(None, ast::Mutability::Mut));
2525

2626
let trait_def = TraitDef {
2727
span,
@@ -40,7 +40,7 @@ pub fn expand_deriving_debug(
4040
attributes: Vec::new(),
4141
is_unsafe: false,
4242
unify_fieldless_variants: false,
43-
combine_substructure: combine_substructure(Box::new(|a, b, c| {
43+
combine_substructure: combine_substructure(box (|a, b, c| {
4444
show_substructure(a, b, c)
4545
})),
4646
}],

compiler/rustc_builtin_macros/src/deriving/decodable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ pub fn expand_deriving_rustc_decodable(
3838
},
3939
explicit_self: None,
4040
args: vec![(
41-
Ptr(Box::new(Literal(Path::new_local(typaram))), Borrowed(None, Mutability::Mut)),
41+
Ptr(box (Literal(Path::new_local(typaram))), Borrowed(None, Mutability::Mut)),
4242
sym::d,
4343
)],
4444
ret_ty: Literal(Path::new_(
4545
pathvec_std!(result::Result),
4646
None,
4747
vec![
48-
Box::new(Self_),
49-
Box::new(Literal(Path::new_(
48+
box (Self_),
49+
box (Literal(Path::new_(
5050
vec![typaram, sym::Error],
5151
None,
5252
vec![],
@@ -58,7 +58,7 @@ pub fn expand_deriving_rustc_decodable(
5858
attributes: Vec::new(),
5959
is_unsafe: false,
6060
unify_fieldless_variants: false,
61-
combine_substructure: combine_substructure(Box::new(|a, b, c| {
61+
combine_substructure: combine_substructure(box (|a, b, c| {
6262
decodable_substructure(a, b, c, krate)
6363
})),
6464
}],

compiler/rustc_builtin_macros/src/deriving/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn expand_deriving_default(
4141
attributes: attrs,
4242
is_unsafe: false,
4343
unify_fieldless_variants: false,
44-
combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| {
44+
combine_substructure: combine_substructure(box (|cx, trait_span, substr| {
4545
match substr.fields {
4646
StaticStruct(_, fields) => {
4747
default_struct_substructure(cx, trait_span, substr, fields)

compiler/rustc_builtin_macros/src/deriving/encodable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ pub fn expand_deriving_rustc_encodable(
123123
},
124124
explicit_self: borrowed_explicit_self(),
125125
args: vec![(
126-
Ptr(Box::new(Literal(Path::new_local(typaram))), Borrowed(None, Mutability::Mut)),
126+
Ptr(box (Literal(Path::new_local(typaram))), Borrowed(None, Mutability::Mut)),
127127
sym::s,
128128
)],
129129
ret_ty: Literal(Path::new_(
130130
pathvec_std!(result::Result),
131131
None,
132132
vec![
133-
Box::new(Tuple(Vec::new())),
134-
Box::new(Literal(Path::new_(
133+
box (Tuple(Vec::new())),
134+
box (Literal(Path::new_(
135135
vec![typaram, sym::Error],
136136
None,
137137
vec![],
@@ -143,7 +143,7 @@ pub fn expand_deriving_rustc_encodable(
143143
attributes: Vec::new(),
144144
is_unsafe: false,
145145
unify_fieldless_variants: false,
146-
combine_substructure: combine_substructure(Box::new(|a, b, c| {
146+
combine_substructure: combine_substructure(box (|a, b, c| {
147147
encodable_substructure(a, b, c, krate)
148148
})),
149149
}],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn borrowed_explicit_self() -> Option<Option<PtrTy>> {
113113
}
114114

115115
pub fn borrowed_self() -> Ty {
116-
borrowed(Box::new(Self_))
116+
borrowed(box (Self_))
117117
}
118118

119119
pub fn nil_ty() -> Ty {

compiler/rustc_builtin_macros/src/deriving/hash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ pub fn expand_deriving_hash(
3232
name: sym::hash,
3333
generics: Bounds { bounds: vec![(typaram, vec![path_std!(hash::Hasher)])] },
3434
explicit_self: borrowed_explicit_self(),
35-
args: vec![(Ptr(Box::new(Literal(arg)), Borrowed(None, Mutability::Mut)), sym::state)],
35+
args: vec![(Ptr(box (Literal(arg)), Borrowed(None, Mutability::Mut)), sym::state)],
3636
ret_ty: nil_ty(),
3737
attributes: vec![],
3838
is_unsafe: false,
3939
unify_fieldless_variants: true,
40-
combine_substructure: combine_substructure(Box::new(|a, b, c| {
40+
combine_substructure: combine_substructure(box (|a, b, c| {
4141
hash_substructure(a, b, c)
4242
})),
4343
}],

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ pub mod test_harness;
5151
pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
5252
let mut register = |name, kind| resolver.register_builtin_macro(name, kind);
5353
macro register_bang($($name:ident: $f:expr,)*) {
54-
$(register(sym::$name, SyntaxExtensionKind::LegacyBang(Box::new($f as MacroExpanderFn)));)*
54+
$(register(sym::$name, SyntaxExtensionKind::LegacyBang(box ($f as MacroExpanderFn)));)*
5555
}
5656
macro register_attr($($name:ident: $f:expr,)*) {
57-
$(register(sym::$name, SyntaxExtensionKind::LegacyAttr(Box::new($f)));)*
57+
$(register(sym::$name, SyntaxExtensionKind::LegacyAttr(box ($f)));)*
5858
}
5959
macro register_derive($($name:ident: $f:expr,)*) {
60-
$(register(sym::$name, SyntaxExtensionKind::LegacyDerive(Box::new(BuiltinDerive($f))));)*
60+
$(register(sym::$name, SyntaxExtensionKind::LegacyDerive(box (BuiltinDerive($f))));)*
6161
}
6262

6363
register_bang! {
@@ -113,5 +113,5 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
113113
}
114114

115115
let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
116-
register(sym::quote, SyntaxExtensionKind::Bang(Box::new(BangProcMacro { client })));
116+
register(sym::quote, SyntaxExtensionKind::Bang(box (BangProcMacro { client })));
117117
}

compiler/rustc_builtin_macros/src/source_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn expand_include<'cx>(
159159
}
160160
}
161161

162-
Box::new(ExpandResult { p, node_id: cx.current_expansion.lint_node_id })
162+
box (ExpandResult { p, node_id: cx.current_expansion.lint_node_id })
163163
}
164164

165165
// include_str! : read the given file, insert it as a literal string expr

compiler/rustc_codegen_llvm/src/back/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
284284
self.additions.push(Addition::Archive {
285285
path: archive.to_path_buf(),
286286
archive: archive_ro,
287-
skip: Box::new(skip),
287+
skip: box (skip),
288288
});
289289
Ok(())
290290
}

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl<'a> DiagnosticHandlers<'a> {
249249
handler: &'a Handler,
250250
llcx: &'a llvm::Context,
251251
) -> Self {
252-
let data = Box::into_raw(Box::new((cgcx, handler)));
252+
let data = Box::into_raw(box ((cgcx, handler)));
253253
unsafe {
254254
llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data.cast());
255255
llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data.cast());

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ unsafe impl Sync for LlvmCodegenBackend {}
197197

198198
impl LlvmCodegenBackend {
199199
pub fn new() -> Box<dyn CodegenBackend> {
200-
Box::new(LlvmCodegenBackend(()))
200+
box (LlvmCodegenBackend(()))
201201
}
202202
}
203203

@@ -253,7 +253,7 @@ impl CodegenBackend for LlvmCodegenBackend {
253253
metadata: EncodedMetadata,
254254
need_metadata_module: bool,
255255
) -> Box<dyn Any> {
256-
Box::new(rustc_codegen_ssa::base::codegen_crate(
256+
box (rustc_codegen_ssa::base::codegen_crate(
257257
LlvmCodegenBackend(()),
258258
tcx,
259259
crate::llvm_util::target_cpu(tcx.sess).to_string(),

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,26 @@ pub fn get_linker<'a>(
130130

131131
match flavor {
132132
LinkerFlavor::Lld(LldFlavor::Link) | LinkerFlavor::Msvc => {
133-
Box::new(MsvcLinker { cmd, sess }) as Box<dyn Linker>
133+
box (MsvcLinker { cmd, sess }) as Box<dyn Linker>
134134
}
135-
LinkerFlavor::Em => Box::new(EmLinker { cmd, sess }) as Box<dyn Linker>,
135+
LinkerFlavor::Em => box (EmLinker { cmd, sess }) as Box<dyn Linker>,
136136
LinkerFlavor::Gcc => {
137-
Box::new(GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: false })
137+
box (GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: false })
138138
as Box<dyn Linker>
139139
}
140140

141141
LinkerFlavor::Lld(LldFlavor::Ld)
142142
| LinkerFlavor::Lld(LldFlavor::Ld64)
143143
| LinkerFlavor::Ld => {
144-
Box::new(GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: true })
144+
box (GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: true })
145145
as Box<dyn Linker>
146146
}
147147

148-
LinkerFlavor::Lld(LldFlavor::Wasm) => Box::new(WasmLd::new(cmd, sess)) as Box<dyn Linker>,
148+
LinkerFlavor::Lld(LldFlavor::Wasm) => box (WasmLd::new(cmd, sess)) as Box<dyn Linker>,
149149

150-
LinkerFlavor::PtxLinker => Box::new(PtxLinker { cmd, sess }) as Box<dyn Linker>,
150+
LinkerFlavor::PtxLinker => box (PtxLinker { cmd, sess }) as Box<dyn Linker>,
151151

152-
LinkerFlavor::BpfLinker => Box::new(BpfLinker { cmd, sess }) as Box<dyn Linker>,
152+
LinkerFlavor::BpfLinker => box (BpfLinker { cmd, sess }) as Box<dyn Linker>,
153153
}
154154
}
155155

0 commit comments

Comments
 (0)