From 13ccbb2919dff8e98d0a242d9d6b7edd17a6bd2c Mon Sep 17 00:00:00 2001 From: Matt Niemeir Date: Tue, 10 Mar 2020 22:27:38 -0500 Subject: find_usages limited to actual usages again --- crates/ra_ide_db/src/search.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'crates/ra_ide_db') diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index b843b5b57..cf78d3e41 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -256,21 +256,21 @@ impl Definition { access: reference_access(&def, &name_ref), }); } - Some(NameRefClass::FieldShorthand { local, field: _ }) => { - let kind = match self { - Definition::StructField(_) => { - ReferenceKind::StructFieldShorthandForField - } - Definition::Local(_) => ReferenceKind::StructFieldShorthandForLocal, - _ => continue, + Some(NameRefClass::FieldShorthand { local, field }) => { + match self { + Definition::StructField(_) if &field == self => refs.push(Reference { + file_range: sema.original_range(name_ref.syntax()), + kind: ReferenceKind::StructFieldShorthandForField, + access: reference_access(&field, &name_ref), + }), + Definition::Local(l) if &local == l => refs.push(Reference { + file_range: sema.original_range(name_ref.syntax()), + kind: ReferenceKind::StructFieldShorthandForLocal, + access: reference_access(&Definition::Local(local), &name_ref), + }), + + _ => {} // not a usage }; - - let file_range = sema.original_range(name_ref.syntax()); - refs.push(Reference { - file_range, - kind, - access: reference_access(&Definition::Local(local), &name_ref), - }); } _ => {} // not a usage } -- cgit v1.2.3