Skip to content

Commit dd7df04

Browse files
committed
Remove uses of box_syntax in rustc and tools
1 parent 24c0b81 commit dd7df04

File tree

80 files changed

+851
-944
lines changed

Some content is hidden

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

80 files changed

+851
-944
lines changed

compiler/rustc_codegen_cranelift/example/alloc_example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(start, core_intrinsics, alloc_error_handler, box_syntax)]
1+
#![feature(start, core_intrinsics, alloc_error_handler)]
22
#![no_std]
33

44
extern crate alloc;
@@ -29,7 +29,7 @@ fn alloc_error_handler(_: alloc::alloc::Layout) -> ! {
2929

3030
#[start]
3131
fn main(_argc: isize, _argv: *const *const u8) -> isize {
32-
let world: Box<&str> = box "Hello World!\0";
32+
let world: Box<&str> = Box::new("Hello World!\0");
3333
unsafe {
3434
puts(*world as *const str as *const u8);
3535
}

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, box_syntax)]
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

@@ -178,7 +178,7 @@ fn main() {
178178
let ptr: *const i8 = hello as *const [u8] as *const i8;
179179
puts(ptr);
180180

181-
let world: Box<&str> = box "World!\0";
181+
let world: Box<&str> = Box::new("World!\0");
182182
puts(*world as *const str as *const i8);
183183
world as Box<dyn SomeTrait>;
184184

@@ -238,10 +238,10 @@ fn main() {
238238
}
239239
}
240240

241-
let _ = box NoisyDrop {
241+
let _ = Box::new(NoisyDrop {
242242
text: "Boxed outer got dropped!\0",
243243
inner: NoisyDropInner,
244-
} as Box<dyn SomeTrait>;
244+
}) as Box<dyn SomeTrait>;
245245

246246
const FUNC_REF: Option<fn()> = Some(main);
247247
match FUNC_REF {

compiler/rustc_codegen_gcc/example/alloc_example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(start, box_syntax, core_intrinsics, alloc_error_handler, lang_items)]
1+
#![feature(start, core_intrinsics, alloc_error_handler, lang_items)]
22
#![no_std]
33

44
extern crate alloc;
@@ -38,7 +38,7 @@ unsafe extern "C" fn _Unwind_Resume() {
3838

3939
#[start]
4040
fn main(_argc: isize, _argv: *const *const u8) -> isize {
41-
let world: Box<&str> = box "Hello World!\0";
41+
let world: Box<&str> = Box::new("Hello World!\0");
4242
unsafe {
4343
puts(*world as *const str as *const u8);
4444
}

compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs
22

33
#![feature(
4-
no_core, unboxed_closures, start, lang_items, box_syntax, never_type, linkage,
4+
no_core, unboxed_closures, start, lang_items, never_type, linkage,
55
extern_types, thread_local
66
)]
77
#![no_core]
@@ -163,7 +163,7 @@ fn main() {
163163
let ptr: *const u8 = hello as *const [u8] as *const u8;
164164
puts(ptr);
165165

166-
let world: Box<&str> = box "World!\0";
166+
let world: Box<&str> = Box::new("World!\0");
167167
puts(*world as *const str as *const u8);
168168
world as Box<dyn SomeTrait>;
169169

@@ -223,10 +223,10 @@ fn main() {
223223
}
224224
}
225225

226-
let _ = box NoisyDrop {
226+
let _ = Box::new(NoisyDrop {
227227
text: "Boxed outer got dropped!\0",
228228
inner: NoisyDropInner,
229-
} as Box<dyn SomeTrait>;
229+
}) as Box<dyn SomeTrait>;
230230

231231
const FUNC_REF: Option<fn()> = Some(main);
232232
#[allow(unreachable_code)]

compiler/rustc_codegen_gcc/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
#[link(name = "c")]

compiler/rustc_error_codes/src/error_codes/E0010.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ the heap at runtime, and therefore cannot be done at compile time.
55
Erroneous code example:
66

77
```compile_fail,E0010
8-
#![feature(box_syntax)]
9-
10-
const CON : Box<i32> = box 0;
8+
const CON : Vec<i32> = vec![1, 2, 3];
119
```

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,8 +1367,8 @@ impl<'a> State<'a> {
13671367
self.ann.pre(self, AnnNode::Expr(expr));
13681368
match expr.kind {
13691369
hir::ExprKind::Box(expr) => {
1370-
self.word_space("box");
1371-
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX);
1370+
self.word_space("Box::new");
1371+
self.print_call_post(std::slice::from_ref(expr));
13721372
}
13731373
hir::ExprKind::Array(exprs) => {
13741374
self.print_expr_vec(exprs);

compiler/rustc_lint/src/unused.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,6 @@ declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]);
13711371
impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
13721372
fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
13731373
match e.kind {
1374-
hir::ExprKind::Box(_) => {}
13751374
hir::ExprKind::Call(path_expr, [_])
13761375
if let hir::ExprKind::Path(qpath) = &path_expr.kind
13771376
&& let Some(did) = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id()

compiler/rustc_mir_transform/src/large_enums.rs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,12 @@ impl EnumSizeOpt {
158158
tmp_ty,
159159
),
160160
};
161-
let rval = Rvalue::Use(Operand::Constant(box (constant_vals)));
161+
let rval = Rvalue::Use(Operand::Constant(Box::new(constant_vals)));
162162

