Cargo should issue a warning when rustflags from an outer config file override rustflags from an inner config file #11885
Labels
A-configuration
Area: cargo config files and env vars
A-rustflags
Area: rustflags
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
Let's say your have two
.cargo/config
files affecting your project:$HOME/.cargo/config
$HOME/my_project/.cargo/config
Let's say these config files have conflicting rustflags values:
In that case, the rustflags in your local file will be overwritten by the globally-set rustflags. This is coherent with the reference, which says that
target.<triple>.rustflags
has a higher priority thanbuild.rustflags
and is mutually exclusive.But it's very confusing when it happens, and it's completely different from usual cargo behavior. Usually, you expect flags you set locally to override flags in a global file.
Proposed Solution
Ideally, the way rustflags are merged between config files should be reconsidered. In practice, it might be impossible to change it without breaking changes to people's workflow.
At the very least, a warning should be issued when such collisions do occur, so that users know that flags they've set locally are being ignored.
The text was updated successfully, but these errors were encountered: