From afc9cf31e3882738835c918e745dc20f3f9f339d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 10 Mar 2020 09:22:16 +0100 Subject: [PATCH] miri engine: turn error sanity checks into assertions --- src/librustc_mir/interpret/validity.rs | 7 +++---- src/librustc_mir/transform/const_prop.rs | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 05bb010959b32..e7b8e6b70e6a2 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -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), } } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index a07c8575b300c..919aa2b2d9630 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -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