diff options
author | vsrs <[email protected]> | 2020-06-10 20:58:25 +0100 |
---|---|---|
committer | vsrs <[email protected]> | 2020-06-18 08:15:43 +0100 |
commit | d4e75312ba64c2541e0d97b9ad8d6e2a735882a4 (patch) | |
tree | 96a2e521edd381a574876cb6b0d90aebe381ecf7 /crates | |
parent | 283ec13fc06dda7ec4d22955e2d2eb96aaff95fd (diff) |
Add associated type test.
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/hover.rs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index c4ee2ff79..2a06006e1 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -2080,4 +2080,61 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
2080 | ] | 2080 | ] |
2081 | "###); | 2081 | "###); |
2082 | } | 2082 | } |
2083 | |||
2084 | #[test] | ||
2085 | fn test_hover_associated_type_has_goto_type_action() { | ||
2086 | let (_, actions) = check_hover_result( | ||
2087 | " | ||
2088 | //- /main.rs | ||
2089 | trait Foo { | ||
2090 | type Item; | ||
2091 | fn get(self) -> Self::Item {} | ||
2092 | } | ||
2093 | |||
2094 | struct Bar{} | ||
2095 | struct S{} | ||
2096 | |||
2097 | impl Foo for S{ | ||
2098 | type Item = Bar; | ||
2099 | } | ||
2100 | |||
2101 | fn test() -> impl Foo { | ||
2102 | S{} | ||
2103 | } | ||
2104 | |||
2105 | fn main() { | ||
2106 | let s<|>t = test().get(); | ||
2107 | } | ||
2108 | ", | ||
2109 | &["Foo::Item<impl Foo>"], | ||
2110 | ); | ||
2111 | assert_debug_snapshot!(actions, | ||
2112 | @r###" | ||
2113 | [ | ||
2114 | GoToType( | ||
2115 | [ | ||
2116 | HoverGotoTypeData { | ||
2117 | mod_path: "Foo", | ||
2118 | nav: NavigationTarget { | ||
2119 | file_id: FileId( | ||
2120 | 1, | ||
2121 | ), | ||
2122 | full_range: 0..62, | ||
2123 | name: "Foo", | ||
2124 | kind: TRAIT_DEF, | ||
2125 | focus_range: Some( | ||
2126 | 6..9, | ||
2127 | ), | ||
2128 | container_name: None, | ||
2129 | description: Some( | ||
2130 | "trait Foo", | ||
2131 | ), | ||
2132 | docs: None, | ||
2133 | }, | ||
2134 | }, | ||
2135 | ], | ||
2136 | ), | ||
2137 | ] | ||
2138 | "###); | ||
2139 | } | ||
2083 | } | 2140 | } |