Create a new project (cargo new foo), edit .cargo/config.toml and add:
[env]
RUSTFLAGS = "-C opt-level=illegal"
I expected to see this happen:
- Either a correct passing of the
RUSTFLAGS leading to an error:
error: optimization level needs to be between 0-3, s or z (instead was `illegal`)
- Or alternatively a warning that
RUSTFLAGS is ignored in the [env] section, and that it must be passed with the rustflags option in either [build] or [target].
Instead, this happened:
- Build silently succeeds, ignoring the set
RUSTFLAGS entirely.
Meta
rustc --version --verbose:
rustc 1.94.0-nightly (7b5cde737 2025-12-27)
binary: rustc
commit-hash: 7b5cde7370b82fecf700071dda98c3fbc7d41fae
commit-date: 2025-12-27
host: aarch64-apple-darwin
release: 1.94.0-nightly
LLVM version: 21.1.8
Create a new project (
cargo new foo), edit.cargo/config.tomland add:I expected to see this happen:
RUSTFLAGSleading to an error:RUSTFLAGSis ignored in the[env]section, and that it must be passed with therustflagsoption in either[build]or[target].Instead, this happened:
RUSTFLAGSentirely.Meta
rustc --version --verbose: