From 9e8f4d31a40eca605a047ed95a98aac43a3e327f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 23 Feb 2021 23:31:07 +0100 Subject: Pickup ConstReference patterns in FindUsages --- crates/ide_db/src/search.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'crates/ide_db/src') diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index ba8bea002..ddcfbd3f3 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs @@ -416,10 +416,11 @@ impl<'a> FindUsages<'a> { sink: &mut dyn FnMut(FileId, FileReference) -> bool, ) -> bool { match NameClass::classify(self.sema, name) { - Some(NameClass::PatFieldShorthand { local_def: _, field_ref }) => { - if !matches!(self.def, Definition::Field(_) if &field_ref == self.def) { - return false; - } + Some(NameClass::PatFieldShorthand { local_def: _, field_ref }) + if matches!( + self.def, Definition::Field(_) if &field_ref == self.def + ) => + { let FileRange { file_id, range } = self.sema.original_range(name.syntax()); let reference = FileReference { range, @@ -429,6 +430,12 @@ impl<'a> FindUsages<'a> { }; sink(file_id, reference) } + Some(NameClass::ConstReference(def)) if *self.def == def => { + let FileRange { file_id, range } = self.sema.original_range(name.syntax()); + let reference = + FileReference { range, name: ast::NameLike::Name(name.clone()), access: None }; + sink(file_id, reference) + } _ => false, // not a usage } } -- cgit v1.2.3