bazelbuild / bazelbuild/rules_rust

Support per-crate `clippy.toml` via `lint_config`

Open
#4,113 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.