Remove box syntax from rustc_mir_build
This commit is contained in:
@@ -40,7 +40,7 @@ impl<'tcx> CFG<'tcx> {
|
||||
) {
|
||||
self.push(
|
||||
block,
|
||||
Statement { source_info, kind: StatementKind::Assign(box (place, rvalue)) },
|
||||
Statement { source_info, kind: StatementKind::Assign(Box::new((place, rvalue))) },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,12 @@ impl<'tcx> CFG<'tcx> {
|
||||
temp: Place<'tcx>,
|
||||
constant: Constant<'tcx>,
|
||||
) {
|
||||
self.push_assign(block, source_info, temp, Rvalue::Use(Operand::Constant(box constant)));
|
||||
self.push_assign(
|
||||
block,
|
||||
source_info,
|
||||
temp,
|
||||
Rvalue::Use(Operand::Constant(Box::new(constant))),
|
||||
);
|
||||
}
|
||||
|
||||
crate fn push_assign_unit(
|
||||
@@ -65,11 +70,11 @@ impl<'tcx> CFG<'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
place,
|
||||
Rvalue::Use(Operand::Constant(box Constant {
|
||||
Rvalue::Use(Operand::Constant(Box::new(Constant {
|
||||
span: source_info.span,
|
||||
user_ty: None,
|
||||
literal: ty::Const::zero_sized(tcx, tcx.types.unit).into(),
|
||||
})),
|
||||
}))),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,7 +85,7 @@ impl<'tcx> CFG<'tcx> {
|
||||
cause: FakeReadCause,
|
||||
place: Place<'tcx>,
|
||||
) {
|
||||
let kind = StatementKind::FakeRead(box (cause, place));
|
||||
let kind = StatementKind::FakeRead(Box::new((cause, place)));
|
||||
let stmt = Statement { source_info, kind };
|
||||
self.push(block, stmt);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
match category {
|
||||
Category::Constant => {
|
||||
let constant = this.as_constant(expr);
|
||||
block.and(Operand::Constant(box constant))
|
||||
block.and(Operand::Constant(Box::new(constant)))
|
||||
}
|
||||
Category::Place | Category::Rvalue(..) => {
|
||||
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));
|
||||
|
||||
@@ -507,10 +507,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
Statement {
|
||||
source_info,
|
||||
kind: StatementKind::AscribeUserType(
|
||||
box (
|
||||
Box::new((
|
||||
place,
|
||||
UserTypeProjection { base: annotation_index, projs: vec![] },
|
||||
),
|
||||
)),
|
||||
Variance::Invariant,
|
||||
),
|
||||
},
|
||||
@@ -534,10 +534,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
Statement {
|
||||
source_info,
|
||||
kind: StatementKind::AscribeUserType(
|
||||
box (
|
||||
Box::new((
|
||||
Place::from(temp),
|
||||
UserTypeProjection { base: annotation_index, projs: vec![] },
|
||||
),
|
||||
)),
|
||||
Variance::Invariant,
|
||||
),
|
||||
},
|
||||
@@ -691,7 +691,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
lt,
|
||||
Rvalue::BinaryOp(
|
||||
BinOp::Lt,
|
||||
box (Operand::Copy(Place::from(index)), Operand::Copy(len)),
|
||||
Box::new((Operand::Copy(Place::from(index)), Operand::Copy(len))),
|
||||
),
|
||||
);
|
||||
let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) };
|
||||
|
||||
@@ -73,7 +73,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
is_min,
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (arg.to_copy(), minval)),
|
||||
Rvalue::BinaryOp(BinOp::Eq, Box::new((arg.to_copy(), minval))),
|
||||
);
|
||||
|
||||
block = this.assert(
|
||||
@@ -158,7 +158,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f])))
|
||||
.collect();
|
||||
|
||||
block.and(Rvalue::Aggregate(box AggregateKind::Array(el_ty), fields))
|
||||
block.and(Rvalue::Aggregate(Box::new(AggregateKind::Array(el_ty)), fields))
|
||||
}
|
||||
ExprKind::Tuple { ref fields } => {
|
||||
// see (*) above
|
||||
@@ -169,7 +169,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f])))
|
||||
.collect();
|
||||
|
||||
block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields))
|
||||
block.and(Rvalue::Aggregate(Box::new(AggregateKind::Tuple), fields))
|
||||
}
|
||||
ExprKind::Closure { closure_id, substs, ref upvars, movability, ref fake_reads } => {
|
||||
// Convert the closure fake reads, if any, from `ExprRef` to mir `Place`
|
||||
@@ -254,19 +254,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
// We implicitly set the discriminant to 0. See
|
||||
// librustc_mir/transform/deaggregator.rs for details.
|
||||
let movability = movability.unwrap();
|
||||
box AggregateKind::Generator(closure_id, substs, movability)
|
||||
Box::new(AggregateKind::Generator(closure_id, substs, movability))
|
||||
}
|
||||
UpvarSubsts::Closure(substs) => {
|
||||
Box::new(AggregateKind::Closure(closure_id, substs))
|
||||
}
|
||||
UpvarSubsts::Closure(substs) => box AggregateKind::Closure(closure_id, substs),
|
||||
};
|
||||
block.and(Rvalue::Aggregate(result, operands))
|
||||
}
|
||||
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {
|
||||
block = unpack!(this.stmt_expr(block, expr, None));
|
||||
block.and(Rvalue::Use(Operand::Constant(box Constant {
|
||||
block.and(Rvalue::Use(Operand::Constant(Box::new(Constant {
|
||||
span: expr_span,
|
||||
user_ty: None,
|
||||
literal: ty::Const::zero_sized(this.tcx, this.tcx.types.unit).into(),
|
||||
})))
|
||||
}))))
|
||||
}
|
||||
ExprKind::Yield { .. }
|
||||
| ExprKind::Literal { .. }
|
||||
@@ -327,7 +329,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
result_value,
|
||||
Rvalue::CheckedBinaryOp(op, box (lhs.to_copy(), rhs.to_copy())),
|
||||
Rvalue::CheckedBinaryOp(op, Box::new((lhs.to_copy(), rhs.to_copy()))),
|
||||
);
|
||||
let val_fld = Field::new(0);
|
||||
let of_fld = Field::new(1);
|
||||
@@ -360,7 +362,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
is_zero,
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), zero)),
|
||||
Rvalue::BinaryOp(BinOp::Eq, Box::new((rhs.to_copy(), zero))),
|
||||
);
|
||||
|
||||
block = self.assert(block, Operand::Move(is_zero), false, zero_err, span);
|
||||
@@ -381,13 +383,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
is_neg_1,
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), neg_1)),
|
||||
Rvalue::BinaryOp(BinOp::Eq, Box::new((rhs.to_copy(), neg_1))),
|
||||
);
|
||||
self.cfg.push_assign(
|
||||
block,
|
||||
source_info,
|
||||
is_min,
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (lhs.to_copy(), min)),
|
||||
Rvalue::BinaryOp(BinOp::Eq, Box::new((lhs.to_copy(), min))),
|
||||
);
|
||||
|
||||
let is_neg_1 = Operand::Move(is_neg_1);
|
||||
@@ -396,14 +398,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
of,
|
||||
Rvalue::BinaryOp(BinOp::BitAnd, box (is_neg_1, is_min)),
|
||||
Rvalue::BinaryOp(BinOp::BitAnd, Box::new((is_neg_1, is_min))),
|
||||
);
|
||||
|
||||
block = self.assert(block, Operand::Move(of), false, overflow_err, span);
|
||||
}
|
||||
}
|
||||
|
||||
block.and(Rvalue::BinaryOp(op, box (lhs, rhs)))
|
||||
block.and(Rvalue::BinaryOp(op, Box::new((lhs, rhs))))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,16 +62,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
assert!(!this.tcx.is_thread_local_static(def_id));
|
||||
local_decl.internal = true;
|
||||
local_decl.local_info =
|
||||
Some(box LocalInfo::StaticRef { def_id, is_thread_local: false });
|
||||
Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: false }));
|
||||
}
|
||||
ExprKind::ThreadLocalRef(def_id) => {
|
||||
assert!(this.tcx.is_thread_local_static(def_id));
|
||||
local_decl.internal = true;
|
||||
local_decl.local_info =
|
||||
Some(box LocalInfo::StaticRef { def_id, is_thread_local: true });
|
||||
Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: true }));
|
||||
}
|
||||
ExprKind::Literal { const_id: Some(def_id), .. } => {
|
||||
local_decl.local_info = Some(box LocalInfo::ConstRef { def_id });
|
||||
local_decl.local_info = Some(Box::new(LocalInfo::ConstRef { def_id }));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -346,13 +346,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
inferred_ty,
|
||||
})
|
||||
});
|
||||
let adt = box AggregateKind::Adt(
|
||||
let adt = Box::new(AggregateKind::Adt(
|
||||
adt_def,
|
||||
variant_index,
|
||||
substs,
|
||||
user_ty,
|
||||
active_field_index,
|
||||
);
|
||||
));
|
||||
this.cfg.push_assign(
|
||||
block,
|
||||
source_info,
|
||||
@@ -403,11 +403,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
}
|
||||
thir::InlineAsmOperand::Const { value, span } => {
|
||||
mir::InlineAsmOperand::Const {
|
||||
value: box Constant { span, user_ty: None, literal: value.into() },
|
||||
value: Box::new(Constant {
|
||||
span,
|
||||
user_ty: None,
|
||||
literal: value.into(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
thir::InlineAsmOperand::SymFn { expr } => mir::InlineAsmOperand::SymFn {
|
||||
value: box this.as_constant(&this.thir[expr]),
|
||||
value: Box::new(this.as_constant(&this.thir[expr])),
|
||||
},
|
||||
thir::InlineAsmOperand::SymStatic { def_id } => {
|
||||
mir::InlineAsmOperand::SymStatic { def_id }
|
||||
|
||||
@@ -123,11 +123,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
Statement {
|
||||
source_info,
|
||||
kind: StatementKind::LlvmInlineAsm(box LlvmInlineAsm {
|
||||
kind: StatementKind::LlvmInlineAsm(Box::new(LlvmInlineAsm {
|
||||
asm: asm.clone(),
|
||||
outputs,
|
||||
inputs,
|
||||
}),
|
||||
})),
|
||||
},
|
||||
);
|
||||
this.block_context.pop();
|
||||
|
||||
@@ -494,7 +494,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
Statement {
|
||||
source_info: ty_source_info,
|
||||
kind: StatementKind::AscribeUserType(
|
||||
box (place, user_ty),
|
||||
Box::new((place, user_ty)),
|
||||
// We always use invariant as the variance here. This is because the
|
||||
// variance field from the ascription refers to the variance to use
|
||||
// when applying the type to the value being matched, but this
|
||||
@@ -2004,7 +2004,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
Statement {
|
||||
source_info,
|
||||
kind: StatementKind::AscribeUserType(
|
||||
box (ascription.source, user_ty),
|
||||
Box::new((ascription.source, user_ty)),
|
||||
ascription.variance,
|
||||
),
|
||||
},
|
||||
@@ -2133,11 +2133,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let local = LocalDecl::<'tcx> {
|
||||
mutability,
|
||||
ty: var_ty,
|
||||
user_ty: if user_ty.is_empty() { None } else { Some(box user_ty) },
|
||||
user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },
|
||||
source_info,
|
||||
internal: false,
|
||||
is_block_tail: None,
|
||||
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
|
||||
local_info: Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
|
||||
VarBindingForm {
|
||||
binding_mode,
|
||||
// hypothetically, `visit_primary_bindings` could try to unzip
|
||||
@@ -2148,7 +2148,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
opt_match_place,
|
||||
pat_span,
|
||||
},
|
||||
)))),
|
||||
))))),
|
||||
};
|
||||
let for_arm_body = self.local_decls.push(local);
|
||||
self.var_debug_info.push(VarDebugInfo {
|
||||
@@ -2166,9 +2166,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
source_info,
|
||||
internal: false,
|
||||
is_block_tail: None,
|
||||
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(
|
||||
local_info: Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(
|
||||
BindingForm::RefForGuard,
|
||||
))),
|
||||
)))),
|
||||
});
|
||||
self.var_debug_info.push(VarDebugInfo {
|
||||
name,
|
||||
|
||||
@@ -346,7 +346,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let result = self.temp(bool_ty, source_info.span);
|
||||
|
||||
// result = op(left, right)
|
||||
self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, box (left, right)));
|
||||
self.cfg.push_assign(
|
||||
block,
|
||||
source_info,
|
||||
result,
|
||||
Rvalue::BinaryOp(op, Box::new((left, right))),
|
||||
);
|
||||
|
||||
// branch based on result
|
||||
self.cfg.terminate(
|
||||
@@ -429,7 +434,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
TerminatorKind::Call {
|
||||
func: Operand::Constant(box Constant {
|
||||
func: Operand::Constant(Box::new(Constant {
|
||||
span: source_info.span,
|
||||
|
||||
// FIXME(#54571): This constant comes from user input (a
|
||||
@@ -439,7 +444,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
user_ty: None,
|
||||
|
||||
literal: method.into(),
|
||||
}),
|
||||
})),
|
||||
args: vec![val, expect],
|
||||
destination: Some((eq_result, eq_block)),
|
||||
cleanup: None,
|
||||
|
||||
@@ -31,7 +31,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
literal: &'tcx ty::Const<'tcx>,
|
||||
) -> Operand<'tcx> {
|
||||
let literal = literal.into();
|
||||
let constant = box Constant { span, user_ty: None, literal };
|
||||
let constant = Box::new(Constant { span, user_ty: None, literal });
|
||||
Operand::Constant(constant)
|
||||
}
|
||||
|
||||
|
||||
@@ -980,19 +980,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
self.local_decls[local].mutability = mutability;
|
||||
self.local_decls[local].source_info.scope = self.source_scope;
|
||||
self.local_decls[local].local_info = if let Some(kind) = self_binding {
|
||||
Some(box LocalInfo::User(ClearCrossCrate::Set(
|
||||
Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(
|
||||
BindingForm::ImplicitSelf(*kind),
|
||||
)))
|
||||
))))
|
||||
} else {
|
||||
let binding_mode = ty::BindingMode::BindByValue(mutability);
|
||||
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
|
||||
Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
|
||||
VarBindingForm {
|
||||
binding_mode,
|
||||
opt_ty_info,
|
||||
opt_match_place: Some((Some(place), span)),
|
||||
pat_span: span,
|
||||
},
|
||||
))))
|
||||
)))))
|
||||
};
|
||||
self.var_indices.insert(var, LocalsForNode::One(local));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user