diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-18 21:18:57 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-18 21:18:57 +0100 |
commit | 36840bd6c71eaf18cdf418c92af51c24e547a4a7 (patch) | |
tree | 3fd05cafec5a30f98780670cac8402196ed2ff06 /crates/ra_ide/src | |
parent | 7a59cd49ff2bb47fa0844fcf5f1ec44f32523b1b (diff) | |
parent | b79fd82559642f4fe504c0c382b86d57c666be1d (diff) |
Merge #4036
4036: Fix a bunch of unresovled references r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/goto_definition.rs | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 8aed94d16..9998ca5a3 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs | |||
@@ -62,10 +62,9 @@ pub(crate) enum ReferenceResult { | |||
62 | 62 | ||
63 | impl ReferenceResult { | 63 | impl ReferenceResult { |
64 | fn to_vec(self) -> Vec<NavigationTarget> { | 64 | fn to_vec(self) -> Vec<NavigationTarget> { |
65 | use self::ReferenceResult::*; | ||
66 | match self { | 65 | match self { |
67 | Exact(target) => vec![target], | 66 | ReferenceResult::Exact(target) => vec![target], |
68 | Approximate(vec) => vec, | 67 | ReferenceResult::Approximate(vec) => vec, |
69 | } | 68 | } |
70 | } | 69 | } |
71 | } | 70 | } |
@@ -74,8 +73,6 @@ pub(crate) fn reference_definition( | |||
74 | sema: &Semantics<RootDatabase>, | 73 | sema: &Semantics<RootDatabase>, |
75 | name_ref: &ast::NameRef, | 74 | name_ref: &ast::NameRef, |
76 | ) -> ReferenceResult { | 75 | ) -> ReferenceResult { |
77 | use self::ReferenceResult::*; | ||
78 | |||
79 | let name_kind = classify_name_ref(sema, name_ref); | 76 | let name_kind = classify_name_ref(sema, name_ref); |
80 | if let Some(def) = name_kind { | 77 | if let Some(def) = name_kind { |
81 | let def = def.definition(); | 78 | let def = def.definition(); |
@@ -91,7 +88,7 @@ pub(crate) fn reference_definition( | |||
91 | .into_iter() | 88 | .into_iter() |
92 | .map(|s| s.to_nav(sema.db)) | 89 | .map(|s| s.to_nav(sema.db)) |
93 | .collect(); | 90 | .collect(); |
94 | Approximate(navs) | 91 | ReferenceResult::Approximate(navs) |
95 | } | 92 | } |
96 | 93 | ||
97 | #[cfg(test)] | 94 | #[cfg(test)] |
@@ -399,6 +396,25 @@ mod tests { | |||
399 | } | 396 | } |
400 | 397 | ||
401 | #[test] | 398 | #[test] |
399 | fn goto_def_for_record_pat_fields() { | ||
400 | covers!(ra_ide_db::goto_def_for_record_field_pats); | ||
401 | check_goto( | ||
402 | r" | ||
403 | //- /lib.rs | ||
404 | struct Foo { | ||
405 | spam: u32, | ||
406 | } | ||
407 | |||
408 | fn bar(foo: Foo) -> Foo { | ||
409 | let Foo { spam<|>: _, } = foo | ||
410 | } | ||
411 | ", | ||
412 | "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", | ||
413 | "spam: u32|spam", | ||
414 | ); | ||
415 | } | ||
416 | |||
417 | #[test] | ||
402 | fn goto_def_for_record_fields_macros() { | 418 | fn goto_def_for_record_fields_macros() { |
403 | check_goto( | 419 | check_goto( |
404 | r" | 420 | r" |