aspect-build / aspect-build/rules_lint
[FR]: lint_clippy_aspect could consume Cargo [lints] / rules_rust lint_config
- Dominant language
- Starlark
- Stars
- 154
- Forks
- 125
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 20
Description
## Problem
`lint_clippy_aspect` accepts a `clippy_flags` list for setting lint levels (e.g. `-Dwarnings`, `-Dclippy::disallowed_methods`, `-Aclippy::new_without_default`).
These flags duplicate configuration that, in modern Rust toolchains, lives in `Cargo.toml`'s `[lints.clippy]` / `[workspace.lints.clippy]` section (stable since Rust 1.74 / Cargo 0.75).
In a hybrid Bazel + cargo workspace this means lint levels must be maintained in two places:
- `Cargo.toml [workspace.lints.clippy]` — what cargo / rust-analyzer / IDE clippy invocations see
- `linters.bzl` `clippy_flags = [...]` — what `lint_clippy_aspect` applies in Bazel
Drift between the two is silent: a lint allowed in one is denied in the other, and contributors only discover it when CI disagrees with their editor.
## `bazelbuild/rules_rust` natively supports the `[lints]` table from Cargo.toml.
```starlark
load("@rules_rust//cargo:defs.bzl", "extract_cargo_lints")
extract_cargo_lints(name = "my_lints", manifest = "Cargo.toml")
rust_library(
name = "my_lib",
srcs = ["src/lib.rs"],
lint_config = ":my_lints", # plumbs lint levels into rustc AND rust_clippy
)
```
`rust_clippy` (the rules_rust native rule) honors `lint_config` via `deps`. But `lint_clippy_aspect` (this repo) is a separate codepath and ignores it.
## Proposal
`lint_clippy_aspect` could pick up clippy lint levels from one of:
1. The aspected target's `lint_config` attribute (if it's a `rust_library` / `rust_binary` / `rust_test` with one set), and merge those flags with `clippy_flags`.
2. Or accept an `extract_cargo_lints` target directly as an aspect parameter, e.g. `cargo_lints = "//:workspace_lints"`, and apply it to every aspected Rust target.
Contributor guide
Research direction
Start by tracing lint_clippy_aspect and linters.bzl, then compare their handling with rules_rust's extract_cargo_lints and the lint_config attribute described in the issue. Determine which proposed configuration source fits the aspect model and how clippy_flags should interact with it. Done means Cargo [lints] settings can reach lint_clippy_aspect without maintaining duplicate lint levels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100