aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/goto_definition.rs19
-rw-r--r--crates/ra_ide_db/src/defs.rs6
2 files changed, 25 insertions, 0 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index a6c86e99c..693344c31 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -886,4 +886,23 @@ mod tests {
886 "x", 886 "x",
887 ) 887 )
888 } 888 }
889
890 #[test]
891 fn goto_def_for_enum_variant_field() {
892 check_goto(
893 "
894 //- /lib.rs
895 enum Foo {
896 Bar { x: i32 }
897 }
898 fn baz(foo: Foo) {
899 match foo {
900 Foo::Bar { x<|> } => x
901 };
902 }
903 ",
904 "x RECORD_FIELD_DEF FileId(1) 21..27 21..22",
905 "x: i32|x",
906 );
907 }
889} 908}
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index 1db60b87f..52233937c 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -126,6 +126,12 @@ fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Opti
126 Some(name_ref_class.definition()) 126 Some(name_ref_class.definition())
127 }, 127 },
128 ast::BindPat(it) => { 128 ast::BindPat(it) => {
129 if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordFieldPat::cast) {
130 return Some(Definition::Field(
131 sema.resolve_record_field_pat(&record_field_pat)?
132 ));
133 }
134
129 let local = sema.to_def(&it)?; 135 let local = sema.to_def(&it)?;
130 Some(Definition::Local(local)) 136 Some(Definition::Local(local))
131 }, 137 },