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

Commit cdbe025

Browse files
committed
Auto merge of rust-lang#13922 - danieleades:loop-that-never-loops, r=lnicola
minor: loop-that-never-loops closes rust-lang#13921
2 parents c7a3f34 + a3114c3 commit cdbe025

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

crates/hir-def/src/attr.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff 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) => {

0 commit comments

Comments
 (0)