-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
A-featuresArea: features — conditional compilationArea: features — conditional compilationA-manifestArea: Cargo.toml issuesArea: Cargo.toml issuesC-tracking-issueCategory: A tracking issue for something unstable.Category: A tracking issue for something unstable.S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Description
Summary
RFC: #3416
Implementation: #NNNN
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#feature-metadata
Extend the schema for feature activations to be a table, not just an array, so more fields can be added in the future.
Unresolved Issues
No response
Future Extensions
- RFC: Cargo feature descriptions rfcs#3485
- RFC: Cargo feature deprecation rfcs#3486
- RFC: Cargo feature visibility (private/public) rfcs#3487
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
linyihai and amab8901joseluis and jessebraham
Metadata
Metadata
Assignees
Labels
A-featuresArea: features — conditional compilationArea: features — conditional compilationA-manifestArea: Cargo.toml issuesArea: Cargo.toml issuesC-tracking-issueCategory: A tracking issue for something unstable.Category: A tracking issue for something unstable.S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Type
Projects
Status
No status
Milestone
Relationships
Development
Select code repository
Activity
amab8901 commentedon Aug 17, 2024
The docs link u posted (https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#feature-metadata) seems obsolete since there is no section called
feature-metadata
in that pageweihanglo commentedon Aug 17, 2024
@amab8901 it is just a placeholder because it hasn't yet implemented
amab8901 commentedon Aug 24, 2024
I think I found the place in the

cargo
source code that needs to be changed to implement this feature:The
Vec<String>
should probably be replaced withBTreeMap<String,String>
. At least that's my first thought. But then I realize it will prob break the old syntax. So now I'm thinking maybe we need some kind of generic? Or perhaps some kind of match statement to deal with Vec vs BTreeMap separately?epage commentedon Aug 25, 2024
That section of code is an internal data structure to track
cargo add
s command-line.Cargo.toml
s definition is incrates/cargo-util-schemas
. An untagged enum would need to be used, much like we have "simple" and "detailed" dependencies. All of this would need to be behind an unstable feature as mentioned behind our contributor guide. We'd also need to make sure that people not using this syntax aren't switched to it oncargo publish
so we don't force everyone to upgrade cargo.With all that said, I'm unsure how much benefit there is on moving this forward until we have fields to take advantage of it.
amab8901 commentedon Aug 25, 2024
do u have an RFC for the fields that we are waiting for?
weihanglo commentedon Aug 25, 2024
See future extensions in the PR description.
amab8901 commentedon Aug 25, 2024
My understanding is that you first need to solve this RFC before you can add those fields. Otherwise, when you try to add those fields, the compiler will complain and say "this is invalid syntax in Cargo.toml !"
tgross35 commentedon Aug 25, 2024
If you are looking to put up a PR, I think the thing that could be changed now is to add a new unstable feature that allows parsing the alternate syntax for feature dependencies:
This was accepted with RFC3416. The other attributes (e.g.
doc
) can't yet be added since they haven't yet been accepted, but it will be easy to expand to them once this groundwork is in.epage commentedon Aug 26, 2024
Note that I said
The important thing for the other RFCs was metadata RFC being approved.