File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -128,19 +128,18 @@ impl Attrs {
128128 let enum_ = & item_tree[ loc. id . value ] ;
129129
130130 let cfg_options = & crate_graph[ krate] . cfg_options ;
131- let variant = ' tri: loop {
132- let mut idx = 0 ;
133- for variant in enum_. variants . clone ( ) {
134- let attrs = item_tree. attrs ( db, krate, variant. into ( ) ) ;
135- if attrs. is_cfg_enabled ( cfg_options) {
136- if it. local_id == Idx :: from_raw ( RawIdx :: from ( idx) ) {
137- break ' tri variant;
138- }
139- idx += 1 ;
140- }
141- }
131+
132+ let Some ( variant) = enum_. variants . clone ( ) . filter ( |variant| {
133+ let attrs = item_tree. attrs ( db, krate, ( * variant) . into ( ) ) ;
134+ attrs. is_cfg_enabled ( cfg_options)
135+ } )
136+ . zip ( 0u32 ..)
137+ . find ( |( _variant, idx) | it. local_id == Idx :: from_raw ( RawIdx :: from ( * idx) ) )
138+ . map ( |( variant, _idx) | variant)
139+ else {
142140 return Arc :: new ( res) ;
143141 } ;
142+
144143 ( item_tree[ variant] . fields . clone ( ) , item_tree, krate)
145144 }
146145 VariantId :: StructId ( it) => {
You can’t perform that action at this time.
0 commit comments