163-
let const_assign =
164-
Statement { source_info, kind: StatementKind::Assign(box (place, rval)) };
163+
let const_assign = Statement {
164+
source_info,
165+
kind: StatementKind::Assign(Box::new((place, rval))),
166+
};
165167

166168
let discr_place = Place::from(
167169
local_decls
@@ -170,48 +172,51 @@ impl EnumSizeOpt {
170172

171173
let store_discr = Statement {
172174
source_info,
173-
kind: StatementKind::Assign(box (discr_place, Rvalue::Discriminant(*rhs))),
175+
kind: StatementKind::Assign(Box::new((
176+
discr_place,
177+
Rvalue::Discriminant(*rhs),
178+
))),
174179
};
175180

176181
let discr_cast_place =
177182
Place::from(local_decls.push(LocalDecl::new(tcx.types.usize, span)));
178183

179184
let cast_discr = Statement {
180185
source_info,
181-
kind: StatementKind::Assign(box (
186+
kind: StatementKind::Assign(Box::new((
182187
discr_cast_place,
183188
Rvalue::Cast(
184189
CastKind::IntToInt,
185190
Operand::Copy(discr_place),
186191
tcx.types.usize,
187192
),
188-
)),
193+
))),
189194
};
190195

191196
let size_place =
192197
Place::from(local_decls.push(LocalDecl::new(tcx.types.usize, span)));
193198

194199
let store_size = Statement {
195200
source_info,
196-
kind: StatementKind::Assign(box (
201+
kind: StatementKind::Assign(Box::new((
197202
size_place,
198203
Rvalue::Use(Operand::Copy(Place {
199204
local: size_array_local,
200205
projection: tcx
201206
.mk_place_elems(&[PlaceElem::Index(discr_cast_place.local)]),
202207
})),
203-
)),
208+
))),
204209
};
205210

206211
let dst =
207212
Place::from(local_decls.push(LocalDecl::new(tcx.mk_mut_ptr(ty), span)));
208213

209214
let dst_ptr = Statement {
210215
source_info,
211-
kind: StatementKind::Assign(box (
216+
kind: StatementKind::Assign(Box::new((
212217
dst,
213218
Rvalue::AddressOf(Mutability::Mut, *lhs),
214-
)),
219+
))),
215220
};
216221

217222
let dst_cast_ty = tcx.mk_mut_ptr(tcx.types.u8);
@@ -220,21 +225,21 @@ impl EnumSizeOpt {
220225

221226
let dst_cast = Statement {
222227
source_info,
223-
kind: StatementKind::Assign(box (
228+
kind: StatementKind::Assign(Box::new((
224229
dst_cast_place,
225230
Rvalue::Cast(CastKind::PtrToPtr, Operand::Copy(dst), dst_cast_ty),
226-
)),
231+
))),
227232
};
228233

229234
let src =
230235
Place::from(local_decls.push(LocalDecl::new(tcx.mk_imm_ptr(ty), span)));
231236

232237
let src_ptr = Statement {
233238
source_info,
234-
kind: StatementKind::Assign(box (
239+
kind: StatementKind::Assign(Box::new((
235240
src,
236241
Rvalue::AddressOf(Mutability::Not, *rhs),
237-
)),
242+
))),
238243
};
239244

240245
let src_cast_ty = tcx.mk_imm_ptr(tcx.types.u8);
@@ -243,24 +248,24 @@ impl EnumSizeOpt {
243248

244249
let src_cast = Statement {
245250
source_info,
246-
kind: StatementKind::Assign(box (
251+
kind: StatementKind::Assign(Box::new((
247252
src_cast_place,
248253
Rvalue::Cast(CastKind::PtrToPtr, Operand::Copy(src), src_cast_ty),
249-
)),
254+
))),
250255
};
251256

252257
let deinit_old =
253-
Statement { source_info, kind: StatementKind::Deinit(box dst) };
258+
Statement { source_info, kind: StatementKind::Deinit(Box::new(dst)) };
254259

255260
let copy_bytes = Statement {
256261
source_info,
257-
kind: StatementKind::Intrinsic(
258-
box NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
262+
kind: StatementKind::Intrinsic(Box::new(
263+
NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
259264
src: Operand::Copy(src_cast_place),
260265
dst: Operand::Copy(dst_cast_place),
261266
count: Operand::Copy(size_place),
262267
}),
263-
),
268+
)),
264269
};
265270

266271
let store_dead = Statement {

compiler/rustc_mir_transform/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(rustc::potential_query_instability)]
22
#![feature(box_patterns)]
33
#![feature(drain_filter)]
4-
#![feature(box_syntax)]
54
#![feature(let_chains)]
65
#![feature(map_try_insert)]
76
#![feature(min_specialization)]

0 commit comments

Comments
 (0)