Skip to content

Commit dda95c1

Browse files
committed
Auto merge of #115713 - chenyukang:yukang-fix-115680-rustdoc-arg-check, r=compiler-errors
Abort if check nightly options failed on stable Fixes #115680 Also, if there are multiple unstable options passing on stable compiler, printing multiple same `note` and `help` seems noisy.
2 parents ffe131f + 12888d2 commit dda95c1

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
@@ -2982,6 +2982,7 @@ pub mod nightly_options {
29822982
) {
29832983
let has_z_unstable_option = matches.opt_strs("Z").iter().any(|x| *x == "unstable-options");
29842984
let really_allows_unstable_options = match_is_nightly_build(matches);
2985+
let mut nightly_options_on_stable = 0;
29852986

29862987
for opt in flags.iter() {
29872988
if opt.stability == OptionStability::Stable {
@@ -3002,20 +3003,27 @@ pub mod nightly_options {
30023003
}
30033004
match opt.stability {
30043005
OptionStability::Unstable => {
3006+
nightly_options_on_stable += 1;
30053007
let msg = format!(
30063008
"the option `{}` is only accepted on the nightly compiler",
30073009
opt.name
30083010
);
30093011
let _ = handler.early_error_no_abort(msg);
3010-
handler.early_note("selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>");
3011-
handler.early_help(
3012-
"consider switching to a nightly toolchain: `rustup default nightly`",
3013-
);
3014-
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>");
30153012
}
30163013
OptionStability::Stable => {}
30173014
}
30183015
}
3016+
if nightly_options_on_stable > 0 {
3017+
handler
3018+
.early_help("consider switching to a nightly toolchain: `rustup default nightly`");
3019+
handler.early_note("selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>");
3020+
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>");
3021+
handler.early_error(format!(
3022+
"{} nightly option{} were parsed",
3023+
nightly_options_on_stable,
3024+
if nightly_options_on_stable > 1 { "s" } else { "" }
3025+
));
3026+
}
30193027
}
30203028
}
30213029

0 commit comments

Comments
 (0)