I've been using rust-analyzer w/ the nvim-lsp for a little while, and its been pretty great. However a few days ago I bumped up a dependency on one of the crates i've been building I noticed that all diagnostics were not being omitted, even with the most egregious of mistakes! On other projects on my machine, diagnostics seem to be working. some examples below:
broken, on my little toy: https://asciinema.org/a/hNJ4Phu6APZTBciFB8wp4yHXo
I'd like to dig down a little and figure this out. has anyone done debug work w/ neovim-lsp and rust-analyzer and would have some tips on where to start?
I poked around git issues, but there doesnt seem to be an exact match for this (maybe https://github.com/rust-analyzer/rust-analyzer/issues/8622, but my project structure doesnt seem particularly exotic). If this behaviour is worth reporting as an issue on github I can be a little more precise with what i'm seeing there
fwiw, rust-analyzer version: rust-analyzer 2021-04-19-95-g07fb65abb
Does everything else work fine, like completions and assists?
yeah everything else (completetion, assists, inlay type hints, etc) is working swimmingly.
The one thing I forgot to mention is that diagnostics for derive macros are present, but diagnostics for "normal" code are all missing
So I've been digging a bit, and I noticed that I am getting no AddDiagnostics messages being seen by main_loop.rs:handle (full enum variant is flycheck::Message::AddDiagnostic). I have a recent version of rust-analyzer built w/ debug signals, so I'm willing to step through this further.Has anyone seen this before or could anyone point me to the interface that generally emits diagnostics to be consumed by
@Jimmy C see the
flycheck module, it emits
cargo check diagnosticsz
thanks a ton! turns out after finnicking a little bit with log messages, I got flycheck to spit out an error saying that
cargo check --workspace --message-format=json --manifest-path /path/to/my/project --all-targets --all-features was failing. When I reran this command locally, I saw it was failing with with "error: multiple packages link to native library
fontconfig, but a native library can be linked only once" .
Lo and behold, there was a neglected member of this project's workspace that was causing this command to fail. once I fixed that, I had "normal" diagnostics back up across my project :) thanks for the tips.
TL;DR: if you lose diagnostics suddenly, but the rest of rust-analyzer works, try running
cargo check --workspace --message-format=json --manifest-path /path/to/Cargo.toml --all-targets --all-features to see if anything fails. thanks for the tip @matklad