Skip to content

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

Closed
@jyn514

Description

@jyn514

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-stabilityArea: `#[stable]`, `#[unstable]` etc.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions