rust-lang / rfcs

RFCs for changes to Rust
https://rust-lang.github.io/rfcs/
Apache License 2.0
5.78k stars 1.55k forks source link

Cargo structured syntax for feature dependencies on crates #3663

Open joshtriplett opened 1 week ago

joshtriplett commented 1 week ago

This RFC extends Cargo's structured table form of features to include a deps key, to unambiguously specify packages the feature depends on without having to use the dep:foo microformat.

[features]
myfeature = { deps = ["some-crate", "another-crate"] }
# This is equivalent to `myfeature = ["dep:some-crate", "dep:another-crate"]`
# This can also be written in shorthand form:
myfeature.deps = ["some-crate", "another-crate"]

This incremental RFC was inspired by the incremental, easier-to-review RFCs currently being used for other individual pieces of the structured table format for features.

Rendered

chrysn commented 4 days ago

I like this because of previously unmentioned future possibilities: It paves the way to have documentation on features in a more parsable format than what is currently used for the document-features crate, and it could provide machine readable descriptions for the impact on stability of a given feature (when features are used in a way that alters semver guarantees, or increase the MSRV).

[edit: Comment should have been to 3416, sorry for the noise, thanks for the clarification in https://github.com/rust-lang/rfcs/pull/3663#issuecomment-2194671155]

epage commented 3 days ago

Note that the table syntax is independent of this and its RFC has been merged. There is a description RFC up.