There are many crates that do version detection in a build script to set cfg
to change what they compile, a disappointingly large subset of these also detect the channel and enable unstable features when detecting they might be supported.
There's three general mechanisms used for this "feature detection":
rustc -vV
and extract the channel name (-nightly
) from the version number, assume all unstable features are supported and work as needed.RUSTFLAGS
/CARGO_ENCODED_RUSTFLAGS
to detect -Zallow-features
and check the actual features are not disabled, assume they will work as needed.Often mechanism three will be gated behind an initial mechanism one check to avoid the overhead of running all these small tests when it's known they will fail.
Crates doing this cause issues for supposedly-stable transitive dependents when they are compiled with a nightly compiler (e.g. https://github.com/rust-lang/rust/issues/113152). This makes it hard to do things like bisect a range of nightly compiler versions against a locked build to find where some other stable feature regressed.
Today it is possible to force-disable unstable features for crates that use mechanisms two and three: cargo build -Zallow-features=
, but for crates using mechanism one you have to do something horrible like wrap rustc
in a shell script that hides the channel info.
Add a new -Zno-channel-info
flag and RUSTC_UNSTABLE_NO_CHANNEL_INFO
envvar that supresses the channel-info from being emitted from the version call, when set a nightly-channel compiler built from bf8716f1c
would say just rustc 1.77.0 (bf8716f1c 2023-12-24)
instead of rustc 1.77.0-nightly (bf8716f1c 2023-12-24)
.
If you have a reviewer or mentor in mind for this work, mention them
here. You can put your own name here if you are planning to mentor the
work.
The main points of the Major Change Process are as follows:
@rustbot second
.
-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.