From c7cedea270c492e9a2c8b81c1312fda44fd8217e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 31 Oct 2019 15:13:52 +0100 Subject: Record assoc item resolution --- crates/ra_ide_api/src/goto_definition.rs | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 323faab33..c1ce54bea 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs @@ -390,6 +390,61 @@ mod tests { "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", ); } + + #[test] + fn goto_definition_works_for_ufcs_inherent_methods() { + check_goto( + " + //- /lib.rs + struct Foo; + impl Foo { + fn frobnicate() { } + } + + fn bar(foo: &Foo) { + Foo::frobnicate<|>(); + } + ", + "frobnicate FN_DEF FileId(1) [27; 47) [30; 40)", + ); + } + + #[test] + fn goto_definition_works_for_ufcs_trait_methods_through_traits() { + check_goto( + " + //- /lib.rs + trait Foo { + fn frobnicate(); + } + + fn bar() { + Foo::frobnicate<|>(); + } + ", + "frobnicate FN_DEF FileId(1) [16; 32) [19; 29)", + ); + } + + #[test] + fn goto_definition_works_for_ufcs_trait_methods_through_self() { + check_goto( + " + //- /lib.rs + struct Foo; + trait Trait { + fn frobnicate(); + } + impl Trait for Foo {} + + fn bar() { + Foo::frobnicate<|>(); + } + ", + "frobnicate FN_DEF FileId(1) [30; 46) [33; 43)", + ); + } + #[test] fn goto_definition_on_self() { check_goto( -- cgit v1.2.3