Skip to content

Commit fab54fc

Browse files
authored
Rollup merge of #69565 - RalfJung:assert, r=eddyb
miri engine: turn some debug_assert into assert @eddyb said to avoid debug assertions in rustc. These checks here look like they are probably not too expensive. Cc @oli-obk
2 parents 3c5b1b7 + 5982e9d commit fab54fc

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/librustc_mir/interpret/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
202202

203203
Char => {
204204
// `u8` to `char` cast
205-
debug_assert_eq!(v as u8 as u128, v);
205+
assert_eq!(v as u8 as u128, v);
206206
Ok(Scalar::from_uint(v, Size::from_bytes(4)))
207207
}
208208

src/librustc_mir/interpret/operator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
234234
BitXor => (Scalar::from_uint(l ^ r, size), left_layout.ty),
235235

236236
Add | Sub | Mul | Rem | Div => {
237-
debug_assert!(!left_layout.abi.is_signed());
237+
assert!(!left_layout.abi.is_signed());
238238
let op: fn(u128, u128) -> (u128, bool) = match bin_op {
239239
Add => u128::overflowing_add,
240240
Sub => u128::overflowing_sub,

src/librustc_mir/interpret/step.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
287287
self.eval_terminator(terminator)?;
288288
if !self.stack.is_empty() {
289289
// This should change *something*
290-
debug_assert!(self.cur_frame() != old_stack || self.frame().block != old_bb);
290+
assert!(self.cur_frame() != old_stack || self.frame().block != old_bb);
291291
if let Some(block) = self.frame().block {
292292
info!("// executing {:?}", block);
293293
}

src/librustc_mir/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
172172
}
173173
let caller_arg = caller_arg.next().ok_or_else(|| err_unsup!(FunctionArgCountMismatch))?;
174174
if rust_abi {
175-
debug_assert!(!caller_arg.layout.is_zst(), "ZSTs must have been already filtered out");
175+
assert!(!caller_arg.layout.is_zst(), "ZSTs must have been already filtered out");
176176
}
177177
// Now, check
178178
if !Self::check_argument_compat(rust_abi, caller_arg.layout, callee_arg.layout) {

src/librustc_mir/interpret/validity.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ fn wrapping_range_contains(r: &RangeInclusive<u128>, test: u128) -> bool {
144144
// "expected something <in the given range>" makes sense.
145145
fn wrapping_range_format(r: &RangeInclusive<u128>, max_hi: u128) -> String {
146146
let (lo, hi) = r.clone().into_inner();
147-
debug_assert!(hi <= max_hi);
147+
assert!(hi <= max_hi);
148148
if lo > hi {
149149
format!("less or equal to {}, or greater or equal to {}", hi, lo)
150150
} else if lo == hi {
151151
format!("equal to {}", lo)
152152
} else if lo == 0 {
153-
debug_assert!(hi < max_hi, "should not be printing if the range covers everything");
153+
assert!(hi < max_hi, "should not be printing if the range covers everything");
154154
format!("less or equal to {}", hi)
155155
} else if hi == max_hi {
156-
debug_assert!(lo > 0, "should not be printing if the range covers everything");
156+
assert!(lo > 0, "should not be printing if the range covers everything");
157157
format!("greater or equal to {}", lo)
158158
} else {
159159
format!("in the range {:?}", r)

0 commit comments

Comments
 (0)