@@ -144,8 +144,8 @@ pub fn parse_check_cfg(specs: Vec<String>) -> CheckCfg {
144
144
145
145
let expected_error = || {
146
146
error ! (
147
- "expected `names(name1, name2, ... nameN )` or \
148
- `values (name, \" value1\" , \" value2\" , ... \" valueN\" )`"
147
+ "expected `exhaustive(names, values )` or \
148
+ `configure (name, \" value1\" , \" value2\" , ... \" valueN\" )`"
149
149
)
150
150
} ;
151
151
@@ -206,6 +206,64 @@ pub fn parse_check_cfg(specs: Vec<String>) -> CheckCfg {
206
206
} else {
207
207
expected_error ( ) ;
208
208
}
209
+ } else if meta_item. has_name ( sym:: exhaustive) {
210
+ for arg in args {
211
+ if arg. is_word ( ) && let Some ( ident) = arg. ident ( ) {
212
+ if ident. name == sym:: names {
213
+ check_cfg. exhaustive_names = true ;
214
+ } else if ident. name == sym:: values {
215
+ check_cfg. exhaustive_values = true ;
216
+ } else {
217
+ error ! (
218
+ "expected `exhaustive(names)` or `exhaustive(values)`"
219
+ ) ;
220
+ }
221
+ } else {
222
+ error ! (
223
+ "`exhaustive()` arguments must be simple identifiers"
224
+ ) ;
225
+ }
226
+ }
227
+ } else if meta_item. has_name ( sym:: configure) {
228
+ let mut names = Vec :: new ( ) ;
229
+ let mut values: FxHashSet < _ > = Default :: default ( ) ;
230
+
231
+ for arg in args {
232
+ if arg. is_word ( ) && let Some ( ident) = arg. ident ( ) {
233
+ if !values. is_empty ( ) {
234
+ error ! ( "`configure()` names cannot be after values" ) ;
235
+ }
236
+ names. push ( ident) ;
237
+ } else if let Some ( LitKind :: Str ( s, _) ) =
238
+ arg. lit ( ) . map ( |lit| & lit. kind )
239
+ {
240
+ if names. is_empty ( ) {
241
+ error ! (
242
+ "`configure()` first arguments must be simple identifiers"
243
+ ) ;
244
+ }
245
+ values. insert ( Some ( s. to_string ( ) ) ) ;
246
+ } else {
247
+ error ! (
248
+ "`configure()` arguments must be simple identifiers or string literals"
249
+ ) ;
250
+ }
251
+ }
252
+
253
+ if values. is_empty ( ) {
254
+ values. insert ( None ) ;
255
+ }
256
+
257
+ for name in names {
258
+ check_cfg
259
+ . expecteds
260
+ . entry ( name. to_string ( ) )
261
+ . and_modify ( |v| match v {
262
+ ExpectedValues :: Some ( v) => v. extend ( values. clone ( ) ) ,
263
+ ExpectedValues :: Any => { }
264
+ } )
265
+ . or_insert_with ( || ExpectedValues :: Some ( values. clone ( ) ) ) ;
266
+ }
209
267
} else {
210
268
expected_error ( ) ;
211
269
}
0 commit comments