Rollup merge of #125173 - scottmcm:never-checked, r=davidtwco
Remove `Rvalue::CheckedBinaryOp` Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996> cc `@RalfJung` While it's a draft, r? ghost
This commit is contained in:
commit
9987e900c0
61 changed files with 212 additions and 215 deletions
|
@ -195,9 +195,15 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
|||
},
|
||||
@call(mir_checked, args) => {
|
||||
parse_by_kind!(self, args[0], _, "binary op",
|
||||
ExprKind::Binary { op, lhs, rhs } => Ok(Rvalue::CheckedBinaryOp(
|
||||
*op, Box::new((self.parse_operand(*lhs)?, self.parse_operand(*rhs)?))
|
||||
)),
|
||||
ExprKind::Binary { op, lhs, rhs } => {
|
||||
if let Some(op_with_overflow) = op.wrapping_to_overflowing() {
|
||||
Ok(Rvalue::BinaryOp(
|
||||
op_with_overflow, Box::new((self.parse_operand(*lhs)?, self.parse_operand(*rhs)?))
|
||||
))
|
||||
} else {
|
||||
Err(self.expr_error(expr_id, "No WithOverflow form of this operator"))
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
@call(mir_offset, args) => {
|
||||
|
|
|
@ -568,11 +568,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let result_tup = Ty::new_tup(self.tcx, &[ty, bool_ty]);
|
||||
let result_value = self.temp(result_tup, span);
|
||||
|
||||
let op_with_overflow = op.wrapping_to_overflowing().unwrap();
|
||||
|
||||
self.cfg.push_assign(
|
||||
block,
|
||||
source_info,
|
||||
result_value,
|
||||
Rvalue::CheckedBinaryOp(op, Box::new((lhs.to_copy(), rhs.to_copy()))),
|
||||
Rvalue::BinaryOp(op_with_overflow, Box::new((lhs.to_copy(), rhs.to_copy()))),
|
||||
);
|
||||
let val_fld = FieldIdx::ZERO;
|
||||
let of_fld = FieldIdx::new(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue