@@ -164,34 +164,31 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
164164 expected_error ( ) ;
165165 } ;
166166
167- if meta_item . has_name ( sym :: names ) {
167+ let mut set_old_syntax = || {
168168 // defaults are flipped for the old syntax
169169 if old_syntax == None {
170170 check_cfg. exhaustive_names = false ;
171171 check_cfg. exhaustive_values = false ;
172172 }
173173 old_syntax = Some ( true ) ;
174+ } ;
175+
176+ if meta_item. has_name ( sym:: names) {
177+ set_old_syntax ( ) ;
174178
175179 check_cfg. exhaustive_names = true ;
176180 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 ( ) {
179182 check_cfg. expecteds . entry ( ident. name ) . or_insert ( ExpectedValues :: Any ) ;
180183 } else {
181184 error ! ( "`names()` arguments must be simple identifiers" ) ;
182185 }
183186 }
184187 } 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 ( ) ;
191189
192190 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 ( ) {
195192 let expected_values = check_cfg
196193 . expecteds
197194 . entry ( ident. name )
@@ -244,19 +241,15 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
244241 error ! ( "`cfg()` names cannot be after values" ) ;
245242 }
246243 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 ( ) {
250245 if any_specified {
251246 error ! ( "`any()` cannot be specified multiple times" ) ;
252247 }
253248 any_specified = true ;
254249 if !args. is_empty ( ) {
255250 error ! ( "`any()` must be empty" ) ;
256251 }
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 ( ) {
260253 if names. is_empty ( ) {
261254 error ! ( "`values()` cannot be specified before the names" ) ;
262255 } else if values_specified {
@@ -267,22 +260,16 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
267260 for arg in args {
268261 if let Some ( LitKind :: Str ( s, _) ) = arg. lit ( ) . map ( |lit| & lit. kind ) {
269262 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 ( ) {
273264 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" ) ;
277266 }
278267 values_any_specified = true ;
279268 if !args. is_empty ( ) {
280269 error ! ( "`any()` must be empty" ) ;
281270 }
282271 } else {
283- error ! (
284- "`values()` arguments must be string literals or `any()`"
285- ) ;
272+ error ! ( "`values()` arguments must be string literals or `any()`" ) ;
286273 }
287274 }
288275 } else {
0 commit comments