rust-analyzer: Rust-Analyzer with Clippy enabled doesn't highlight errors in Cargo Workspaces with many empty crates
When working in a Cargo Workspace with many crates (>=6), most of which are still empty, I noticed that errors were not displayed at all in the crate I was working on when using Clippy as the checkOnSave command. The same does not happen when using Check instead of Clippy.
I expect that part of the reason for this is that Clippy errors out on the it_works testcase in the default new crate template, since it contains assert_eq!(2 + 2, 4), which triggers a default-deny Clippy lint.
However, what was unexpected is that errors as simple as let x = y; (with no prior definition of y) are not recognized in the non-empty crates when too many crates are still “defaulted”.
Example project tree:
.
├── Cargo.toml
├── Cargo.lock
├── bug (depends on dep1)
│ ├── Cargo.toml
│ └── src
│ └── lib.rs (trivial `let x = y;` error that is not detected)
├── dep1 (depends on dep2)
│ ├── Cargo.toml
│ └── src
│ └── lib.rs (default content)
├── dep2
│ ├── Cargo.toml
│ └── src
│ └── lib.rs (default content)
├── nop1
│ ├── Cargo.toml
│ └── src
│ └── lib.rs (default content)
├── nop2
│ ├── Cargo.toml
│ └── src
│ └── lib.rs (default content)
└── nop3
├── Cargo.toml
└── src
└── lib.rs (default content)
Contents of bug/src/lib.rs:
fn wut() {
let x = y;
}
Contents of all other lib.rs files:
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
Test Workspace: workspace.tar.gz
Notes on Reproducing:
- set
rust-analyzer.checkOnSave.commandtoclippy - run
cargo cleanin the workspace - restart VS Code (for some reason not restarting VS Code after changing from
checktoclippymakes it remember that the error exists)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (9 by maintainers)
Let’s close this, but feel free to link to the
clippyissue and/or reopen if necessary.right! thanks, I’ll look into it!