Clippy warning randomly in vscodium and emacs

I have both emacs with rustic+lsp and vscodium flatpak with rust-analyzer, both set to use clippy as the checker. I have a rust project with a file that should always trigger clippy a clippy warning about comment markup (missing backticks). For some reason, when I visit this file in either emacs or vscodium, the clippy warnings don't always appear. I think if they appear in one of the editors, they appear in both - but am not sure. Also, at least in emacs, when I visit that file I can sometimes see the clippy warnings show up (underlines, inline warnings, and border arrows) an then later disappear during initialization. I am not altering the settings of emacs or vscodium between runs.

What could be doing this? Because the two IDEs are completely different internally, I strongly suspect it must be something about how the environment is prepared. But what?

It doesn't seem to be related to whether the crate is built or clean. I've been using nightly 1.86, and updating it - hoping the effect would disappear, but it has persisted for a while (weeks at least). I've also been keeping the vscodium extensions updated and doing package updates in emacs, hoping for the same thing.

At the moment, everything is in a state where the clippy warnings are being displayed, and I can't get them to not be. Of course that's happening when decide to submit this to the forum.

It might be something in the configuration rust-analyzer (the engine powering Rust support) is using to invoke Clippy.

The really weird case is when, using emacs, I see that the clippy warnings appear and then disappear all during initialization when visiting that file. That suggests maybe a race condition between two things rust-analyzer might be invoking?

does the error show up when you save the file?

rust-analyzer can do certain high level type checking, but it's limited and not enabled by default; most of the diagnostics come from the cargo check integration (can be configured to run clippy), which is only triggered when the file is saved, not on the fly.

in theory, you can configure your editor to run the check command on every keystroke, but you'll have very poor performance.

It is, actually (although arguably the most useful diagnostics, type errors and borrowck errors, are either experimental or non-existent).

1 Like

Regardless of how I have it configured, shouldn't it do whatever behavior it is configured for consistently? It's not.

I have it configured to show pedantic clippy warnings by having #![warn(clippy::pedantic)] in main.rs for this crate. That works, just not all of the time. It's the "not all of the time" part that is the problem. There have been times when I start up one of the IDEs and immediately visit the file that should have the clippy warnings about missing backticks - and it doesn't show them after completing initialization (although sometimes it shows the warning during emacs initialization, and then they disappear by the time initialization completes). Other times, doing the same thing, it does show the warnings.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.