diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-12 15:31:34 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-18 21:35:02 +0000 |
| commit | c1a0f8205ca17ca60ffb332b2d4994e22d09cb6e (patch) | |
| tree | d078344ad497734fa5d098900f4000d5fdd7c7e4 | |
| parent | a5769193d1661238b4792c26daef350da1df5cf6 (diff) | |
| download | rust-c1a0f8205ca17ca60ffb332b2d4994e22d09cb6e.tar.gz rust-c1a0f8205ca17ca60ffb332b2d4994e22d09cb6e.zip | |
Rename checked_binop_checks_overflow.
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/machine.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/terminator.rs | 2 | ||||
| -rw-r--r-- | src/tools/miri/src/machine.rs | 4 |
3 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 5b7b0dc66d1..450488315ef 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -147,8 +147,9 @@ pub trait Machine<'mir, 'tcx>: Sized { true } - /// Whether CheckedBinOp MIR statements should actually check for overflow. - fn checked_binop_checks_overflow(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool; + /// Whether Assert(OverflowNeg) and Assert(Overflow) MIR terminators should actually + /// check for overflow. + fn ignore_checkable_overflow_assertions(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool; /// Entry point for obtaining the MIR of anything that should get evaluated. /// So not just functions and shims, but also const/static initializers, anonymous @@ -466,8 +467,8 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) { } #[inline(always)] - fn checked_binop_checks_overflow(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool { - true + fn ignore_checkable_overflow_assertions(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool { + false } #[inline(always)] diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index 70805972c40..294bd35c13e 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -137,7 +137,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } Assert { ref cond, expected, ref msg, target, cleanup } => { - let ignored = !M::checked_binop_checks_overflow(self) + let ignored = M::ignore_checkable_overflow_assertions(self) && match msg { mir::AssertKind::OverflowNeg(..) => true, mir::AssertKind::Overflow(op, ..) => op.is_checkable(), diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index c99cc68dbab..8bd1e802f8a 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -815,8 +815,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> { } #[inline(always)] - fn checked_binop_checks_overflow(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool { - ecx.tcx.sess.overflow_checks() + fn ignore_checkable_overflow_assertions(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool { + !ecx.tcx.sess.overflow_checks() } #[inline(always)] |
