rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.28k stars 1.61k forks source link

rust-analyzer seems to cache old warnings #18168

Closed BenD0G closed 1 month ago

BenD0G commented 1 month ago

rust-analyzer version: 0.3.2112-standalone (94b526fc8 2024-09-15)

rustc version: rustc 1.81.0 (eeb90cda1 2024-09-04)

editor or extension: VSCode - extension version v0.3.2112

relevant settings: nothing unusual I think

Problem

rust-analyzer warns about "unused variable: order_statuses_clone" on a particular line of this file. There used to be a variable by that name, but I got rid of it a while ago. As you can see from the image, it is currently highlighting a comment for this warning. Image

If I move code around, it will highlight a different line with the same warning: Image

I have tried:

  1. Reloading VSCode window
  2. Restarting remote machine
  3. Uninstalling and re-installing rust-analyzer extension.

Sorry I can't provide a minimal reproduction - this seems particular to something that's been cached on my machine. Any help would be greatly appreciated!

ChayimFriedman2 commented 1 month ago

These are diagnostics from cargo check, which can take a while to compute. After they are recomputed this should be fixed.

BenD0G commented 1 month ago

Sorry @ChayimFriedman2 , thanks for the response but I'm afraid I don't understand - this warning is still here after several days, many hours spent editing the code and several restarts.

What exactly are these diagnostics from cargo check? Any way I can kill that process or clear their cache?

ChayimFriedman2 commented 1 month ago

It may be that the target folder is corrupted (it happens from time to time). This is cargo's cache. Delete it.

BenD0G commented 1 month ago

Ah that did it, thank you! Sorry, hadn't realized that rust-analyzer used the target folder.

Thanks so much for responding so quickly!