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

Setting check.workspace to false still emits diagnostics from all members the first time they are seen #17126

Open
zjp-CN opened this issue Apr 23, 2024 · 4 comments
Labels
C-bug Category: bug

Comments

@zjp-CN
Copy link

zjp-CN commented Apr 23, 2024

rust-analyzer version: v0.3.1906

rustc version: rustc 1.79.0-nightly (1684a753d 2024-04-01)

editor or extension: I've tested this on VSCode, NeoVim, Helix.

relevant settings: check.workspace = false

code snippet to reproduce:

#16510 brings check.workspace setting, it works well except the first time RA starts.

The reproducing steps are:

  • make a workspace containing a member and the root crate: make some diagnostics in both
  • set check.workspace to false
  • open a file from one of the package, wait for RA starts, then you'll see diagnostics from both pkgs (=> this is the bug)
  • save the file, you'll finally see diagnostics from single pkg

Found in https://users.rust-lang.org/t/rust-analyzer-cargo-workspaces-and-members-in-helix-editor/110284/8

@zjp-CN zjp-CN added the C-bug Category: bug label Apr 23, 2024
@Veykril
Copy link
Member

Veykril commented Apr 23, 2024

That works as expected in that the initial check (as well as any check invoked when not in a rust file) will trigger a workspace check. I guess we could change the setting to try-state bool, true, startup, never/false if people find that confusing? Or maybe change just the default behavior to not do workspace checks at all if disabled I have no preference here. Might be better to just change now the default works instead

@zjp-CN
Copy link
Author

zjp-CN commented Apr 23, 2024

That works as expected in that the initial check (as well as any check invoked when not in a rust file) will trigger a workspace check.

Wait, does it mean cargo-check on workspace is run during initialization and other scenarios on purpose, so diagnostics throughout workspace are reported?
Tangential: I noticed a single "rust-analyzer.check.overrideCommand": "cargo check --message-format=json" setting acts the same as a single "rust-analyzer.check.workspace": false setting last night, but now I find overrideCommand still run check for all members... Would additional workspace check from RA be the reason?

Or maybe change just the default behavior to not do workspace checks at all if disabled I have no preference here.

I'm in favor of that. If check.workspace is set to false, the user surely want to mute diagnostics from other members deliberately. Any workspace diagnostic under the setting will be surprising... If they want the workspace diagnostics back, they will change the setting to true.

change the setting to try-state bool, true, startup, never/false

Well, keep things simple. Startup is redundant to me for the reason above... My two cents...

@lnicola
Copy link
Member

lnicola commented Apr 23, 2024

It's probably less obvious, but "rust-analyzer.check.workspace": false means that only the package(s) which include a saved file will be checked. So if you're not saving a file, there's no package to check.

@zjp-CN
Copy link
Author

zjp-CN commented Apr 23, 2024

"rust-analyzer.check.workspace": false means that only the package(s) which include a saved file will be checked

Might be another solution: document the behavior with no code changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants