bazelbuild / bazelbuild/rules_rust
Support per-crate `clippy.toml` via `lint_config`
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
**Note**: I'm willing to write the PR for this feature, just posting an issue to get maintainer feedback first
## Problem
The clippy aspect currently uses a single global `clippy.toml` for the entire workspace. There is no way for individual crates to provide their own clippy configuration file.
This matters for lints like `disallowed-types`, `too-many-arguments-threshold`, `type-complexity-threshold`, etc. that require `clippy.toml` for their configuration. A workspace with many crates often needs different thresholds or disallowed-type lists per crate, but today the only option is a single workspace-wide config.
## Root cause
The clippy aspect hardcodes `CLIPPY_CONF_DIR` from a single private attribute:
[`rust/private/clippy.bzl` L281-285](https://github.com/bazelbuild/rules_rust/blob/0.66.0/rust/private/clippy.bzl#L281-L285):
```python
"_config": attr.label(
doc = "The `clippy.toml` file used for configuration",
allow_single_file = True,
default = Label("//rust/settings:clippy.toml"),
),
```
## Proposed solution
Extend the existing `lint_config` / `LintsInfo` mechanism to support a per-target clippy config file. This is the natural place since `lint_config` already provides per-target clippy flags.
Contributor guide
Assessment
This issue has not been assessed yet.