about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2023-03-16 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2023-03-16 22:55:45 +0100
commitedb0717e7ca51dbde53f1dc26956efb0d90825c0 (patch)
treef0da9df344ce16a52bceee9f86473f5749873de0
parente42bea9fdef30787709ddd1de9259717954e7bd6 (diff)
downloadrust-edb0717e7ca51dbde53f1dc26956efb0d90825c0.tar.gz
rust-edb0717e7ca51dbde53f1dc26956efb0d90825c0.zip
Tweak implementation of overflow checking assertions
Extract and reuse logic controlling behaviour of overflow checking
assertions instead of duplicating it three times.
-rw-r--r--src/base.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/base.rs b/src/base.rs
index d0af3729b23..1b8e9312e2f 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -346,17 +346,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
                 crate::abi::codegen_return(fx);
             }
             TerminatorKind::Assert { cond, expected, msg, target, cleanup: _ } => {
-                if !fx.tcx.sess.overflow_checks() {
-                    let overflow_not_to_check = match msg {
-                        AssertKind::OverflowNeg(..) => true,
-                        AssertKind::Overflow(op, ..) => op.is_checkable(),
-                        _ => false,
-                    };
-                    if overflow_not_to_check {
-                        let target = fx.get_block(*target);
-                        fx.bcx.ins().jump(target, &[]);
-                        continue;
-                    }
+                if !fx.tcx.sess.overflow_checks() && msg.is_optional_overflow_check() {
+                    let target = fx.get_block(*target);
+                    fx.bcx.ins().jump(target, &[]);
+                    continue;
                 }
                 let cond = codegen_operand(fx, cond).load_scalar(fx);