Skip to content

Commit c1a0f82

Browse files
committed
Rename checked_binop_checks_overflow.
1 parent a576919 commit c1a0f82

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

compiler/rustc_const_eval/src/interpret/machine.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ pub trait Machine<'mir, 'tcx>: Sized {
147147
true
148148
}
149149

150-
/// Whether CheckedBinOp MIR statements should actually check for overflow.
151-
fn checked_binop_checks_overflow(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool;
150+
/// Whether Assert(OverflowNeg) and Assert(Overflow) MIR terminators should actually
151+
/// check for overflow.
152+
fn ignore_checkable_overflow_assertions(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool;
152153

153154
/// Entry point for obtaining the MIR of anything that should get evaluated.
154155
/// 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>) {
466467
}
467468

468469
#[inline(always)]
469-
fn checked_binop_checks_overflow(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool {
470-
true
470+
fn ignore_checkable_overflow_assertions(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool {
471+
false
471472
}
472473

473474
#[inline(always)]

compiler/rustc_const_eval/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
137137
}
138138

139139
Assert { ref cond, expected, ref msg, target, cleanup } => {
140-
let ignored = !M::checked_binop_checks_overflow(self)
140+
let ignored = M::ignore_checkable_overflow_assertions(self)
141141
&& match msg {
142142
mir::AssertKind::OverflowNeg(..) => true,
143143
mir::AssertKind::Overflow(op, ..) => op.is_checkable(),

src/tools/miri/src/machine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
815815
}
816816

817817
#[inline(always)]
818-
fn checked_binop_checks_overflow(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
819-
ecx.tcx.sess.overflow_checks()
818+
fn ignore_checkable_overflow_assertions(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
819+
!ecx.tcx.sess.overflow_checks()
820820
}
821821

822822
#[inline(always)]

0 commit comments

Comments
 (0)