about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2019-09-23 21:33:58 -0700
committerDylan MacKenzie <ecstaticmorse@gmail.com>2019-09-28 07:06:52 -0700
commitbc7928a5076616b88b2325b26d91d2547b9a4ac3 (patch)
tree64bf5cf45bb890d796608ccda870ef25967bce72
parent93ee7791b60937b3dd163509c5ed631e1698e99b (diff)
downloadrust-bc7928a5076616b88b2325b26d91d2547b9a4ac3.tar.gz
rust-bc7928a5076616b88b2325b26d91d2547b9a4ac3.zip
Trigger ICE on nightly if validators disagree
Also adds an unstable flag to disable the ICE
(`-Zsuppress-const-validation-back-compat-ice`) so that nightly users do
not have to revert to a previous nightly if their code causes
disagreement between the validators.
-rw-r--r--src/librustc/session/config.rs2
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs21
2 files changed, 21 insertions, 2 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index cbb22f1e448..7c97fd11af2 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -1359,6 +1359,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         "describes how to render the `rendered` field of json diagnostics"),
     unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
         "take the breaks off const evaluation. NOTE: this is unsound"),
+    suppress_const_validation_back_compat_ice: bool = (false, parse_bool, [TRACKED],
+        "silence ICE triggered when the new const validator disagrees with the old"),
     osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
         "pass `-install_name @rpath/...` to the macOS linker"),
     sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED],
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index d9854237eeb..fef918b3298 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -1022,11 +1022,24 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
             self.errors.dedup();
             new_errors.dedup();
 
-            // FIXME: Downgrade this to a warning.
             if self.errors != new_errors {
                 error!("old validator: {:?}", self.errors);
                 error!("new validator: {:?}", new_errors);
-                panic!("disagreement between validators.");
+
+                // ICE on nightly if the validators do not emit exactly the same errors.
+                // Users can supress this panic with an unstable compiler flag (hopefully after
+                // filing an issue).
+                let opts = &self.tcx.sess.opts;
+                let trigger_ice = opts.unstable_features.is_nightly_build()
+                    && !opts.debugging_opts.suppress_const_validation_back_compat_ice;
+
+                if trigger_ice {
+                    span_bug!(
+                        body.span,
+                        "{}",
+                        VALIDATOR_MISMATCH_ERR,
+                    );
+                }
             }
         }
 
@@ -1850,3 +1863,7 @@ fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<FxHashSet<usize
     }
     Some(ret)
 }
+
+const VALIDATOR_MISMATCH_ERR: &str =
+    r"Disagreement between legacy and dataflow-based const validators.
+    After filing an issue, use `-Zsuppress-const-validation-back-compat-ice` to compile your code.";