Skip to content

Commit

Permalink
Merge #6181
Browse files Browse the repository at this point in the history
6181: Fix source_to_def for named enum variant fields r=jonas-schievink a=jonas-schievink

bors r+ 🤖

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
  • Loading branch information
bors[bot] and jonas-schievink authored Oct 9, 2020
2 parents 636b413 + 468b804 commit c1a8c03
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/hir/src/semantics/source_to_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};
Expand Down
17 changes: 17 additions & 0 deletions crates/ide/src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c1a8c03

Please sign in to comment.