Problem
When passing -Zallow-features=... as a command-line flag, it is not included in CARGO_ENCODED_RUSTFLAGS. This means that build scripts which look at the encoded flags can't detect when nightly features are limited.
(This is the same type of issue as #12437, but for command-line flags instead of profile-rustflags)
Steps
I noticed this in anyhow, which reads CARGO_ENCODED_RUSTFLAGS when compiling a test program to check for nightly support.
$ cargo init anyhow-test && cd anyhow-test
$ cargo add anyhow
$ cargo check +nightly -Zallow-features=
The test program compiles successfully (because -Zallow-features= isn't propagated), so anyhow enables its nightly features, then immediately faceplants when it tries to build itself
(I initially opened anyhow#450, but agree with the author that this is a Cargo issue).
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.95.0 (f2d3ce0bd 2026-03-21)
release: 1.95.0
commit-hash: f2d3ce0bd7f24a49f8f72d9000448f8838c4e850
commit-date: 2026-03-21
host: aarch64-apple-darwin
libgit2: 1.9.2 (sys:0.20.4 vendored)
libcurl: 8.7.1 (sys:0.4.83+curl-8.15.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Mac OS 26.5.0 [64-bit]
Problem
When passing
-Zallow-features=...as a command-line flag, it is not included inCARGO_ENCODED_RUSTFLAGS. This means that build scripts which look at the encoded flags can't detect when nightly features are limited.(This is the same type of issue as #12437, but for command-line flags instead of
profile-rustflags)Steps
I noticed this in
anyhow, which readsCARGO_ENCODED_RUSTFLAGSwhen compiling a test program to check for nightly support.The test program compiles successfully (because
-Zallow-features=isn't propagated), soanyhowenables its nightly features, then immediately faceplants when it tries to build itself(I initially opened anyhow#450, but agree with the author that this is a Cargo issue).
Possible Solution(s)
No response
Notes
No response
Version