Skip to content

Commit 12888d2

Browse files
committed
Abort if check nightly options failed on stable
1 parent 7f0fa48 commit 12888d2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

compiler/rustc_session/src/config.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,7 @@ pub mod nightly_options {
29592959
) {
29602960
let has_z_unstable_option = matches.opt_strs("Z").iter().any(|x| *x == "unstable-options");
29612961
let really_allows_unstable_options = match_is_nightly_build(matches);
2962+
let mut nightly_options_on_stable = 0;
29622963

29632964
for opt in flags.iter() {
29642965
if opt.stability == OptionStability::Stable {
@@ -2979,20 +2980,27 @@ pub mod nightly_options {
29792980
}
29802981
match opt.stability {
29812982
OptionStability::Unstable => {
2983+
nightly_options_on_stable += 1;
29822984
let msg = format!(
29832985
"the option `{}` is only accepted on the nightly compiler",
29842986
opt.name
29852987
);
29862988
let _ = handler.early_error_no_abort(msg);
2987-
handler.early_note("selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>");
2988-
handler.early_help(
2989-
"consider switching to a nightly toolchain: `rustup default nightly`",
2990-
);
2991-
handler.early_note("for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>");
29922989
}
29932990
OptionStability::Stable => {}
29942991
}
29952992
}
2993+
if nightly_options_on_stable > 0 {
2994+
handler
2995+
.early_help("consider switching to a nightly toolchain: `rustup default nightly`");
2996+
handler.early_note("selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>");
2997+
handler.early_note("for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>");
2998+
handler.early_error(format!(
2999+
"{} nightly option{} were parsed",
3000+
nightly_options_on_stable,
3001+
if nightly_options_on_stable > 1 { "s" } else { "" }
3002+
));
3003+
}
29963004
}
29973005
}
29983006

0 commit comments

Comments
 (0)