diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index 5918b9541be..66fc11611b1 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs @@ -189,6 +189,10 @@ impl SourceToDefCtx<'_, '_> { let def = self.type_alias_to_def(container.with_value(it))?; def.into() }, + ast::Variant(it) => { + let def = self.enum_variant_to_def(container.with_value(it))?; + VariantId::from(def).into() + }, _ => continue, } }; diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index e0830eb4fc6..ae68b4392ed 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs @@ -405,6 +405,23 @@ enum Foo { ); } + #[test] + fn test_find_all_refs_enum_var_field() { + check( + r#" +enum Foo { + A, + B { field<|>: u8 }, + C, +} +"#, + expect![[r#" + field RECORD_FIELD FileId(0) 26..35 26..31 Other + + "#]], + ); + } + #[test] fn test_find_all_refs_two_modules() { check(