Skip to content

Automatically enable required-features #4663

@mystor

Description

@mystor

If I have a crate like:

[package]
name = "foo"

[features]
myfeature = []
another = []

[[example]]
name = "myexample"
required-features = ["myfeature", "another"]

It would be awesome if cargo run --example myexample automatically enabled the myfeature 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:

error: target `myexample` requires the features: `myfeature`, `another`
Consider enabling them by passing e.g. `--features="myfeature another"`

See also #2911

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-featuresArea: features — conditional compilationA-required-featuresArea: required-features settingC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions