Skip to content

Commit

Permalink
miri engine: turn error sanity checks into assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 10, 2020
1 parent 3dbade6 commit afc9cf3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// Run it.
match visitor.visit_value(op) {
Ok(()) => Ok(()),
// We should only get validation errors here. Avoid other errors as
// those do not show *where* in the value the issue lies.
Err(err) if matches!(err.kind, err_unsup!(ValidationFailure { .. })) => Err(err),
Err(err) if cfg!(debug_assertions) => {
bug!("Unexpected error during validation: {}", err)
}
Err(err) => Err(err),
Err(err) => bug!("Unexpected error during validation: {}", err),
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// Some errors shouldn't come up because creating them causes
// an allocation, which we should avoid. When that happens,
// dedicated error variants should be introduced instead.
// Only test this in debug builds though to avoid disruptions.
debug_assert!(
assert!(
!error.kind.allocates(),
"const-prop encountered allocating error: {}",
error
Expand Down

0 comments on commit afc9cf3

Please sign in to comment.