rustc json diagnostics parsing error
rust-analyzer version: 0.3.2490-standalone
rustc version: 1.87.0
editor or extension: Helix / Neovim (any lsp client)
I am trying to get diagnostics to work on a project without cargo. Meson does support clippy output via clippy-driver, so I changed the check.overrideCommand, however, rust-analyzer fails with: ERROR synthetic syntax. Looking at the json output of cargo clippy and clippy-driver/rustc, they seem to be structured slightly differently:
json outputs
I can reproduce the issue with a simple main.rs containing an unused variable and setting check.overrideCommand to rustc src/main.rs --emit metadata --out-dir /tmp --error-format=json
The synthetic syntax error is not related. Is that the only error you see?
Yes that's the only thing that gets logged, and no diagnostics show up in the editor
So there is no problem?
The problem is that the output from rustc/clippy-driver doesn't show up as inline diagnostics in lsp clients, and it does when the json output comes from cargo check (default).
The difference in the structure does seem like something that will cause us to fail to parse it, although I'm not sure.
I've tested some more editors, the rustc output fails to show diagnostics for Helix, Neovim, and Zed. However it does seem to work for vscode. So maybe the json does get parsed correctly, but rust-analyzer outputs a message to the client that can only be properly understood by vscode. I don't know how to debug the client-server messages though.
There are extensions that allow you to see the LSP communication, at least to VSCode, I think.