Avoid running clippy on rust analyzer
When using the suggested approach of enabling clippy on build this also ends up being checked when running the rust-analyzer tool. This ends up being pretty tedious during development since it means that the code now has to both compile and pass clippy checks, but I really just want to update the rust project file.
Is there an existing mechanism to disable clippy when using the rust analyzer tool? If not, would it be reasonable to make it possible to pass additional args to the rust analyzer tool so that I gate things with a --config?
Which suggested approach to use clippy do you use? This one?
$ bazel build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect --output_groups=clippy_checks //hello_lib:all
I presume you added this to your .bazelrc as something like:
build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect --output_groups=clippy_checks
If I wanted to disable clippy for rust analyzer runs in this scenario, I'd add this to the .bazelrc:
build:noclippy --output_groups=-clippy_checks
(https://docs.bazel.build/versions/main/command-line-reference.html#flag--output_groups). Then you should be able to run:
bazel run --config=noclippy @rules_rust//tools/rust_analyzer:gen_rust_project //my:project
Am I making any sense?
Yep this makes sense! The main thing I wasn't aware of here is that the parameter passed to run would propagate to the underlying bazel build command that gen_rust_project invokes.
Your suggestion does indeed remove the clippy check, though it seems like enabling the aspect by default still causes the Rust targets to be compiled, so it still fails to generate the rust-analyzer project file if there is a syntax error. Is there a way to also disable this?
Would be great to have this stuff included in the docs, so happy to do a docs PR to help the next person running into this
Scratch what I said about it working, seems like the problem is still there. It seems like the --config noclippy is not propagated to gen_rust_project's call to build rust_analyzer_aspect.
If I add build --config noclippy to my bazelrc it does disable the rustc + clippy invocation, so it seems like the issue is just about being able to propagate the option between the bazel run invocation and the underlying call to bazel build.
I tried to add --config noclippy at the end of the gen_rust_project command line (thinking that it might just pass through the arguments to bazel), but this seems to fail when it tries to use this list of targets to construct the aquery command later on.