rust-lang / rust-lang/rust-analyzer
rust-analyzer didn't return warning/hint diagnostics on `textDocument/diagnostic`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
- rust-analyzer
publishDiagnosticsafter open rust file, containing the warning/hint level diagnostics - switch windows in editor, then the client requests
textDocument/diagnosticfor the same file, rust-analyzer returns empty diagnostics
Server trace logs, same logs with VSCode+rust-analzyer too, more logs https://github.com/fannheyward/coc-rust-analyzer/issues/1276#issuecomment-2462451351
[Trace - 14:56:20] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///Users/fannheyward/src/hello-rust/src/main.rs",
"diagnostics": [
{
"range": {...},
"severity": 2,
"code": "unused_imports",
"source": "rustc",
"message": "unused import: `std::env`\n`#[warn(unused_imports)]` on by default",
"relatedInformation": [...],
"tags": [1],
"data": {...}
},
{
"range": {...}
},
"severity": 4,
"code": "unused_imports",
"source": "rustc",
"message": "remove the whole `use` item",
"relatedInformation": [...]
}
],
"version": 1
}
...
[Trace - 14:57:31] Sending request 'textDocument/diagnostic - (18)'.
Params: {
"textDocument": {
"uri": "file:///Users/fannheyward/src/hello-rust/src/main.rs"
}
}
[Trace - 14:57:31] Received response 'textDocument/diagnostic - (18)' in 2ms.
Result: {
"kind": "full",
"items": []
}
rust-analyzer version: rust-analyzer 0.0.0 (27e824fad4 2024-12-15)
rustc version: rustc 1.83.0 (90b35a623 2024-11-26)
editor or extension: nvim + coc.nvim
code snippet to reproduce:
use std::env;
fn main() {
println!("Hello, world!");
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided Rust snippet and compare the publishDiagnostics trace with the textDocument/diagnostic response. Trace the server's diagnostic handling for warning and hint levels; done means the pull request returns the same warning and hint diagnostics instead of an empty items array after the client requests diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100