Skip to content

Commit 13f916f

Browse files
committed
Auto merge of #69880 - RalfJung:miri-assert-error-sanity, r=<try>
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 3dbade6 + afc9cf3 commit 13f916f

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
@@ -817,11 +817,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
817817
// Run it.
818818
match visitor.visit_value(op) {
819819
Ok(()) => Ok(()),
820+
// We should only get validation errors here. Avoid other errors as
821+
// those do not show *where* in the value the issue lies.
820822
Err(err) if matches!(err.kind, err_unsup!(ValidationFailure { .. })) => Err(err),
821-
Err(err) if cfg!(debug_assertions) => {
822-
bug!("Unexpected error during validation: {}", err)
823-
}
824-
Err(err) => Err(err),
823+
Err(err) => bug!("Unexpected error during validation: {}", err),
825824
}
826825
}
827826

src/librustc_mir/transform/const_prop.rs

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

0 commit comments

Comments
 (0)