-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically enable required-features #4663
Comments
Is there a possibility to alter this issue to also include binaries? I currently have: [package]
name = "lambdapi"
[features]
cli = ["rustyline", "structopt"]
[[bin]]
name = "lambdapi"
required-features = ["cli"]
[dependencies]
rustyline = { version = "1.0.0", optional = true }
structopt = { version = "0.2.2", optional = true } At the moment running:
Instead I have to run: |
Joining the request - we are hitting this in three-rs with "gltf-loader" feature. |
@gankro is looking for mentors, cc @rust-lang/cargo |
So, unfortunately this, while it sounds like an E-should-not-be-that-hard bug, is actually pretty tricky to fix properly! However we probably could get a 80% working solution without too too much effort. The error originates from this function, whose job is to determine which targets should be compiled, based on the CLI flags ( The proper solution here I believe is to remove features from resolve, and instead do feature selection later, exactly in the The 80% solution would be to enable required features before we construct resolve. This happens over here: cargo/src/cargo/ops/cargo_compile.rs Lines 353 to 359 in 420f9ec
(and we get there from this code, specific to I think, for
I think that with some amount of legwork we could get rid of If we don't want to fix |
Any updates on this? |
This would also be nice for crates which offer optional binaries, where there are features that don't have to be there by default for the library but are required for binaries. |
Just wanted to point that the feature proposal from rust-lang/rfcs#2887 will fix this if implemented. |
I haven't seen it mentioned here, but the current behaviour is anti-useful:
|
Running into rust-lang/cargo#4663 for the examples.
Just to add that I've currently come up with a project cargo-rx which abstracts away FWIW, I agree it'd be nice to see this feature supported by default in |
fyi: Rust Analyzer "Run" action (F1 -> Rust Analyzer: Run in vscode) enables required features for examples. |
Any updates on this issue? |
|
Well, we didn't get What now? 😕 |
As #10409 was closed in favor of this issue could the title maybe be adjusted to also mention bins? |
If I have a crate like:
It would be awesome if
cargo run --example myexample
automatically enabled themyfeature
feature for me, rather than producing an error message like it does today. There is no situation where I can do anything useful without padding the additional--features myfeature
flag.This is the current message:
See also #2911
The text was updated successfully, but these errors were encountered: