Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a3114c3

Browse files
author
daniel.eades
committed
move loop index inside iterator
1 parent 6153ea8 commit a3114c3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

crates/hir-def/src/attr.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,18 @@ impl Attrs {
251251
let enum_ = &item_tree[loc.id.value];
252252

253253
let cfg_options = &crate_graph[krate].cfg_options;
254-
let mut idx = 0;
255-
let Some(variant) = enum_.variants.clone().find(|variant| {
254+
255+
let Some(variant) = enum_.variants.clone().filter(|variant| {
256256
let attrs = item_tree.attrs(db, krate, (*variant).into());
257-
if attrs.is_cfg_enabled(cfg_options) {
258-
if it.local_id == Idx::from_raw(RawIdx::from(idx)) {
259-
return true
260-
}
261-
idx += 1;
262-
}
263-
false
264-
}) else {
257+
attrs.is_cfg_enabled(cfg_options)
258+
})
259+
.zip(0u32..)
260+
.find(|(_variant, idx)| it.local_id == Idx::from_raw(RawIdx::from(*idx)))
261+
.map(|(variant, _idx)| variant)
262+
else {
265263
return Arc::new(res);
266264
};
265+
267266
(item_tree[variant].fields.clone(), item_tree, krate)
268267
}
269268
VariantId::StructId(it) => {

0 commit comments

Comments
 (0)