Report when a cfg(feature)
refers to a feature which doesn't exist on a crate
#11559
Labels
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Problem
I have a crate with a feature.
I have CI which runs
cargo test
with that feature enabled.I also have some tests which are specific to that feature, which are gated behind a
cfg(feature)
attribute.However, there was a typo in the
cfg(feature)
attribute, which meant that the feature-specific tests were never actually enabled.Ideally, I would have gotten a compile-time error telling me "You have a
cfg(feature)
which doesn't exist for your crate" (or just a standard unreachable code diagnostic). But at least a warning would be useful.Proposed Solution
Provide an error, or at least warning, when a
cfg(feature)
attribute is used which Cargo doesn't treat as a feature for the crate being compiled.Notes
I filed this against Cargo because it has the knowledge of the known features of a crate, but it's really a rustc feature request at core - I imagine this either looks like cargo supplying a known feature universe to rustc, or rustc reporting encountered features back to cargo.
The text was updated successfully, but these errors were encountered: