8
8
9
9
[ summary ] : #summary
10
10
11
- This RFC is just meta tracking information for the three following RFCs:
11
+ This RFC adds a "detailed" feature definition:
12
+ ``` toml
13
+ [features ]
14
+ # same as `foo = []`
15
+ foo = { enables = [] }
16
+ ```
17
+
18
+ This is to unblock the following RFCs:
12
19
13
20
- [ Cargo feature descriptions] ( https://github.com/rust-lang/rfcs/pull/3485 )
14
21
- [ Cargo feature deprecation] ( https://github.com/rust-lang/rfcs/pull/3486 )
@@ -68,20 +75,11 @@ features are enabled by a given feature. For example,
68
75
69
76
All other keys are described in their individual RFCs.
70
77
71
- # Reference-level explanation
78
+ ## General Implementation & Usage
72
79
73
- [ reference-level-explanation ] : #reference-level-explanation
74
-
75
- ` enables ` will take the place of the feature dependency array that currently
76
- exists. Semantics will remain unchanged.
77
-
78
- This is a required key. If there are no requirements, an empty list should be
79
- provided (` enables = [] ` ). This content is already in the index.
80
-
81
- # General Implementation & Usage
82
-
83
- Use cases for this information will likely develop with time, but one of the
84
- simplest applications is for information output with ` cargo add ` :
80
+ Use cases for these new keys will likely develop with time,
81
+ but one of the simplest applications is for information output with `cargo
82
+ add`:
85
83
86
84
``` text
87
85
crab@rust foobar % cargo add regex
@@ -105,17 +103,23 @@ crab@rust foobar % cargo add regex
105
103
Features like ` aho-corasick ` , ` memchr ` , or ` use_std ` would likely be
106
104
` public = false ` since they aren't listed on the crate landing page.
107
105
108
- ## Implementation note: sort order
106
+ # Reference-level explanation
107
+
108
+ [ reference-level-explanation ] : #reference-level-explanation
109
+
110
+ ` enables ` will take the place of the feature dependency array that currently
111
+ exists. Semantics will remain unchanged.
109
112
110
- In general, any tool that renders features ( ` rustdoc ` , ` cargo add ` ) should
111
- attempt to present them in the following way:
113
+ This is a required key. If there are no requirements, an empty list should be
114
+ provided ( ` enables = [] ` ). This content is already in the index.
112
115
113
- - Display default features first
114
- - Display non-default but stable features next (can be in a separate section)
115
- - Display deprecated features last (can be in a separate section)
116
- - Do not display private features unless receiving a flag saying to do so (e.g.
117
- ` --document-private-items ` with ` rustdoc ` )
118
- - If ordering is not preserved, present the features alphabetically
116
+ The availability of this new syntax should not require an MSRV bump.
117
+ This means we need to make sure that if you use ` feature_name = [] ` in your ` Cargo.toml ` ,
118
+ then the published ` Cargo.toml ` should as well.
119
+ However, we leave it as an implementation detail whether using ` feature_name = { enables =[] } `
120
+ requires an MSRV bump for users of your published package as we have not been
121
+ actively streamlining the workflow for maintaining separate development and
122
+ published MSRVs.
119
123
120
124
# Drawbacks
121
125
@@ -128,6 +132,23 @@ attempt to present them in the following way:
128
132
129
133
[ rationale-and-alternatives ] : #rationale-and-alternatives
130
134
135
+ This RFC has no impact on the Index Summaries.
136
+ Future RFCs will need to work with that.
137
+
138
+ ## Naming
139
+
140
+ - ` enables ` reads better on the line than ` enable `
141
+ - ` enables ` is likely an easier word for non-native speakers than ` activates `
142
+ - ` required ` is used elsewhere to say "this should automatically be available if requirements are met"
143
+
144
+ ## Schema
145
+
146
+ We could split the special feature syntax (` dep: ` , etc) as distinct fields
147
+ but we'd prefer trivial conversion from the "simple" schema to the "detailed" schema,
148
+ like ` dependencies ` .
149
+ However, we likely would want to prefer using new fields over adding more syntax,
150
+ like with [ disabling default features] ( https://github.com/rust-lang/cargo/issues/3126 ) .
151
+
131
152
# Prior art
132
153
133
154
[ prior-art ] : #prior-art
@@ -140,12 +161,10 @@ attempt to present them in the following way:
140
161
141
162
[ future-possibilities ] : #future-possibilities
142
163
143
- - A ` rust-version ` field that could indicate e.g. ` rust-version = "nightly" ` or
144
- ` rust-version = "1.65" ` to specify a MSRV for that feature. See:
145
- < https://github.com/rust-lang/rfcs/pull/3416#discussion_r1174478461 >
146
- - ` cargo add ` can show the ` doc ` and ` deprecated ` summary with the listed
147
- features.
148
- - [ ` cargo-info ` ] can use this information to provide feature descriptions.
164
+ - [ Cargo feature descriptions] ( https://github.com/rust-lang/rfcs/pull/3485 )
165
+ - [ Cargo feature deprecation] ( https://github.com/rust-lang/rfcs/pull/3486 )
166
+ - [ Cargo feature visibility] ( https://github.com/rust-lang/rfcs/pull/3487 )
167
+ - [ Cargo feature stability] ( https://github.com/rust-lang/cargo/issues/10881 )
149
168
150
169
[ cargo #12335 ] : https://github.com/rust-lang/cargo/issues/12235
151
170
[ cargo #10882 ] : https://github.com/rust-lang/cargo/issues/10882
0 commit comments