Skip to content

rust-analyzer didn't return warning/hint diagnostics on textDocument/diagnostic #18709

@fannheyward

Description

@fannheyward
  1. rust-analyzer publishDiagnostics after open rust file, containing the warning/hint level diagnostics
  2. switch windows in editor, then the client requests textDocument/diagnostic for the same file, rust-analyzer returns empty diagnostics

Server trace logs, same logs with VSCode+rust-analzyer too, more logs fannheyward/coc-rust-analyzer#1276 (comment)

[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 (27e824f 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!");
}

Metadata

Metadata

Assignees

Labels

A-diagnosticsdiagnostics / error reportingA-lspLSP conformance issues and missing featuresC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions