Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stable: Give a better error message for rustc +nightly -Zunstable-options #110090

Closed
jyn514 opened this issue Apr 8, 2023 · 2 comments · Fixed by #112692
Closed

stable: Give a better error message for rustc +nightly -Zunstable-options #110090

jyn514 opened this issue Apr 8, 2023 · 2 comments · Fixed by #112692
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-stability Area: `#[stable]`, `#[unstable]` etc. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 8, 2023

Code

$(rustup which rustc --toolchain 1.68) +nightly -Zunstable-options

Current output

error: the option `Z` is only accepted on the nightly compiler

Desired output

error: the option `Z` is only accepted on the nightly compiler
error: couldn't read +nightly: No such file or directory (os error 2)
|
= note: selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>

Rationale and extra context

Distros often install rustc directly, without a rustup wrapper. In that case, people using the distro rustc may see suggestions on stack overflow or elsewhere that won't work with their toolchain. We should improve the error message for them.

Originally reported in #104785.

Other cases

No response

Anything else?

Note that to test your change for this issue, you'll have to set channel = "stable" in config.toml; nightly reports a different error:

; $(rustup which rustc --toolchain nightly) +nightly -Zunstable-options
error: couldn't read +nightly: No such file or directory (os error 2)

error: aborting due to previous error
@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 8, 2023
@jyn514
Copy link
Member Author

jyn514 commented Apr 8, 2023

It would also be nice to point people to how to install a nightly compiler; maybe something like

error: the option `Z` is only accepted on the nightly compiler
|
= help: consider switching to a nightly toolchain: `rustup default nightly`
= note: for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>

@jyn514 jyn514 added the A-stability Area: `#[stable]`, `#[unstable]` etc. label Apr 8, 2023
@jyn514
Copy link
Member Author

jyn514 commented May 10, 2023

This is non-trivial to fix because we don't have a handler this early in the compiler, so there's no record that the error was emitted; right now you'd have to juggle around an ErrorGuaranteed between rustc_session/interface/driver. I think I'd suggest implementing this by having a single handler used throughout rustc_driver::run_compiler, and calling abort_if_errors() just before the call to interface::run_compiler:

interface::run_compiler(config, |compiler| {

@jyn514 jyn514 added E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. labels May 10, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 18, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 19, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 19, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 19, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 20, 2023
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating rust-lang#110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
@bors bors closed this as completed in b6144cd Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-stability Area: `#[stable]`, `#[unstable]` etc. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant