Closed
Description
In rls/vscode, if you right-click on an enum name, it shows you all its uses. If you right click on a name of one of its variants, there are no uses shown despite there being some.
This doesn't seem to be fault of rls. Apparently the save-analysis info fed to rls is wrong. See the output presented here. In the defs table, the Foo
enum has index 12 while the Foo::Bar
variant has index 13. In the refs table, the correct index 12 is used to reference the enum, but the enum variant is referenced with index 14 which doesn't even exist in the defs table.
$ cargo new save-analysis-demo
$ cd save-analysis-demo
$ cat src/main.rs
enum Foo {
Bar,
}
fn main() {
let v = Foo::Bar;
}
$ RUSTFLAGS="-Z save-analysis" cargo +nightly check
$ cat target/debug/deps/save-analysis/save_analysis_demo-*.json | jq '.defs'
[...]
{
"kind": "TupleVariant",
"id": {
"krate": 0,
"index": 13
},
"span": {
"file_name": "src/main.rs",
"byte_start": 12,
"byte_end": 15,
"line_start": 2,
"line_end": 2,
"column_start": 2,
"column_end": 5
},
"name": "Bar",
"qualname": "::Foo::Bar",
"value": "Foo::Bar",
"parent": {
"krate": 0,
"index": 12
},
"children": [],
"decl_id": null,
"docs": "",
"sig": null,
"attributes": []
},
{
"kind": "Enum",
"id": {
"krate": 0,
"index": 12
},
"span": {
"file_name": "src/main.rs",
"byte_start": 5,
"byte_end": 8,
"line_start": 1,
"line_end": 1,
"column_start": 6,
"column_end": 9
},
"name": "Foo",
"qualname": "::Foo",
"value": "Foo::{Bar}",
"parent": null,
"children": [
{
"krate": 0,
"index": 13
}
],
"decl_id": null,
"docs": "",
"sig": null,
"attributes": []
},
[...]
$ cat target/debug/deps/save-analysis/save_analysis_demo-*.json | jq '.refs'
[
{
"kind": "Variable",
"span": {
"file_name": "src/main.rs",
"byte_start": 45,
"byte_end": 48,
"line_start": 5,
"line_end": 5,
"column_start": 15,
"column_end": 18
},
"ref_id": {
"krate": 0,
"index": 14
}
},
{
"kind": "Type",
"span": {
"file_name": "src/main.rs",
"byte_start": 40,
"byte_end": 43,
"line_start": 5,
"line_end": 5,
"column_start": 10,
"column_end": 13
},
"ref_id": {
"krate": 0,
"index": 12
}
}
]