about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2024-05-16 02:07:31 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2024-05-17 20:33:02 -0700
commit95c0e5c6a86ca467b0fb7043bd56dee82418ac5f (patch)
tree961ac9359e2a2d7edcf81a1f97a7ef0a5514e096 /compiler/rustc_const_eval/src/interpret
parent8e78d168040b2d7106a28712c39106602c7a1d61 (diff)
Remove `Rvalue::CheckedBinaryOp`
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
-rw-r--r--compiler/rustc_const_eval/src/interpret/step.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs
index ee415c380de..cb72d55a9ba 100644
--- a/compiler/rustc_const_eval/src/interpret/step.rs
+++ b/compiler/rustc_const_eval/src/interpret/step.rs
@@ -167,15 +167,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                 let left = self.read_immediate(&self.eval_operand(left, layout)?)?;
                 let layout = util::binop_right_homogeneous(bin_op).then_some(left.layout);
                 let right = self.read_immediate(&self.eval_operand(right, layout)?)?;
-                self.binop_ignore_overflow(bin_op, &left, &right, &dest)?;
-            }
-
-            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 = util::binop_right_homogeneous(bin_op).then_some(left.layout);
-                let right = self.read_immediate(&self.eval_operand(right, layout)?)?;
-                self.binop_with_overflow(bin_op, &left, &right, &dest)?;
+                if let Some(bin_op) = bin_op.overflowing_to_wrapping() {
+                    self.binop_with_overflow(bin_op, &left, &right, &dest)?;
+                } else {
+                    self.binop_ignore_overflow(bin_op, &left, &right, &dest)?;
+                }
             }
 
             UnaryOp(un_op, ref operand) => {