Whenever I update my code I see cargo check or cargo clippy check several external crates. Now that I've set clippy into sadistic mode, VSStudio reports 9k+ Problems. 99 % (rough estimate) are not my code but crates like log, core, and lots of others.
When running check or clippy using the command line everything is as expected.
How can I configure VSCode or rust-analyzer to just check the current project or those shown in the workspace but not external references?
So you're experiencing the same?
I've been reading through the settings over and over again but didn't find a suitable option.
Will try the workaround you provided, soon.
Yes, any time I open a workspace that has a lot of dependencies (Substrate projects for instance) it can take upward of 30 minutes to check all of the dependencies, which is quite painful.
This is not a valid command and will effectively disable check-on-save functionality, which you can also achieve by setting "rust-analyzer.checkOnSave.enable": false.
Shouldn't command be check or clippy only? Are you sure it successfully re-runs on save? allTargets is set to true for me. I'll give it a try but I'd like to see the implied --lib --bins --tests --benches --examples to be checked as well.
rust-analyzer.checkOnSave.overrideCommand overrides the effect of checkOnSave.command, checkOnSave.features, checkOnSave.allTargets and checkOnSave.target, so they don't matter. Otherwise, setting checkOnSave.command to "cargo check" would indeed make it not work at all, because it should be just the cargo command like check or clippy.
@fyl2xp1 as to your original problem: rust-analyzer just runs cargo check (with various parameters) in your workspace, which wouldn't report errors for the standard library. The only way I can imagine getting errors from the standard library would be if you opened the standard library source (maybe by jumping to a definition) and VS considers it a separate workspace and runs rust-analyzer there. Unless running cargo clippy in your workspace also produces those errors.
"Jump so source" is a good hint, thanks! I'll try to reproduce if with a smaller project, trying to understand what rust-analyzer is doing to which source. Currently I have opened the root dir of several cargo workspaces and projects. That might be unexpected to the current implementation.
This feature is used heavily by Cargo; it will pass --cap-lints allow when compiling your dependencies, so that if they have any warnings, they do not pollute the output of your build.
Oookay. I think all problems reported within external crates are from macro's therein. rust-analyzer seems validate those expanded macros and attributes them to my code.
I don't know if this is on purpose.
I'll align my code to clippy first to see if there are any unexpected reports left.