diff options
Diffstat (limited to 'crates/ide/src/references.rs')
-rw-r--r-- | crates/ide/src/references.rs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index e05465b32..5693dd400 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -110,14 +110,23 @@ pub(crate) fn find_all_refs( | |||
110 | .filter(|r| search_kind == ReferenceKind::Other || search_kind == r.kind) | 110 | .filter(|r| search_kind == ReferenceKind::Other || search_kind == r.kind) |
111 | .collect(); | 111 | .collect(); |
112 | 112 | ||
113 | let decl_range = def.try_to_nav(sema.db)?.focus_or_full_range(); | 113 | let nav = def.try_to_nav(sema.db)?; |
114 | 114 | let decl_range = nav.focus_or_full_range(); | |
115 | let declaration = Declaration { | 115 | |
116 | nav: def.try_to_nav(sema.db)?, | 116 | let mut kind = ReferenceKind::Other; |
117 | kind: ReferenceKind::Other, | 117 | if let Definition::Local(local) = def { |
118 | access: decl_access(&def, &syntax, decl_range), | 118 | if let either::Either::Left(pat) = local.source(sema.db).value { |
119 | if matches!( | ||
120 | pat.syntax().parent().and_then(ast::RecordPatField::cast), | ||
121 | Some(pat_field) if pat_field.name_ref().is_none() | ||
122 | ) { | ||
123 | kind = ReferenceKind::FieldShorthandForLocal; | ||
124 | } | ||
125 | } | ||
119 | }; | 126 | }; |
120 | 127 | ||
128 | let declaration = Declaration { nav, kind, access: decl_access(&def, &syntax, decl_range) }; | ||
129 | |||
121 | Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references })) | 130 | Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references })) |
122 | } | 131 | } |
123 | 132 | ||
@@ -613,7 +622,7 @@ fn foo() { | |||
613 | expect![[r#" | 622 | expect![[r#" |
614 | f RECORD_FIELD FileId(0) 15..21 15..16 Other | 623 | f RECORD_FIELD FileId(0) 15..21 15..16 Other |
615 | 624 | ||
616 | FileId(0) 55..56 Other Read | 625 | FileId(0) 55..56 RecordFieldExprOrPat Read |
617 | FileId(0) 68..69 Other Write | 626 | FileId(0) 68..69 Other Write |
618 | "#]], | 627 | "#]], |
619 | ); | 628 | ); |
@@ -748,7 +757,7 @@ fn f() -> m::En { | |||
748 | expect![[r#" | 757 | expect![[r#" |
749 | field RECORD_FIELD FileId(0) 56..65 56..61 Other | 758 | field RECORD_FIELD FileId(0) 56..65 56..61 Other |
750 | 759 | ||
751 | FileId(0) 125..130 Other Read | 760 | FileId(0) 125..130 RecordFieldExprOrPat Read |
752 | "#]], | 761 | "#]], |
753 | ); | 762 | ); |
754 | } | 763 | } |