rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.75k stars 2.42k forks source link

cargo should automatically enable an example's required features #8583

Closed Lokathor closed 3 years ago

Lokathor commented 4 years ago

Describe the problem you are trying to solve If you attempt to run an example with a required feature that's not a default feature of the crate, cargo prints an error message.

Describe the solution you'd like Instead, cargo should "do what I mean": just enable any additional required features for that example and then run the example.

Notes A similar change can be made for test and bins.

cc @joshtriplett

joshtriplett commented 4 years ago

I think this would be reasonable, as long as Cargo printed a message saying that was what it was doing. For instance:

Example `abc` requires feature `xyz`; rebuilding crate with feature `xyz`...
pksunkara commented 3 years ago

Duplicate of #4663?

Lokathor commented 3 years ago

sure looks that way. closing.