From 4f7da04c6735e1d00fceb6fc6f83542626ce03c9 Mon Sep 17 00:00:00 2001 From: succcubbus <16743652+succcubbus@users.noreply.github.com> Date: Fri, 13 Dec 2019 21:59:25 +0100 Subject: add tests for goto on tuple fields --- crates/ra_ide/src/goto_definition.rs | 16 ++++++++++++++++ crates/ra_ide/src/goto_type_definition.rs | 18 +++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 96a73675f..30118b43f 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -446,6 +446,22 @@ mod tests { ); } + #[test] + fn goto_for_tuple_fields() { + check_goto( + " + //- /lib.rs + struct Foo(u32); + + fn bar() { + let foo = Foo(0); + foo.<|>0; + } + ", + "TUPLE_FIELD_DEF FileId(1) [11; 14)", + ); + } + #[test] fn goto_definition_works_for_ufcs_inherent_methods() { check_goto( diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index cc1b90925..5501bb742 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -104,7 +104,7 @@ mod tests { } #[test] - fn goto_type_definition_works_param() { + fn goto_type_definition_for_param() { check_goto( " //- /lib.rs @@ -114,4 +114,20 @@ mod tests { "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", ); } + + #[test] + fn goto_type_definition_for_tuple_field() { + check_goto( + " + //- /lib.rs + struct Foo; + struct Bar(Foo); + fn foo() { + let bar = Bar(Foo); + bar.<|>0; + } + ", + "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", + ); + } } -- cgit v1.2.3