Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Diagnostics not clearing after fix and save #17300

Closed
tomjw64 opened this issue May 27, 2024 · 21 comments · Fixed by #18740
Closed

Regression: Diagnostics not clearing after fix and save #17300

tomjw64 opened this issue May 27, 2024 · 21 comments · Fixed by #18740
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@tomjw64
Copy link

tomjw64 commented May 27, 2024

This seems to be a regression from the last released version of the rust-analyzer extension. When the file is saved, diagnostics will appear, but then if problem is fixed and saved again, the diagnostics will remain. The extension must be restarted to clear diagnostics.

This only occurs on the newest version of rust-analyzer. When testing on 0.3.1958, this issue does not occur. I suspect it has something to do with this PR.

rust-analyzer version: 2024-05-27

rustc version: rustc 1.80.0-nightly (bdbbb6c6a 2024-05-26)

editor or extension: VSCode, extension version 0.3.1975

example video of issue:
https://github.com/rust-lang/rust-analyzer/assets/1285308/9dee3798-cddd-4e76-9a11-e49cfd510cca

@kalkronline
Copy link

Was just about to file this. For me, this is only happening over SSH.

@mladedav
Copy link
Contributor

Looking at this, what I just noticed could cause this is if the next flycheck gets cancelled, the diagnostics are not cleared. But I don't think that should happen too often so probably not the issue?

I'll try to look if I can replicate it (maybe with ssh), but does it happen for you with all projects? Or just some specific ones?

@jlvihv
Copy link

jlvihv commented May 28, 2024

I also encountered this issue. The problem started after upgrading to the latest version of rust-analyzer yesterday afternoon. I encountered this issue on both VSCode and Zed.

@jlvihv
Copy link

jlvihv commented May 28, 2024

Was just about to file this. For me, this is only happening over SSH.

It might be because your local and remote environments are using different versions of the rust-analyzer extension. Once you upgrade them to the latest version, you will encounter the same issue.

@liam-b
Copy link

liam-b commented May 28, 2024

I'm having the exact same issue on my local vscode. Errors don't seem to get cleared after fixing the code. (just to confirm, I downgraded to v0.3.1958 and all is well)

@Veykril
Copy link
Member

Veykril commented May 28, 2024

Right, I can tell the issue. If you have check on save diagnostics somewhere and the next check succeeds without emitting any again we won't clear them as the logic only does when a diagnostic was received 🤦

@Veykril Veykril added the Broken Window Bugs / technical debt to be addressed immediately label May 28, 2024
@mladedav
Copy link
Contributor

@Veykril It should get cleared when we receive DidFinish?

@Veykril
Copy link
Member

Veykril commented May 28, 2024

Right, it's in fact the other way around, we don't clear it if a succeeding check still has diagnostics (that is we accumulate), which is what one can observein the linked example video (the test function is unused and hence always emits a warning)

@mladedav
Copy link
Contributor

If a check has diagnostics, the old ones should be cleared when the first AddDiagnostic is received so in that example when the unused function diagnostics is received, all other should disappear.

The state is tracked for flychecks globally though, so if there are invocations per workspace, that would be broken as the first finishing flycheck would clear its (potentially empty) diagnostics and the other flychecks would accumulate.

@ghost
Copy link

ghost commented May 29, 2024

I also encountered this issue. The problem started after upgrading to the latest version of rust-analyzer yesterday afternoon. I encountered this issue on both VSCode and Zed.

temporary fix for zed:
set rust-analyzer binary in your settings.json to the rustup rust-analzyer as follow:
"lsp": { "rust-analyzer": { "binary": { "path": "/Users/[ur_user_name]/.cargo/bin/rust-analyzer", "arguments": [] } } }
then switch your rustup to a stable version (e.g. 1.78.0) and restart zed editor

@mladedav
Copy link
Contributor

set rust-analyzer binary in your settings.json to the rustup rust-analzyer

Note that rust-analyzer is not installed by rustup when you use the default profile, you need to add the component manually if you haven't yet.

bors added a commit that referenced this issue Jun 1, 2024
fix diagnostics clearing when flychecks run per-workspace

This might be causing #17300 or it's a different bug with the same functionality.

I wonder if the decision to clear diagnostics should stay in the main loop or maybe the flycheck itself should track it and tell the mainloop?

I have used a hash map but we could just as well use a vector since the IDs are `usizes` in some given range starting at 0. It would be probably faster but this just felt a bit cleaner and it allows us to change the ID to newtype later and we can just use a hasher that returns the underlying integer.
@lnicola
Copy link
Member

lnicola commented Jun 2, 2024

Fixed in #17302.

@lnicola lnicola closed this as completed Jun 2, 2024
@Possseidon
Copy link

This is suddenly happening to me again in the pre-release version 0.4.2226-standalone (fda8b48bd8 2024-12-21). When I switch to the stable release one errors are cleared just fine. I also tried it in two different workspaces, so it seems it's not just my workspace causing issues.

@Possseidon
Copy link

Looking at recently merged PRs, it looks like #18729 might be causing it.

@Veykril
Copy link
Member

Veykril commented Dec 22, 2024

I think I've observed it as well earlier. Will investigate a bit and otherwise revert for now.

@Flourish38
Copy link

I am experiencing this behavior in release version 0.3.2247 and 0.3.2249, but not in 0.3.2237.

@pdeva
Copy link

pdeva commented Jan 6, 2025

i am experiencing this too. using 0.3.2249 in vscode

@puleo1
Copy link

puleo1 commented Jan 7, 2025

also experiencing this on 0.3.2249

@exokernel
Copy link

Also running into this on 0.3.2249

@ChayimFriedman2
Copy link
Contributor

@Flourish38 @pdeva @puleo1 @exokernel See #18854.

@767829413
Copy link

I used the pre-release version of rust-analyzer and it's as simple as that. 0.4.2250

@rust-lang rust-lang locked as resolved and limited conversation to collaborators Jan 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.