aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db')
-rw-r--r--crates/ra_ide_db/src/search.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs
index 9436a7562..b843b5b57 100644
--- a/crates/ra_ide_db/src/search.rs
+++ b/crates/ra_ide_db/src/search.rs
@@ -30,7 +30,8 @@ pub struct Reference {
30 30
31#[derive(Debug, Clone, PartialEq)] 31#[derive(Debug, Clone, PartialEq)]
32pub enum ReferenceKind { 32pub enum ReferenceKind {
33 StructFieldShorthand, 33 StructFieldShorthandForField,
34 StructFieldShorthandForLocal,
34 StructLiteral, 35 StructLiteral,
35 Other, 36 Other,
36} 37}
@@ -238,8 +239,8 @@ impl Definition {
238 // FIXME: reuse sb 239 // FIXME: reuse sb
239 // See https://github.com/rust-lang/rust/pull/68198#issuecomment-574269098 240 // See https://github.com/rust-lang/rust/pull/68198#issuecomment-574269098
240 241
241 match (classify_name_ref(&sema, &name_ref), self) { 242 match classify_name_ref(&sema, &name_ref) {
242 (Some(NameRefClass::Definition(def)), _) if &def == self => { 243 Some(NameRefClass::Definition(def)) if &def == self => {
243 let kind = if is_record_lit_name_ref(&name_ref) 244 let kind = if is_record_lit_name_ref(&name_ref)
244 || is_call_expr_name_ref(&name_ref) 245 || is_call_expr_name_ref(&name_ref)
245 { 246 {
@@ -255,14 +256,19 @@ impl Definition {
255 access: reference_access(&def, &name_ref), 256 access: reference_access(&def, &name_ref),
256 }); 257 });
257 } 258 }
258 ( 259 Some(NameRefClass::FieldShorthand { local, field: _ }) => {
259 Some(NameRefClass::FieldShorthand { local, field: _ }), 260 let kind = match self {
260 Definition::StructField(_), 261 Definition::StructField(_) => {
261 ) => { 262 ReferenceKind::StructFieldShorthandForField
263 }
264 Definition::Local(_) => ReferenceKind::StructFieldShorthandForLocal,
265 _ => continue,
266 };
267
262 let file_range = sema.original_range(name_ref.syntax()); 268 let file_range = sema.original_range(name_ref.syntax());
263 refs.push(Reference { 269 refs.push(Reference {
264 file_range: file_range, 270 file_range,
265 kind: ReferenceKind::StructFieldShorthand, 271 kind,
266 access: reference_access(&Definition::Local(local), &name_ref), 272 access: reference_access(&Definition::Local(local), &name_ref),
267 }); 273 });
268 } 274 }