Confusing behavior when passing features to package #11415
Labels
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-needs-info
Status: Needs more info, such as a reproduction or more background for a feature request.
Problem
If you have a package
foo
in your workspace, and it is not the default build target (cargo build
buildsbar
), you build it viacargo build -p foo
. Now, if you want to enable a feature, the intuitive approach would be tocargo build -p foo --features new-feat
. This will cause an error ifbar
doesn't have such feature, but it will build just fine ifbar
also has thenew-feat
feautre.This is immensly confusing, as the feature is enabled for a package which one isn't even attempting to build. The solution is to, of course, invoke
cargo build -p foo --features "foo/new-feat"
, but finding out about this is not trivial.Proposed Solution
Emit a warning when running
cargo build -p MEMBER --features FEATURE
if bothMEMBER
and the root package have this feature declared.Notes
If this is deemed useful, I can tackle the implementation.
The text was updated successfully, but these errors were encountered: