Skip to content

Commit d4e7531

Browse files
committed
Add associated type test.
1 parent 283ec13 commit d4e7531

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

.vscode/launch.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@
120120
"sourceMaps": true,
121121
"outFiles": [ "${workspaceFolder}/editors/code/out/tests/unit/**/*.js" ],
122122
"preLaunchTask": "Pretest"
123-
}
123+
},
124+
{
125+
"name": "(Windows) Attach",
126+
"type": "cppvsdbg",
127+
"request": "attach",
128+
"processId": "${command:pickProcess}"
129+
}
124130
]
125131
}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ members = [ "crates/*", "xtask/" ]
44
[profile.dev]
55
# disabling debug info speeds up builds a bunch,
66
# and we don't rely on it for debugging that much.
7-
debug = 0
7+
debug = 2
88

99
[profile.release]
1010
incremental = true

crates/ra_ide/src/hover.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,4 +2080,61 @@ fn func(foo: i32) { if true { <|>foo; }; }
20802080
]
20812081
"###);
20822082
}
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+
}
20832140
}

0 commit comments

Comments
 (0)