@@ -2315,31 +2315,36 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2315
2315
return true ;
2316
2316
}
2317
2317
2318
+ // Unnamed top-level enums are special and we
2319
+ // whitelist them via the `whitelisted_vars` filter,
2320
+ // since they're effectively top-level constants,
2321
+ // and there's no way for them to be referenced
2322
+ // consistently.
2318
2323
let parent = self . resolve_item ( item. parent_id ( ) ) ;
2319
- if parent. is_module ( ) {
2320
- let mut prefix_path = parent. path_for_whitelisting ( self ) ;
2321
-
2322
- // Unnamed top-level enums are special and we
2323
- // whitelist them via the `whitelisted_vars` filter,
2324
- // since they're effectively top-level constants,
2325
- // and there's no way for them to be referenced
2326
- // consistently.
2327
- if let TypeKind :: Enum ( ref enum_) = * ty. kind ( ) {
2328
- if ty. name ( ) . is_none ( ) &&
2329
- enum_. variants ( ) . iter ( ) . any ( |variant| {
2330
- prefix_path. push ( variant. name ( ) . into ( ) ) ;
2331
- let name = prefix_path[ 1 ..] . join ( "::" ) ;
2332
- prefix_path. pop ( ) . unwrap ( ) ;
2333
- self . options ( )
2334
- . whitelisted_vars
2335
- . matches ( & name)
2336
- } ) {
2337
- return true ;
2338
- }
2339
- }
2324
+ if !parent. is_module ( ) {
2325
+ return false ;
2340
2326
}
2341
2327
2342
- false
2328
+
2329
+ let enum_ = match * ty. kind ( ) {
2330
+ TypeKind :: Enum ( ref e) => e,
2331
+ _ => return false ,
2332
+ } ;
2333
+
2334
+ if ty. name ( ) . is_some ( ) {
2335
+ return false ;
2336
+ }
2337
+
2338
+ let mut prefix_path =
2339
+ parent. path_for_whitelisting ( self ) ;
2340
+ enum_. variants ( ) . iter ( ) . any ( |variant| {
2341
+ prefix_path. push ( variant. name ( ) . into ( ) ) ;
2342
+ let name = prefix_path[ 1 ..] . join ( "::" ) ;
2343
+ prefix_path. pop ( ) . unwrap ( ) ;
2344
+ self . options ( )
2345
+ . whitelisted_vars
2346
+ . matches ( & name)
2347
+ } )
2343
2348
}
2344
2349
}
2345
2350
} )
0 commit comments