Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8b0b7ef

Browse files
committed
Remove box syntax from rustc_mir_build
1 parent cbe3afe commit 8b0b7ef

File tree

14 files changed

+74
-59
lines changed

14 files changed

+74
-59
lines changed

compiler/rustc_mir_build/src/build/cfg.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'tcx> CFG<'tcx> {
4040
) {
4141
self.push(
4242
block,
43-
Statement { source_info, kind: StatementKind::Assign(box (place, rvalue)) },
43+
Statement { source_info, kind: StatementKind::Assign(Box::new((place, rvalue))) },
4444
);
4545
}
4646

@@ -51,7 +51,12 @@ impl<'tcx> CFG<'tcx> {
5151
temp: Place<'tcx>,
5252
constant: Constant<'tcx>,
5353
) {
54-
self.push_assign(block, source_info, temp, Rvalue::Use(Operand::Constant(box constant)));
54+
self.push_assign(
55+
block,
56+
source_info,
57+
temp,
58+
Rvalue::Use(Operand::Constant(Box::new(constant))),
59+
);
5560
}
5661

5762
crate fn push_assign_unit(
@@ -65,11 +70,11 @@ impl<'tcx> CFG<'tcx> {
6570
block,
6671
source_info,
6772
place,
68-
Rvalue::Use(Operand::Constant(box Constant {
73+
Rvalue::Use(Operand::Constant(Box::new(Constant {
6974
span: source_info.span,
7075
user_ty: None,
7176
literal: ty::Const::zero_sized(tcx, tcx.types.unit).into(),
72-
})),
77+
}))),
7378
);
7479
}
7580

@@ -80,7 +85,7 @@ impl<'tcx> CFG<'tcx> {
8085
cause: FakeReadCause,
8186
place: Place<'tcx>,
8287
) {
83-
let kind = StatementKind::FakeRead(box (cause, place));
88+
let kind = StatementKind::FakeRead(Box::new((cause, place)));
8489
let stmt = Statement { source_info, kind };
8590
self.push(block, stmt);
8691
}

compiler/rustc_mir_build/src/build/expr/as_operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
111111
match category {
112112
Category::Constant => {
113113
let constant = this.as_constant(expr);
114-
block.and(Operand::Constant(box constant))
114+
block.and(Operand::Constant(Box::new(constant)))
115115
}
116116
Category::Place | Category::Rvalue(..) => {
117117
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));

compiler/rustc_mir_build/src/build/expr/as_place.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
507507
Statement {
508508
source_info,
509509
kind: StatementKind::AscribeUserType(
510-
box (
510+
Box::new((
511511
place,
512512
UserTypeProjection { base: annotation_index, projs: vec![] },
513-
),
513+
)),
514514
Variance::Invariant,
515515
),
516516
},
@@ -534,10 +534,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
534534
Statement {
535535
source_info,
536536
kind: StatementKind::AscribeUserType(
537-
box (
537+
Box::new((
538538
Place::from(temp),
539539
UserTypeProjection { base: annotation_index, projs: vec![] },
540-
),
540+
)),
541541
Variance::Invariant,
542542
),
543543
},
@@ -691,7 +691,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
691691
lt,
692692
Rvalue::BinaryOp(
693693
BinOp::Lt,
694-
box (Operand::Copy(Place::from(index)), Operand::Copy(len)),
694+
Box::new((Operand::Copy(Place::from(index)), Operand::Copy(len))),
695695
),
696696
);
697697
let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) };

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7373
block,
7474
source_info,
7575
is_min,
76-
Rvalue::BinaryOp(BinOp::Eq, box (arg.to_copy(), minval)),
76+
Rvalue::BinaryOp(BinOp::Eq, Box::new((arg.to_copy(), minval))),
7777
);
7878

7979
block = this.assert(
@@ -158,7 +158,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
158158
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f])))
159159
.collect();
160160

161-
block.and(Rvalue::Aggregate(box AggregateKind::Array(el_ty), fields))
161+
block.and(Rvalue::Aggregate(Box::new(AggregateKind::Array(el_ty)), fields))
162162
}
163163
ExprKind::Tuple { ref fields } => {
164164
// see (*) above
@@ -169,7 +169,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
169169
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f])))
170170
.collect();
171171

