Skip to content

Commit bc7928a

Browse files
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.
1 parent 93ee779 commit bc7928a

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13591359
"describes how to render the `rendered` field of json diagnostics"),
13601360
unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
13611361
"take the breaks off const evaluation. NOTE: this is unsound"),
1362+
suppress_const_validation_back_compat_ice: bool = (false, parse_bool, [TRACKED],
1363+
"silence ICE triggered when the new const validator disagrees with the old"),
13621364
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
13631365
"pass `-install_name @rpath/...` to the macOS linker"),
13641366
sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED],

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,11 +1022,24 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
10221022
self.errors.dedup();
10231023
new_errors.dedup();
10241024

1025-
// FIXME: Downgrade this to a warning.
10261025
if self.errors != new_errors {
10271026
error!("old validator: {:?}", self.errors);
10281027
error!("new validator: {:?}", new_errors);
1029-
panic!("disagreement between validators.");
1028+
1029+
// ICE on nightly if the validators do not emit exactly the same errors.
1030+
// Users can supress this panic with an unstable compiler flag (hopefully after
1031+
// filing an issue).
1032+
let opts = &self.tcx.sess.opts;
1033+
let trigger_ice = opts.unstable_features.is_nightly_build()
1034+
&& !opts.debugging_opts.suppress_const_validation_back_compat_ice;
1035+
1036+
if trigger_ice {
1037+
span_bug!(
1038+
body.span,
1039+
"{}",
1040+
VALIDATOR_MISMATCH_ERR,
1041+
);
1042+
}
10301043
}
10311044
}
10321045

@@ -1850,3 +1863,7 @@ fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<FxHashSet<usize
18501863
}
18511864
Some(ret)
18521865
}
1866+
1867+
const VALIDATOR_MISMATCH_ERR: &str =
1868+
r"Disagreement between legacy and dataflow-based const validators.
1869+
After filing an issue, use `-Zsuppress-const-validation-back-compat-ice` to compile your code.";

0 commit comments

Comments
 (0)