Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit bd3ddba

Browse files
committed
tests: Add a test attempt for rust-lang/rust#57462.
This unfortunately passes regardless right now because of the racer fallback. And without the racer fallback we're not able to go to the definition of either Foo or Foo::new. The test is probably worth having regardless.
1 parent ea7a0c3 commit bd3ddba

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

tests/tests.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,3 +1364,75 @@ fn cmd_lens_run() {
13641364

13651365
rls.shutdown(rls_timeout());
13661366
}
1367+
1368+
#[test]
1369+
fn test_def_static_method_call() {
1370+
let p = project("simple_workspace")
1371+
.file("Cargo.toml", &basic_bin_manifest("bar"))
1372+
.file(
1373+
"src/main.rs",
1374+
r#"
1375+
struct Foo {
1376+
}
1377+
1378+
impl Foo {
1379+
fn new() {
1380+
}
1381+
}
1382+
1383+
fn main() {
1384+
Foo::new();
1385+
}
1386+
"#,
1387+
)
1388+
.build();
1389+
1390+
let root_path = p.root();
1391+
let mut rls = p.spawn_rls();
1392+
1393+
rls.request(
1394+
0,
1395+
"initialize",
1396+
Some(json!({
1397+
"rootPath": root_path,
1398+
"capabilities": {}
1399+
})),
1400+
)
1401+
.unwrap();
1402+
1403+
let request_id = 1;
1404+
1405+
rls.request(
1406+
request_id,
1407+
"textDocument/definition",
1408+
Some(json!({
1409+
"position": {
1410+
"character": 20, // Foo
1411+
"line": 10
1412+
},
1413+
"textDocument": {
1414+
"uri": format!("file://{}/src/main.rs", root_path.display()),
1415+
"version": 1
1416+
}
1417+
})),
1418+
)
1419+
.unwrap();
1420+
1421+
let json = rls.wait_until_json_id(request_id, rls_timeout());
1422+
let result = json["result"].as_array().unwrap();
1423+
assert_eq!(
1424+
result[0]["range"],
1425+
json!({
1426+
"start": {
1427+
"line": 1,
1428+
"character": 23,
1429+
},
1430+
"end": {
1431+
"line": 1,
1432+
"character": 23,
1433+
}
1434+
})
1435+
);
1436+
1437+
rls.shutdown(rls_timeout());
1438+
}

0 commit comments

Comments
 (0)