Skip to content

Commit edb0717

Browse files
committed
Tweak implementation of overflow checking assertions
Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times.
1 parent e42bea9 commit edb0717

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/base.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
346346
crate::abi::codegen_return(fx);
347347
}
348348
TerminatorKind::Assert { cond, expected, msg, target, cleanup: _ } => {
349-
if !fx.tcx.sess.overflow_checks() {
350-
let overflow_not_to_check = match msg {
351-
AssertKind::OverflowNeg(..) => true,
352-
AssertKind::Overflow(op, ..) => op.is_checkable(),
353-
_ => false,
354-
};
355-
if overflow_not_to_check {
356-
let target = fx.get_block(*target);
357-
fx.bcx.ins().jump(target, &[]);
358-
continue;
359-
}
349+
if !fx.tcx.sess.overflow_checks() && msg.is_optional_overflow_check() {
350+
let target = fx.get_block(*target);
351+
fx.bcx.ins().jump(target, &[]);
352+
continue;
360353
}
361354
let cond = codegen_operand(fx, cond).load_scalar(fx);
362355

0 commit comments

Comments
 (0)