Skip to content

Commit c1a8c03

Browse files
Merge #6181
6181: Fix source_to_def for named enum variant fields r=jonas-schievink a=jonas-schievink bors r+ 🤖 Co-authored-by: Jonas Schievink <[email protected]>
2 parents 636b413 + 468b804 commit c1a8c03

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

crates/hir/src/semantics/source_to_def.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ impl SourceToDefCtx<'_, '_> {
189189
let def = self.type_alias_to_def(container.with_value(it))?;
190190
def.into()
191191
},
192+
ast::Variant(it) => {
193+
let def = self.enum_variant_to_def(container.with_value(it))?;
194+
VariantId::from(def).into()
195+
},
192196
_ => continue,
193197
}
194198
};

crates/ide/src/references.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,23 @@ enum Foo {
405405
);
406406
}
407407

408+
#[test]
409+
fn test_find_all_refs_enum_var_field() {
410+
check(
411+
r#"
412+
enum Foo {
413+
A,
414+
B { field<|>: u8 },
415+
C,
416+
}
417+
"#,
418+
expect![[r#"
419+
field RECORD_FIELD FileId(0) 26..35 26..31 Other
420+
421+
"#]],
422+
);
423+
}
424+
408425
#[test]
409426
fn test_find_all_refs_two_modules() {
410427
check(

0 commit comments

Comments
 (0)