aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvsrs <[email protected]>2020-06-10 20:58:25 +0100
committervsrs <[email protected]>2020-06-18 08:15:43 +0100
commitd4e75312ba64c2541e0d97b9ad8d6e2a735882a4 (patch)
tree96a2e521edd381a574876cb6b0d90aebe381ecf7
parent283ec13fc06dda7ec4d22955e2d2eb96aaff95fd (diff)
Add associated type test.
-rw-r--r--.vscode/launch.json8
-rw-r--r--Cargo.toml2
-rw-r--r--crates/ra_ide/src/hover.rs57
3 files changed, 65 insertions, 2 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 8ca27d878..7a2c033cb 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -120,6 +120,12 @@
120 "sourceMaps": true, 120 "sourceMaps": true,
121 "outFiles": [ "${workspaceFolder}/editors/code/out/tests/unit/**/*.js" ], 121 "outFiles": [ "${workspaceFolder}/editors/code/out/tests/unit/**/*.js" ],
122 "preLaunchTask": "Pretest" 122 "preLaunchTask": "Pretest"
123 } 123 },
124 {
125 "name": "(Windows) Attach",
126 "type": "cppvsdbg",
127 "request": "attach",
128 "processId": "${command:pickProcess}"
129 }
124 ] 130 ]
125} 131}
diff --git a/Cargo.toml b/Cargo.toml
index 5278b5a16..a5f68f7fe 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,7 +4,7 @@ members = [ "crates/*", "xtask/" ]
4[profile.dev] 4[profile.dev]
5# disabling debug info speeds up builds a bunch, 5# disabling debug info speeds up builds a bunch,
6# and we don't rely on it for debugging that much. 6# and we don't rely on it for debugging that much.
7debug = 0 7debug = 2
8 8
9[profile.release] 9[profile.release]
10incremental = true 10incremental = true
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}