Skip to content

Commit a2b469c

Browse files
authored
Rollup merge of #69880 - RalfJung:miri-assert-error-sanity, r=oli-obk
miri engine: turn error sanity checks into assertions We had these as debug assertions so far to make sure our test suite is clean, but really these are conditions that should never arise and also @eddyb told me to turn non-performance-critical debug assertions into full assertions so here we go. ;) I propose that we do a check-only crater run to make sure this does not actually happen in practice. r? @oli-obk
2 parents 5ed9d7e + 2ee2157 commit a2b469c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/librustc_mir/interpret/validity.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
825825
// Run it.
826826
match visitor.visit_value(op) {
827827
Ok(()) => Ok(()),
828+
// We should only get validation errors here. Avoid other errors as
829+
// those do not show *where* in the value the issue lies.
828830
Err(err) if matches!(err.kind, err_ub!(ValidationFailure { .. })) => Err(err),
829-
Err(err) if cfg!(debug_assertions) => {
830-
bug!("Unexpected error during validation: {}", err)
831-
}
832-
Err(err) => Err(err),
831+
Err(err) => bug!("Unexpected error during validation: {}", err),
833832
}
834833
}
835834

src/librustc_mir/transform/const_prop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
404404
// Some errors shouldn't come up because creating them causes
405405
// an allocation, which we should avoid. When that happens,
406406
// dedicated error variants should be introduced instead.
407-
// Only test this in debug builds though to avoid disruptions.
408-
debug_assert!(
407+
assert!(
409408
!error.kind.allocates(),
410409
"const-prop encountered allocating error: {}",
411410
error

0 commit comments

Comments
 (0)