diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2023-03-16 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2023-03-16 22:55:45 +0100 |
| commit | 27b430bcb36e46cc5dcfd88ec6cec2639ad2467c (patch) | |
| tree | 9bb26a194c35f8cfa1b4141210a21e14d63e1bd9 /compiler/rustc_codegen_ssa/src | |
| parent | e386217dd996d293b3bde2285f6f5f4f502d7c17 (diff) | |
| download | rust-27b430bcb36e46cc5dcfd88ec6cec2639ad2467c.tar.gz rust-27b430bcb36e46cc5dcfd88ec6cec2639ad2467c.zip | |
Tweak implementation of overflow checking assertions
Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/block.rs | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 71c71d59b7a..f9aa2aecf65 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -563,15 +563,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // with #[rustc_inherit_overflow_checks] and inlined from // another crate (mostly core::num generic/#[inline] fns), // while the current crate doesn't use overflow checks. - if !bx.cx().check_overflow() { - let overflow_not_to_check = match msg { - AssertKind::OverflowNeg(..) => true, - AssertKind::Overflow(op, ..) => op.is_checkable(), - _ => false, - }; - if overflow_not_to_check { - const_cond = Some(expected); - } + if !bx.cx().check_overflow() && msg.is_optional_overflow_check() { + const_cond = Some(expected); } // Don't codegen the panic block if success if known. |
