diff options
author | Aleksey Kladov <[email protected]> | 2020-06-10 11:34:23 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-06-10 11:34:23 +0100 |
commit | db1cadd4447f7c580c5436a4368a4de3c67fa37a (patch) | |
tree | afa0afa35ca069de038d6aa01772097a6873804f /crates/ra_ide_db/src | |
parent | 560b98bc505be6ff70876df661e4055e1b38a78c (diff) |
In field patterns, don't highlight local binding as a field
Diffstat (limited to 'crates/ra_ide_db/src')
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 9 |
1 files changed, 6 insertions, 3 deletions
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 { | |||
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | #[derive(Debug)] | ||
81 | pub enum NameClass { | 82 | pub enum NameClass { |
82 | Definition(Definition), | 83 | Definition(Definition), |
83 | /// `None` in `if let None = Some(82) {}` | 84 | /// `None` in `if let None = Some(82) {}` |
@@ -131,9 +132,11 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option | |||
131 | let local = sema.to_def(&it)?; | 132 | let local = sema.to_def(&it)?; |
132 | 133 | ||
133 | if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordFieldPat::cast) { | 134 | if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordFieldPat::cast) { |
134 | if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { | 135 | if record_field_pat.name_ref().is_none() { |
135 | let field = Definition::Field(field); | 136 | if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { |
136 | return Some(NameClass::FieldShorthand { local, field }); | 137 | let field = Definition::Field(field); |
138 | return Some(NameClass::FieldShorthand { local, field }); | ||
139 | } | ||
137 | } | 140 | } |
138 | } | 141 | } |
139 | 142 | ||