diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-09 02:00:18 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-09 02:00:18 +0100 |
commit | c1a8c032994ea9af478ccb48e229754ad0e677e1 (patch) | |
tree | 4d9f2e64cc20459dc3bc71088332880baab81a29 | |
parent | 636b413e142e2b831ded74642c8193a0dc39b4a7 (diff) | |
parent | 468b80485644bf1b15dee97d15029378f0f6d199 (diff) |
Merge #6181
6181: Fix source_to_def for named enum variant fields r=jonas-schievink a=jonas-schievink
bors r+ :robot:
Co-authored-by: Jonas Schievink <[email protected]>
-rw-r--r-- | crates/hir/src/semantics/source_to_def.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/references.rs | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index 5918b9541..66fc11611 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<'_, '_> { | |||
189 | let def = self.type_alias_to_def(container.with_value(it))?; | 189 | let def = self.type_alias_to_def(container.with_value(it))?; |
190 | def.into() | 190 | def.into() |
191 | }, | 191 | }, |
192 | ast::Variant(it) => { | ||
193 | let def = self.enum_variant_to_def(container.with_value(it))?; | ||
194 | VariantId::from(def).into() | ||
195 | }, | ||
192 | _ => continue, | 196 | _ => continue, |
193 | } | 197 | } |
194 | }; | 198 | }; |
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index e0830eb4f..ae68b4392 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -406,6 +406,23 @@ enum Foo { | |||
406 | } | 406 | } |
407 | 407 | ||
408 | #[test] | 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 | |||
425 | #[test] | ||
409 | fn test_find_all_refs_two_modules() { | 426 | fn test_find_all_refs_two_modules() { |
410 | check( | 427 | check( |
411 | r#" | 428 | r#" |