From fa2ea8f494d8434da705dc0e0f047f3bd7503af9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 18 Apr 2020 22:05:06 +0200 Subject: Fix goto definition for record patterns --- crates/ra_ide_db/src/defs.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'crates/ra_ide_db/src/defs.rs') diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 49a8c74fb..785613b82 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -180,6 +180,7 @@ fn classify_name_inner(sema: &Semantics, name: &ast::Name) -> Opti } } +#[derive(Debug)] pub enum NameRefClass { Definition(Definition), FieldShorthand { local: Local, field: Definition }, @@ -229,6 +230,14 @@ pub fn classify_name_ref( } } + if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) { + tested_by!(goto_def_for_record_field_pats; force); + if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { + let field = Definition::StructField(field); + return Some(NameRefClass::Definition(field)); + } + } + if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { tested_by!(goto_def_for_macros; force); if let Some(macro_def) = sema.resolve_macro_call(¯o_call) { -- cgit v1.2.3