about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-23 04:26:05 +0100
committerGitHub <noreply@github.com>2020-03-23 04:26:05 +0100
commita2b469c4ccf3777294422c350c10012ca2e22e25 (patch)
tree32af5e8fb5c4b344f57fe0c8efb9dc2e967e83e1
parent5ed9d7ebb662ad993e9f2e8c70575fb27cd45041 (diff)
parent2ee2157e29b9cab1fc0ebd89246ba27f48fce3d9 (diff)
downloadrust-a2b469c4ccf3777294422c350c10012ca2e22e25.tar.gz
rust-a2b469c4ccf3777294422c350c10012ca2e22e25.zip
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
-rw-r--r--src/librustc_mir/interpret/validity.rs7
-rw-r--r--src/librustc_mir/transform/const_prop.rs3
2 files changed, 4 insertions, 6 deletions
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index d93b78a5bd5..6f9543bf95a 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -825,11 +825,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_ub!(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 b41043ee510..a19901f3778 100644
--- a/src/librustc_mir/transform/const_prop.rs
+++ b/src/librustc_mir/transform/const_prop.rs
@@ -404,8 +404,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