Run clippy on every Bazel build via the rules_rust aspect - #461
Draft
tinder-maxwellelliott wants to merge 1 commit into
Draft
Run clippy on every Bazel build via the rules_rust aspect#461tinder-maxwellelliott wants to merge 1 commit into
tinder-maxwellelliott wants to merge 1 commit into
Conversation
Wire rust_clippy_aspect and the clippy_checks output group into .bazelrc's build command so first-party Rust crates are linted immediately on any bazel build/test/run/coverage invocation, instead of waiting for the cargo clippy pass in CI. The aspect only attaches to rules_rust targets, skips external crates, and denies warnings by default — the same bar as the existing cargo clippy -D warnings CI gate. Fix the needless_borrow lint in tools/coverage/src/enforce.rs that the aspect caught on its first run: tools/coverage is outside the Cargo workspace, so the cargo clippy CI pass never saw it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
.bazelrcnow applies@rules_rust//rust:defs.bzl%rust_clippy_aspect(plus theclippy_checksoutput group) on thebuildcommand, so everybazel build/test/run/coverageinvocation lints first-party Rust crates immediately.needless_borrowintools/coverage/src/enforce.rs.Why
Clippy previously only ran as a
cargo clippy --all-targets -- -D warningsstep in CI, so lint issues weren't caught during local Bazel development — and crates outside the Cargo workspace were never linted at all. Theenforce.rsfix in this PR is a live example:tools/coverageis Bazel-only, so the cargo pass never saw it.The aspect matches the existing CI bar: it denies warnings by default (
-Dwarnings), only attaches to rules_rust targets viarequired_providers, and skips external crate_universe crates. A target can opt out withtags = ["no-clippy"]. CI's Bazel jobs pick this up automatically through.bazelrc, so no workflow changes are needed. The cargo clippy CI step stays, since it covers things Bazel doesn't build (tests/e2e,build.rsvia cargo).Verification
bazel build //src:all //tools/coverage:allpasses with.clippy.okmarkers produced for all seven first-party crates (libs, bins, and test targets).clone_on_copywarning fails the build immediately (then reverted).//:license),bazel run --script_path //:bazel-diff-rust, andcquery— the pathsbazel-diff-example.shexercises — are unaffected.build --nobuild); everything else ran on the pinned 8.5.1.MODULE.bazel.lockstays clean under the pinned version.//tools/coverage:lcov_merger_testpasses after the lint fix.🤖 Generated with Claude Code