Stream: t-compiler/rust-analyzer

Topic: missing diagnostics w/ nvim-lsp after bumping dependency

Jimmy C (Apr 24 2021 at 18:20, on Zulip):

hey folks,

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:

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, 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


Lukas Wirth (Apr 24 2021 at 18:22, on Zulip):

Does everything else work fine, like completions and assists?

Jimmy C (Apr 24 2021 at 18:30, on Zulip):

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

Jimmy C (May 03 2021 at 23:25, on Zulip):

So I've been digging a bit, and I noticed that I am getting no AddDiagnostics messages being seen by (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 handle_events?

matklad (May 04 2021 at 12:08, on Zulip):

@Jimmy C see the flycheck module, it emits cargo check diagnosticsz

Jimmy C (May 05 2021 at 00:04, on Zulip):

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

Last update: Jul 26 2021 at 13:15UTC