let val = crate::constant::codegen_tls_ref(fx, def_id, lval.layout());
lval.write_cvalue(fx, val);
}
- Rvalue::BinaryOp(bin_op, ref lhs, ref rhs) => {
+ Rvalue::BinaryOp(bin_op, box (ref lhs, ref rhs)) => {
let lhs = codegen_operand(fx, lhs);
let rhs = codegen_operand(fx, rhs);
let res = crate::num::codegen_binop(fx, bin_op, lhs, rhs);
lval.write_cvalue(fx, res);
}
- Rvalue::CheckedBinaryOp(bin_op, ref lhs, ref rhs) => {
+ Rvalue::CheckedBinaryOp(bin_op, box (ref lhs, ref rhs)) => {
let lhs = codegen_operand(fx, lhs);
let rhs = codegen_operand(fx, rhs);
associated_type_bounds,
never_type,
try_blocks,
+ box_patterns,
hash_drain_filter
)]
#![warn(rust_2018_idioms)]
(bx, operand)
}
- mir::Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
+ mir::Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
let lhs = self.codegen_operand(&mut bx, lhs);
let rhs = self.codegen_operand(&mut bx, rhs);
let llresult = match (lhs.val, rhs.val) {
};
(bx, operand)
}
- mir::Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
+ mir::Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
let lhs = self.codegen_operand(&mut bx, lhs);
let rhs = self.codegen_operand(&mut bx, rhs);
let result = self.codegen_scalar_checked_binop(
Cast(CastKind, Operand<'tcx>, Ty<'tcx>),
- BinaryOp(BinOp, Operand<'tcx>, Operand<'tcx>),
- CheckedBinaryOp(BinOp, Operand<'tcx>, Operand<'tcx>),
+ BinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>),
+ CheckedBinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>),
NullaryOp(NullOp, Ty<'tcx>),
UnaryOp(UnOp, Operand<'tcx>),
}
#[cfg(target_arch = "x86_64")]
-static_assert_size!(Rvalue<'_>, 56);
+static_assert_size!(Rvalue<'_>, 40);
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
pub enum CastKind {
Cast(ref kind, ref place, ref ty) => {
write!(fmt, "{:?} as {:?} ({:?})", place, ty, kind)
}
- BinaryOp(ref op, ref a, ref b) => write!(fmt, "{:?}({:?}, {:?})", op, a, b),
- CheckedBinaryOp(ref op, ref a, ref b) => {
+ BinaryOp(ref op, box (ref a, ref b)) => write!(fmt, "{:?}({:?}, {:?})", op, a, b),
+ CheckedBinaryOp(ref op, box (ref a, ref b)) => {
write!(fmt, "Checked{:?}({:?}, {:?})", op, a, b)
}
UnaryOp(ref op, ref a) => write!(fmt, "{:?}({:?})", op, a),
}
Rvalue::Len(..) => tcx.types.usize,
Rvalue::Cast(.., ty) => ty,
- Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
+ Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
let lhs_ty = lhs.ty(local_decls, tcx);
let rhs_ty = rhs.ty(local_decls, tcx);
op.ty(tcx, lhs_ty, rhs_ty)
}
- Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
+ Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
let lhs_ty = lhs.ty(local_decls, tcx);
let rhs_ty = rhs.ty(local_decls, tcx);
let ty = op.ty(tcx, lhs_ty, rhs_ty);
AddressOf(mutability, place) => AddressOf(mutability, place.fold_with(folder)),
Len(place) => Len(place.fold_with(folder)),
Cast(kind, op, ty) => Cast(kind, op.fold_with(folder), ty.fold_with(folder)),
- BinaryOp(op, rhs, lhs) => BinaryOp(op, rhs.fold_with(folder), lhs.fold_with(folder)),
- CheckedBinaryOp(op, rhs, lhs) => {
- CheckedBinaryOp(op, rhs.fold_with(folder), lhs.fold_with(folder))
+ BinaryOp(op, box (rhs, lhs)) => {
+ BinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder)))
+ }
+ CheckedBinaryOp(op, box (rhs, lhs)) => {
+ CheckedBinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder)))
}
UnaryOp(op, val) => UnaryOp(op, val.fold_with(folder)),
Discriminant(place) => Discriminant(place.fold_with(folder)),
op.visit_with(visitor)?;
ty.visit_with(visitor)
}
- BinaryOp(_, ref rhs, ref lhs) | CheckedBinaryOp(_, ref rhs, ref lhs) => {
+ BinaryOp(_, box (ref rhs, ref lhs)) | CheckedBinaryOp(_, box (ref rhs, ref lhs)) => {
rhs.visit_with(visitor)?;
lhs.visit_with(visitor)
}
self.visit_ty(ty, TyContext::Location(location));
}
- Rvalue::BinaryOp(_bin_op, lhs, rhs)
- | Rvalue::CheckedBinaryOp(_bin_op, lhs, rhs) => {
+ Rvalue::BinaryOp(_bin_op, box(lhs, rhs))
+ | Rvalue::CheckedBinaryOp(_bin_op, box(lhs, rhs)) => {
self.visit_operand(lhs, location);
self.visit_operand(rhs, location);
}
);
}
- Rvalue::BinaryOp(_bin_op, ref operand1, ref operand2)
- | Rvalue::CheckedBinaryOp(_bin_op, ref operand1, ref operand2) => {
+ Rvalue::BinaryOp(_bin_op, box (ref operand1, ref operand2))
+ | Rvalue::CheckedBinaryOp(_bin_op, box (ref operand1, ref operand2)) => {
self.consume_operand(location, operand1);
self.consume_operand(location, operand2);
}
);
}
- Rvalue::BinaryOp(_bin_op, ref operand1, ref operand2)
- | Rvalue::CheckedBinaryOp(_bin_op, ref operand1, ref operand2) => {
+ Rvalue::BinaryOp(_bin_op, box (ref operand1, ref operand2))
+ | Rvalue::CheckedBinaryOp(_bin_op, box (ref operand1, ref operand2)) => {
self.consume_operand(location, (operand1, span), flow_state);
self.consume_operand(location, (operand2, span), flow_state);
}
Rvalue::BinaryOp(
BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge,
- left,
- right,
+ box (left, right),
) => {
let ty_left = left.ty(body, tcx);
match ty_left.kind() {
| Rvalue::Repeat(ref operand, _)
| Rvalue::Cast(_, ref operand, _)
| Rvalue::UnaryOp(_, ref operand) => self.gather_operand(operand),
- Rvalue::BinaryOp(ref _binop, ref lhs, ref rhs)
- | Rvalue::CheckedBinaryOp(ref _binop, ref lhs, ref rhs) => {
+ Rvalue::BinaryOp(ref _binop, box (ref lhs, ref rhs))
+ | Rvalue::CheckedBinaryOp(ref _binop, box (ref lhs, ref rhs)) => {
self.gather_operand(lhs);
self.gather_operand(rhs);
}
self.copy_op(&op, &dest)?;
}
- BinaryOp(bin_op, ref left, ref right) => {
+ BinaryOp(bin_op, box (ref left, ref right)) => {
let layout = binop_left_homogeneous(bin_op).then_some(dest.layout);
let left = self.read_immediate(&self.eval_operand(left, layout)?)?;
let layout = binop_right_homogeneous(bin_op).then_some(left.layout);
self.binop_ignore_overflow(bin_op, &left, &right, &dest)?;
}
- CheckedBinaryOp(bin_op, ref left, ref right) => {
+ CheckedBinaryOp(bin_op, box (ref left, ref right)) => {
// Due to the extra boolean in the result, we can never reuse the `dest.layout`.
let left = self.read_immediate(&self.eval_operand(left, None)?)?;
let layout = binop_right_homogeneous(bin_op).then_some(left.layout);
let cond = self.make_place(Mutability::Mut, tcx.types.bool);
let compute_cond = self.make_statement(StatementKind::Assign(box (
cond,
- Rvalue::BinaryOp(BinOp::Ne, Operand::Copy(end), Operand::Copy(beg)),
+ Rvalue::BinaryOp(BinOp::Ne, box (Operand::Copy(end), Operand::Copy(beg))),
)));
// `if end != beg { goto loop_body; } else { goto loop_end; }`
Place::from(beg),
Rvalue::BinaryOp(
BinOp::Add,
- Operand::Copy(Place::from(beg)),
- Operand::Constant(self.make_usize(1)),
+ box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))),
),
)))];
self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
Place::from(beg),
Rvalue::BinaryOp(
BinOp::Add,
- Operand::Copy(Place::from(beg)),
- Operand::Constant(self.make_usize(1)),
+ box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))),
),
)));
self.block(vec![statement], TerminatorKind::Goto { target: BasicBlock::new(6) }, true);
| Rvalue::UnaryOp(_, operand)
| Rvalue::Cast(_, operand, _) => in_operand::<Q, _>(cx, in_local, operand),
- Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
+ Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => {
in_operand::<Q, _>(cx, in_local, lhs) || in_operand::<Q, _>(cx, in_local, rhs)
}
}
}
- Rvalue::BinaryOp(op, ref lhs, ref rhs)
- | Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
+ Rvalue::BinaryOp(op, box (ref lhs, ref rhs))
+ | Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
let lhs_ty = lhs.ty(self.body, self.tcx);
let rhs_ty = rhs.ty(self.body, self.tcx);
trace!("checking UnaryOp(op = {:?}, arg = {:?})", op, arg);
self.check_unary_op(*op, arg, source_info)?;
}
- Rvalue::BinaryOp(op, left, right) => {
+ Rvalue::BinaryOp(op, box (left, right)) => {
trace!("checking BinaryOp(op = {:?}, left = {:?}, right = {:?})", op, left, right);
self.check_binary_op(*op, left, right, source_info)?;
}
- Rvalue::CheckedBinaryOp(op, left, right) => {
+ Rvalue::CheckedBinaryOp(op, box (left, right)) => {
trace!(
"checking CheckedBinaryOp(op = {:?}, left = {:?}, right = {:?})",
op,
) -> Option<()> {
self.use_ecx(|this| {
match rvalue {
- Rvalue::BinaryOp(op, left, right) | Rvalue::CheckedBinaryOp(op, left, right) => {
+ Rvalue::BinaryOp(op, box (left, right))
+ | Rvalue::CheckedBinaryOp(op, box (left, right)) => {
let l = this.ecx.eval_operand(left, None);
let r = this.ecx.eval_operand(right, None);
}
BinOp::Mul => {
if const_arg.layout.ty.is_integral() && arg_value == 0 {
- if let Rvalue::CheckedBinaryOp(_, _, _) = rvalue {
+ if let Rvalue::CheckedBinaryOp(_, _) = rvalue {
let val = Immediate::ScalarPair(
const_arg.to_scalar()?.into(),
Scalar::from_bool(false).into(),
opt_to_apply.infos[0].first_switch_info.discr_used_in_switch;
let not_equal_rvalue = Rvalue::BinaryOp(
not_equal,
- Operand::Copy(Place::from(second_discriminant_temp)),
- Operand::Copy(first_descriminant_place),
+ box (
+ Operand::Copy(Place::from(second_discriminant_temp)),
+ Operand::Copy(first_descriminant_place),
+ ),
);
patch.add_statement(
end_of_block_location,
/// Transform boolean comparisons into logical operations.
fn combine_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
match rvalue {
- Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), a, b) => {
+ Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
// Transform "Eq(a, true)" ==> "a"
(BinOp::Eq, _, Some(true)) => Some(a.clone()),
source_info: terminator.source_info,
kind: StatementKind::Assign(box (
destination,
- Rvalue::BinaryOp(bin_op, lhs, rhs),
+ Rvalue::BinaryOp(bin_op, box (lhs, rhs)),
)),
});
terminator.kind = TerminatorKind::Goto { target };
let op = if f_b { BinOp::Eq } else { BinOp::Ne };
let rhs = Rvalue::BinaryOp(
op,
- Operand::Copy(Place::from(discr_local)),
- const_cmp,
+ box (Operand::Copy(Place::from(discr_local)), const_cmp),
);
Statement {
source_info: f.source_info,
self.validate_operand(operand)?;
}
- Rvalue::BinaryOp(op, lhs, rhs) | Rvalue::CheckedBinaryOp(op, lhs, rhs) => {
+ Rvalue::BinaryOp(op, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(op, box (lhs, rhs)) => {
let op = *op;
let lhs_ty = lhs.ty(self.body, self.tcx);
use Operand::*;
match rhs {
- Rvalue::BinaryOp(_, ref mut left @ Move(_), Constant(_)) => {
+ Rvalue::BinaryOp(_, box (ref mut left @ Move(_), Constant(_))) => {
*left = Copy(opt.to_switch_on);
}
- Rvalue::BinaryOp(_, Constant(_), ref mut right @ Move(_)) => {
+ Rvalue::BinaryOp(_, box (Constant(_), ref mut right @ Move(_))) => {
*right = Copy(opt.to_switch_on);
}
_ => (),
if *lhs == place_switched_on =>
{
match rhs {
- Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), left, right) => {
+ Rvalue::BinaryOp(
+ op @ (BinOp::Eq | BinOp::Ne),
+ box (left, right),
+ ) => {
let (branch_value_scalar, branch_value_ty, to_switch_on) =
find_branch_value_info(left, right)?;
let one = self.constant_usize(1);
let (ptr_next, cur_next) = if ptr_based {
- (Rvalue::Use(copy(cur.into())), Rvalue::BinaryOp(BinOp::Offset, move_(cur.into()), one))
+ (
+ Rvalue::Use(copy(cur.into())),
+ Rvalue::BinaryOp(BinOp::Offset, box (move_(cur.into()), one)),
+ )
} else {
(
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)),
- Rvalue::BinaryOp(BinOp::Add, move_(cur.into()), one),
+ Rvalue::BinaryOp(BinOp::Add, box (move_(cur.into()), one)),
)
};
let loop_block = BasicBlockData {
statements: vec![self.assign(
can_go,
- Rvalue::BinaryOp(BinOp::Eq, copy(Place::from(cur)), copy(length_or_end)),
+ Rvalue::BinaryOp(BinOp::Eq, box (copy(Place::from(cur)), copy(length_or_end))),
)],
is_cleanup: unwind.is_cleanup(),
terminator: Some(Terminator {
self.assign(cur, Rvalue::Cast(CastKind::Misc, Operand::Move(tmp), iter_ty)),
self.assign(
length_or_end,
- Rvalue::BinaryOp(BinOp::Offset, Operand::Copy(cur), Operand::Move(length)),
+ Rvalue::BinaryOp(
+ BinOp::Offset,
+ box (Operand::Copy(cur), Operand::Move(length)),
+ ),
),
]
} else {
block,
source_info,
lt,
- Rvalue::BinaryOp(BinOp::Lt, Operand::Copy(Place::from(index)), Operand::Copy(len)),
+ Rvalue::BinaryOp(
+ BinOp::Lt,
+ box (Operand::Copy(Place::from(index)), Operand::Copy(len)),
+ ),
);
let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) };
// assert!(lt, "...")
block,
source_info,
is_min,
- Rvalue::BinaryOp(BinOp::Eq, arg.to_copy(), minval),
+ Rvalue::BinaryOp(BinOp::Eq, box (arg.to_copy(), minval)),
);
block = this.assert(
block,
source_info,
result_value,
- Rvalue::CheckedBinaryOp(op, lhs.to_copy(), rhs.to_copy()),
+ Rvalue::CheckedBinaryOp(op, box (lhs.to_copy(), rhs.to_copy())),
);
let val_fld = Field::new(0);
let of_fld = Field::new(1);
block,
source_info,
is_zero,
- Rvalue::BinaryOp(BinOp::Eq, rhs.to_copy(), zero),
+ Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), zero)),
);
block = self.assert(block, Operand::Move(is_zero), false, zero_err, span);
block,
source_info,
is_neg_1,
- Rvalue::BinaryOp(BinOp::Eq, rhs.to_copy(), neg_1),
+ Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), neg_1)),
);
self.cfg.push_assign(
block,
source_info,
is_min,
- Rvalue::BinaryOp(BinOp::Eq, lhs.to_copy(), min),
+ Rvalue::BinaryOp(BinOp::Eq, box (lhs.to_copy(), min)),
);
let is_neg_1 = Operand::Move(is_neg_1);
block,
source_info,
of,
- Rvalue::BinaryOp(BinOp::BitAnd, is_neg_1, is_min),
+ Rvalue::BinaryOp(BinOp::BitAnd, box (is_neg_1, is_min)),
);
block = self.assert(block, Operand::Move(of), false, overflow_err, span);
}
}
- block.and(Rvalue::BinaryOp(op, lhs, rhs))
+ block.and(Rvalue::BinaryOp(op, box (lhs, rhs)))
}
}
let result = self.temp(bool_ty, source_info.span);
// result = op(left, right)
- self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, left, right));
+ self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, box (left, right)));
// branch based on result
self.cfg.terminate(
self.locals[local] = self.operand_to_node(span, operand)?;
Ok(())
}
- Rvalue::BinaryOp(op, ref lhs, ref rhs) if Self::check_binop(op) => {
+ Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) if Self::check_binop(op) => {
let lhs = self.operand_to_node(span, lhs)?;
let rhs = self.operand_to_node(span, rhs)?;
self.locals[local] = self.add_node(Node::Binop(op, lhs, rhs), span);
Ok(())
}
}
- Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) if Self::check_binop(op) => {
+ Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs))
+ if Self::check_binop(op) =>
+ {
let lhs = self.operand_to_node(span, lhs)?;
let rhs = self.operand_to_node(span, rhs)?;
self.locals[local] = self.add_node(Node::Binop(op, lhs, rhs), span);
match rvalue {
Use(op) | Repeat(op, _) | Cast(_, op, _) | UnaryOp(_, op) => visit_op(op),
Aggregate(_, ops) => ops.iter().for_each(visit_op),
- BinaryOp(_, lhs, rhs) | CheckedBinaryOp(_, lhs, rhs) => {
+ BinaryOp(_, box (lhs, rhs)) | CheckedBinaryOp(_, box (lhs, rhs)) => {
visit_op(lhs);
visit_op(rhs);
- },
+ }
_ => (),
}
}
}
},
// binops are fine on integers
- Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
+ Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => {
check_operand(tcx, lhs, span, body)?;
check_operand(tcx, rhs, span, body)?;
let ty = lhs.ty(body, tcx);