From db1cadd4447f7c580c5436a4368a4de3c67fa37a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 10 Jun 2020 12:34:23 +0200 Subject: In field patterns, don't highlight local binding as a field --- crates/ra_ide_db/src/defs.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide_db') diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 1826f3ac6..3ef5e74b6 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -78,6 +78,7 @@ impl Definition { } } +#[derive(Debug)] pub enum NameClass { Definition(Definition), /// `None` in `if let None = Some(82) {}` @@ -131,9 +132,11 @@ pub fn classify_name(sema: &Semantics, name: &ast::Name) -> Option let local = sema.to_def(&it)?; if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordFieldPat::cast) { - if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { - let field = Definition::Field(field); - return Some(NameClass::FieldShorthand { local, field }); + if record_field_pat.name_ref().is_none() { + if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { + let field = Definition::Field(field); + return Some(NameClass::FieldShorthand { local, field }); + } } } -- cgit v1.2.3