Skip to content

Commit 089debd

Browse files
committed
Remove box syntax from rustc_mir_build
1 parent 25b7648 commit 089debd

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
},
@@ -690,7 +690,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
690690
lt,
691691
Rvalue::BinaryOp(
692692
BinOp::Lt,
693-
box (Operand::Copy(Place::from(index)), Operand::Copy(len)),
693+
Box::new((Operand::Copy(Place::from(index)), Operand::Copy(len))),
694694
),
695695
);
696696
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 { .. }
@@ -326,7 +328,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
326328
block,
327329
source_info,
328330
result_value,
329-
Rvalue::CheckedBinaryOp(op, box (lhs.to_copy(), rhs.to_copy())),
331+
Rvalue::CheckedBinaryOp(op, Box::new((lhs.to_copy(), rhs.to_copy()))),
330332
);
331333
let val_fld = Field::new(0);
332334
let of_fld = Field::new(1);
@@ -359,7 +361,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
359361
block,
360362
source_info,
361363
is_zero,
362-
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), zero)),
364+
Rvalue::BinaryOp(BinOp::Eq, Box::new((rhs.to_copy(), zero))),
363365
);
364366

365367
block = self.assert(block, Operand::Move(is_zero), false, zero_err, span);
@@ -380,13 +382,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
380382
block,
381383
source_info,
382384
is_neg_1,
383-
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), neg_1)),
385+
Rvalue::BinaryOp(BinOp::Eq, Box::new((rhs.to_copy(), neg_1))),
384386
);
385387
self.cfg.push_assign(
386388
block,
387389
source_info,
388390
is_min,
389-
Rvalue::BinaryOp(BinOp::Eq, box (lhs.to_copy(), min)),
391+
Rvalue::BinaryOp(BinOp::Eq, Box::new((lhs.to_copy(), min))),
390392
);
391393

392394
let is_neg_1 = Operand::Move(is_neg_1);
@@ -395,14 +397,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
395397
block,
396398
source_info,
397399
of,
398-
Rvalue::BinaryOp(BinOp::BitAnd, box (is_neg_1, is_min)),
400+
Rvalue::BinaryOp(BinOp::BitAnd, Box::new((is_neg_1, is_min))),
399401
);
400402

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

405-
block.and(Rvalue::BinaryOp(op, box (lhs, rhs)))
407+
block.and(Rvalue::BinaryOp(op, Box::new((lhs, rhs))))
406408
}
407409
}
408410

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
@@ -328,13 +328,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
328328
inferred_ty,
329329
})
330330
});
331-
let adt = box AggregateKind::Adt(
331+
let adt = Box::new(AggregateKind::Adt(
332332
adt_def,
333333
variant_index,
334334
substs,
335335
user_ty,
336336
active_field_index,
337-
);
337+
));
338338
this.cfg.push_assign(
339339
block,
340340
source_info,
@@ -385,11 +385,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
385385
}
386386
thir::InlineAsmOperand::Const { value, span } => {
387387
mir::InlineAsmOperand::Const {
388-
value: box Constant { span, user_ty: None, literal: value.into() },
388+
value: Box::new(Constant {
389+
span,
390+
user_ty: None,
391+
literal: value.into(),
392+
}),
389393
}
390394
}
391395
thir::InlineAsmOperand::SymFn { expr } => mir::InlineAsmOperand::SymFn {
392-
value: box this.as_constant(&this.thir[expr]),
396+
value: Box::new(this.as_constant(&this.thir[expr])),
393397
},
394398
thir::InlineAsmOperand::SymStatic { def_id } => {
395399
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
@@ -454,7 +454,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
454454
Statement {
455455
source_info: ty_source_info,
456456
kind: StatementKind::AscribeUserType(
457-
box (place, user_ty),
457+
Box::new((place, user_ty)),
458458
// We always use invariant as the variance here. This is because the
459459
// variance field from the ascription refers to the variance to use
460460
// when applying the type to the value being matched, but this
@@ -1964,7 +1964,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
19641964
Statement {
19651965
source_info,
19661966
kind: StatementKind::AscribeUserType(
1967-
box (ascription.source, user_ty),
1967+
Box::new((ascription.source, user_ty)),
19681968
ascription.variance,
19691969
),
19701970
},
@@ -2093,11 +2093,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
20932093
let local = LocalDecl::<'tcx> {
20942094
mutability,
20952095
ty: var_ty,
2096-
user_ty: if user_ty.is_empty() { None } else { Some(box user_ty) },
2096+
user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },
20972097
source_info,
20982098
internal: false,
20992099
is_block_tail: None,
2100-
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
2100+
local_info: Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
21012101
VarBindingForm {
21022102
binding_mode,
21032103
// hypothetically, `visit_primary_bindings` could try to unzip
@@ -2108,7 +2108,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21082108
opt_match_place,
21092109
pat_span,
21102110
},
2111-
)))),
2111+
))))),
21122112
};
21132113
let for_arm_body = self.local_decls.push(local);
21142114
self.var_debug_info.push(VarDebugInfo {
@@ -2126,9 +2126,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21262126
source_info,
21272127
internal: false,
21282128
is_block_tail: None,
2129-
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(
2129+
local_info: Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(
21302130
BindingForm::RefForGuard,
2131-
))),
2131+
)))),
21322132
});
21332133
self.var_debug_info.push(VarDebugInfo {
21342134
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)