172-
block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields))
172+
block.and(Rvalue::Aggregate(Box::new(AggregateKind::Tuple), fields))
173173
}
174174
ExprKind::Closure { closure_id, substs, ref upvars, movability, ref fake_reads } => {
175175
// Convert the closure fake reads, if any, from `ExprRef` to mir `Place`
@@ -254,19 +254,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
254254
// We implicitly set the discriminant to 0. See
255255
// librustc_mir/transform/deaggregator.rs for details.
256256
let movability = movability.unwrap();
257-
box AggregateKind::Generator(closure_id, substs, movability)
257+
Box::new(AggregateKind::Generator(closure_id, substs, movability))
258+
}
259+
UpvarSubsts::Closure(substs) => {
260+
Box::new(AggregateKind::Closure(closure_id, substs))
258261
}
259-
UpvarSubsts::Closure(substs) => box AggregateKind::Closure(closure_id, substs),
260262
};
261263
block.and(Rvalue::Aggregate(result, operands))
262264
}
263265
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {
264266
block = unpack!(this.stmt_expr(block, expr, None));
265-
block.and(Rvalue::Use(Operand::Constant(box Constant {
267+
block.and(Rvalue::Use(Operand::Constant(Box::new(Constant {
266268
span: expr_span,
267269
user_ty: None,
268270
literal: ty::Const::zero_sized(this.tcx, this.tcx.types.unit).into(),
269-
})))
271+
}))))
270272
}
271273
ExprKind::Yield { .. }
272274
| ExprKind::Literal { .. }
@@ -327,7 +329,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
327329
block,
328330
source_info,
329331
result_value,
330-
Rvalue::CheckedBinaryOp(op, box (lhs.to_copy(), rhs.to_copy())),
332+
Rvalue::CheckedBinaryOp(op, Box::new((lhs.to_copy(), rhs.to_copy()))),
331333
);
332334
let val_fld = Field::new(0);
333335
let of_fld = Field::new(1);
@@ -360,7 +362,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
360362
block,
361363
source_info,
362364
is_zero,
363-
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), zero)),
365+
Rvalue::BinaryOp(BinOp::Eq, Box::new((rhs.to_copy(), zero))),
364366
);
365367

366368
block = self.assert(block, Operand::Move(is_zero), false, zero_err, span);
@@ -381,13 +383,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
381383
block,
382384
source_info,
383385
is_neg_1,
384-
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), neg_1)),
386+
Rvalue::BinaryOp(BinOp::Eq, Box::new((rhs.to_copy(), neg_1))),
385387
);
386388
self.cfg.push_assign(
387389
block,
388390
source_info,
389391
is_min,
390-
Rvalue::BinaryOp(BinOp::Eq, box (lhs.to_copy(), min)),
392+
Rvalue::BinaryOp(BinOp::Eq, Box::new((lhs.to_copy(), min))),
391393
);
392394

393395
let is_neg_1 = Operand::Move(is_neg_1);
@@ -396,14 +398,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
396398
block,
397399
source_info,
398400
of,
399-
Rvalue::BinaryOp(BinOp::BitAnd, box (is_neg_1, is_min)),
401+
Rvalue::BinaryOp(BinOp::BitAnd, Box::new((is_neg_1, is_min))),
400402
);
401403

402404
block = self.assert(block, Operand::Move(of), false, overflow_err, span);
403405
}
404406
}
405407

406-
block.and(Rvalue::BinaryOp(op, box (lhs, rhs)))
408+
block.and(Rvalue::BinaryOp(op, Box::new((lhs, rhs))))
407409
}
408410
}
409411

compiler/rustc_mir_build/src/build/expr/as_temp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6262
assert!(!this.tcx.is_thread_local_static(def_id));
6363
local_decl.internal = true;
6464
local_decl.local_info =
65-
Some(box LocalInfo::StaticRef { def_id, is_thread_local: false });
65+
Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: false }));
6666
}
6767
ExprKind::ThreadLocalRef(def_id) => {
6868
assert!(this.tcx.is_thread_local_static(def_id));
6969
local_decl.internal = true;
7070
local_decl.local_info =
71-
Some(box LocalInfo::StaticRef { def_id, is_thread_local: true });
71+
Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: true }));
7272
}
7373
ExprKind::Literal { const_id: Some(def_id), .. } => {
74-
local_decl.local_info = Some(box LocalInfo::ConstRef { def_id });
74+
local_decl.local_info = Some(Box::new(LocalInfo::ConstRef { def_id }));
7575
}
7676
_ => {}
7777
}

compiler/rustc_mir_build/src/build/expr/into.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
346346
inferred_ty,
347347
})
348348
});
349-
let adt = box AggregateKind::Adt(
349+
let adt = Box::new(AggregateKind::Adt(
350350
adt_def,
351351
variant_index,
352352
substs,
353353
user_ty,
354354
active_field_index,
355-
);
355+
));
356356
this.cfg.push_assign(
357357
block,
358358
source_info,
@@ -403,11 +403,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
403403
}
404404
thir::InlineAsmOperand::Const { value, span } => {
405405
mir::InlineAsmOperand::Const {
406-
value: box Constant { span, user_ty: None, literal: value.into() },
406+
value: Box::new(Constant {
407+
span,
408+
user_ty: None,
409+
literal: value.into(),
410+
}),
407411
}
408412
}
409413
thir::InlineAsmOperand::SymFn { expr } => mir::InlineAsmOperand::SymFn {
410-
value: box this.as_constant(&this.thir[expr]),
414+
value: Box::new(this.as_constant(&this.thir[expr])),
411415
},
412416
thir::InlineAsmOperand::SymStatic { def_id } => {
413417
mir::InlineAsmOperand::SymStatic { def_id }

compiler/rustc_mir_build/src/build/expr/stmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
123123
block,
124124
Statement {
125125
source_info,
126-
kind: StatementKind::LlvmInlineAsm(box LlvmInlineAsm {
126+
kind: StatementKind::LlvmInlineAsm(Box::new(LlvmInlineAsm {
127127
asm: asm.clone(),
128128
outputs,
129129
inputs,
130-
}),
130+
})),
131131
},
132132
);
133133
this.block_context.pop();

compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
494494
Statement {
495495
source_info: ty_source_info,
496496
kind: StatementKind::AscribeUserType(
497-
box (place, user_ty),
497+
Box::new((place, user_ty)),
498498
// We always use invariant as the variance here. This is because the
499499
// variance field from the ascription refers to the variance to use
500500
// when applying the type to the value being matched, but this
@@ -2004,7 +2004,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
20042004
Statement {
20052005
source_info,
20062006
kind: StatementKind::AscribeUserType(
2007-
box (ascription.source, user_ty),
2007+
Box::new((ascription.source, user_ty)),
20082008
ascription.variance,
20092009
),
20102010
},
@@ -2133,11 +2133,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21332133
let local = LocalDecl::<'tcx> {
21342134
mutability,
21352135
ty: var_ty,
2136-
user_ty: if user_ty.is_empty() { None } else { Some(box user_ty) },
2136+
user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },
21372137
source_info,
21382138
internal: false,
21392139
is_block_tail: None,
2140-
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
2140+
local_info: Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
21412141
VarBindingForm {
21422142
binding_mode,
21432143
// hypothetically, `visit_primary_bindings` could try to unzip
@@ -2148,7 +2148,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21482148
opt_match_place,
21492149
pat_span,
21502150
},
2151-
)))),
2151+
))))),
21522152
};
21532153
let for_arm_body = self.local_decls.push(local);
21542154
self.var_debug_info.push(VarDebugInfo {
@@ -2166,9 +2166,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21662166
source_info,
21672167
internal: false,
21682168
is_block_tail: None,
2169-
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(
2169+
local_info: Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(
21702170
BindingForm::RefForGuard,
2171-
))),
2171+
)))),
21722172
});
21732173
self.var_debug_info.push(VarDebugInfo {
21742174
name,

compiler/rustc_mir_build/src/build/matches/test.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
346346
let result = self.temp(bool_ty, source_info.span);
347347

348348
// result = op(left, right)
349-
self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, box (left, right)));
349+
self.cfg.push_assign(
350+
block,
351+
source_info,
352+
result,
353+
Rvalue::BinaryOp(op, Box::new((left, right))),
354+
);
350355

351356
// branch based on result
352357
self.cfg.terminate(
@@ -429,7 +434,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
429434
block,
430435
source_info,
431436
TerminatorKind::Call {
432-
func: Operand::Constant(box Constant {
437+
func: Operand::Constant(Box::new(Constant {
433438
span: source_info.span,
434439

435440
// FIXME(#54571): This constant comes from user input (a
@@ -439,7 +444,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
439444
user_ty: None,
440445

441446
literal: method.into(),
442-
}),
447+
})),
443448
args: vec![val, expect],
444449
destination: Some((eq_result, eq_block)),
445450
cleanup: None,

compiler/rustc_mir_build/src/build/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3131
literal: &'tcx ty::Const<'tcx>,
3232
) -> Operand<'tcx> {
3333
let literal = literal.into();
34-
let constant = box Constant { span, user_ty: None, literal };
34+
let constant = Box::new(Constant { span, user_ty: None, literal });
3535
Operand::Constant(constant)
3636
}
3737

0 commit comments

Comments
 (0)