Compiler/clippy keeps reporting on fixed issues

I encountered something yesterday that I have written about previously.

I had bacon running with a clippy-all target and it was warning about a bunch of unused variables, with suggestions that I should add a _ to silence the warning. I did so for a few of them and saved, and then bacon refreshed, but the entries were still showing, but with the new names. I.e. before it was saying that foo and bar where unused. I renamed them to _foo and _bar and after bacon had re-run clippy it reported the same warnings, but this time said that _foo and _bar were unused and that I could prefix them with _ to get rid of the warning(!).

I stopped bacon and ran cargo clippy manually, but it produced the same results.

Last time this happened I wrote that I would archive the target directory so it could be inspected. Stupidly, I forgot this and instead ran cargo clean, because I had some vague memory that this fixed the problem. And indeed it did, but then I remembered that I shouldn't have done that..

I'm curious about what manner of state is saved in the target directory that could cause this.

This weird state seems to be exceptionally rare, but I've seen it at least twice that I'm 100% certain of. I'm pretty sure I've seen the same problem, expressed in a different way, but I tend to quick-fire cargo clean when I just need to continue working.

Just throwing it out there that sometimes if the warnings/errors don't seem to be keeping up with your changes, run cargo clean and see it it makes it better. Or better yet, archive the target directory and then run cargo clean.

1 Like

This sounds related to a problem I had with incremental building recently. My problem showed up as incorrect code being generated in asm! blocks but turned out to be about handling temporary files and incremental building. You can read about it here: Instructions missing from naked_asm blocks. · Issue #139407 · rust-lang/rust · GitHub

This has been fixed in nightly releases a few days ago. Perhaps you could try that.