Passing unstable flags only on nightly toolchains #14733
Labels
A-configuration
Area: cargo config files and env vars
A-rustflags
Area: rustflags
A-rustup
Area: rustup interaction
A-unstable
Area: nightly unstable support
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-needs-design
Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Problem
I sometimes enable unstable rustc features in my user level
config.toml
, such as the parallel frontend (-Zthreads
).This works fine when I'm using the nightly toolchain, but when I
rustup default stable
it causes builds to fail witherror: the option Z is only accepted on the nightly compiler
until I go comment that flag out in the config.Proposed Solution
Adding a new target specifier for toolchain name or channel seems like the nicest solution, I'd love to be able to write:
And have that flag tacked on only when I'm using nightly. I think this works well with the existing behavior for targets and cfgs:
Theoretically you could also introduce a
cfg
type for the current toolchain so you could write:... but I'm not sure that it makes sense given that code generally isn't aware of what toolchain it's built under, not to mention that adding a new
cfg
type seems like a bigger change than is necessary.Notes
This question was asked on the rust discord around a year ago (by @RocketPrinter) and @danielhenrymantilla suggested the following workaround:
I'm currently using this, but it feels gross to rely on the path of the running rustc and in the long term it'd be nice to not need a wrapper.
The text was updated successfully, but these errors were encountered: