Skip to content

Commit 085eaa7

Browse files
committed
Adapt interpreter.
1 parent 7f36a3f commit 085eaa7

File tree

4 files changed

+3
-15
lines changed

4 files changed

+3
-15
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
219219
sym::mul_with_overflow => BinOp::Mul,
220220
_ => bug!(),
221221
};
222-
self.binop_with_overflow(
223-
bin_op, /*force_overflow_checks*/ true, &lhs, &rhs, dest,
224-
)?;
222+
self.binop_with_overflow(bin_op, &lhs, &rhs, dest)?;
225223
}
226224
sym::saturating_add | sym::saturating_sub => {
227225
let l = self.read_immediate(&args[0])?;

compiler/rustc_const_eval/src/interpret/operator.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ use super::{ImmTy, Immediate, InterpCx, Machine, PlaceTy};
1010
impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1111
/// Applies the binary operation `op` to the two operands and writes a tuple of the result
1212
/// and a boolean signifying the potential overflow to the destination.
13-
///
14-
/// `force_overflow_checks` indicates whether overflow checks should be done even when
15-
/// `tcx.sess.overflow_checks()` is `false`.
1613
pub fn binop_with_overflow(
1714
&mut self,
1815
op: mir::BinOp,
19-
force_overflow_checks: bool,
2016
left: &ImmTy<'tcx, M::Provenance>,
2117
right: &ImmTy<'tcx, M::Provenance>,
2218
dest: &PlaceTy<'tcx, M::Provenance>,
@@ -28,10 +24,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
2824
"type mismatch for result of {:?}",
2925
op,
3026
);
31-
// As per https://github.com/rust-lang/rust/pull/98738, we always return `false` in the 2nd
32-
// component when overflow checking is disabled.
33-
let overflowed =
34-
overflowed && (force_overflow_checks || M::checked_binop_checks_overflow(self));
3527
// Write the result to `dest`.
3628
if let Abi::ScalarPair(..) = dest.layout.abi {
3729
// We can use the optimized path and avoid `place_field` (which might do

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
185185
let left = self.read_immediate(&self.eval_operand(left, None)?)?;
186186
let layout = binop_right_homogeneous(bin_op).then_some(left.layout);
187187
let right = self.read_immediate(&self.eval_operand(right, layout)?)?;
188-
self.binop_with_overflow(
189-
bin_op, /*force_overflow_checks*/ false, &left, &right, &dest,
190-
)?;
188+
self.binop_with_overflow(bin_op, &left, &right, &dest)?;
191189
}
192190

193191
UnaryOp(un_op, ref operand) => {

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 1 addition & 1 deletion
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::checked_binop_checks_overflow(self)
141141
&& match msg {
142142
mir::AssertKind::OverflowNeg(..) => true,
143143
mir::AssertKind::Overflow(op, ..) => op.is_checkable(),

0 commit comments

Comments
 (0)