@@ -164,34 +164,31 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
164
164
expected_error ( ) ;
165
165
} ;
166
166
167
- if meta_item . has_name ( sym :: names ) {
167
+ let mut set_old_syntax = || {
168
168
// defaults are flipped for the old syntax
169
169
if old_syntax == None {
170
170
check_cfg. exhaustive_names = false ;
171
171
check_cfg. exhaustive_values = false ;
172
172
}
173
173
old_syntax = Some ( true ) ;
174
+ } ;
175
+
176
+ if meta_item. has_name ( sym:: names) {
177
+ set_old_syntax ( ) ;
174
178
175
179
check_cfg. exhaustive_names = true ;
176
180
for arg in args {
177
- if arg. is_word ( ) && arg. ident ( ) . is_some ( ) {
178
- let ident = arg. ident ( ) . expect ( "multi-segment cfg key" ) ;
181
+ if arg. is_word ( ) && let Some ( ident) = arg. ident ( ) {
179
182
check_cfg. expecteds . entry ( ident. name ) . or_insert ( ExpectedValues :: Any ) ;
180
183
} else {
181
184
error ! ( "`names()` arguments must be simple identifiers" ) ;
182
185
}
183
186
}
184
187
} else if meta_item. has_name ( sym:: values) {
185
- // defaults are flipped for the old syntax
186
- if old_syntax == None {
187
- check_cfg. exhaustive_names = false ;
188
- check_cfg. exhaustive_values = false ;
189
- }
190
- old_syntax = Some ( true ) ;
188
+ set_old_syntax ( ) ;
191
189
192
190
if let Some ( ( name, values) ) = args. split_first ( ) {
193
- if name. is_word ( ) && name. ident ( ) . is_some ( ) {
194
- let ident = name. ident ( ) . expect ( "multi-segment cfg key" ) ;
191
+ if name. is_word ( ) && let Some ( ident) = name. ident ( ) {
195
192
let expected_values = check_cfg
196
193
. expecteds
197
194
. entry ( ident. name )
@@ -244,19 +241,15 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
244
241
error ! ( "`cfg()` names cannot be after values" ) ;
245
242
}
246
243
names. push ( ident) ;
247
- } else if arg. has_name ( sym:: any)
248
- && let Some ( args) = arg. meta_item_list ( )
249
- {
244
+ } else if arg. has_name ( sym:: any) && let Some ( args) = arg. meta_item_list ( ) {
250
245
if any_specified {
251
246
error ! ( "`any()` cannot be specified multiple times" ) ;
252
247
}
253
248
any_specified = true ;
254
249
if !args. is_empty ( ) {
255
250
error ! ( "`any()` must be empty" ) ;
256
251
}
257
- } else if arg. has_name ( sym:: values)
258
- && let Some ( args) = arg. meta_item_list ( )
259
- {
252
+ } else if arg. has_name ( sym:: values) && let Some ( args) = arg. meta_item_list ( ) {
260
253
if names. is_empty ( ) {
261
254
error ! ( "`values()` cannot be specified before the names" ) ;
262
255
} else if values_specified {
@@ -267,22 +260,16 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
267
260
for arg in args {
268
261
if let Some ( LitKind :: Str ( s, _) ) = arg. lit ( ) . map ( |lit| & lit. kind ) {
269
262
values. insert ( Some ( * s) ) ;
270
- } else if arg. has_name ( sym:: any)
271
- && let Some ( args) = arg. meta_item_list ( )
272
- {
263
+ } else if arg. has_name ( sym:: any) && let Some ( args) = arg. meta_item_list ( ) {
273
264
if values_any_specified {
274
- error ! (
275
- "`any()` in `values()` cannot be specified multiple times"
276
- ) ;
265
+ error ! ( "`any()` in `values()` cannot be specified multiple times" ) ;
277
266
}
278
267
values_any_specified = true ;
279
268
if !args. is_empty ( ) {
280
269
error ! ( "`any()` must be empty" ) ;
281
270
}
282
271
} else {
283
- error ! (
284
- "`values()` arguments must be string literals or `any()`"
285
- ) ;
272
+ error ! ( "`values()` arguments must be string literals or `any()`" ) ;
286
273
}
287
274
}
288
275
} else {
0 commit comments