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

Open
#4,113 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
build-system

Research direction

Read rust/private/clippy.bzl around L281-L285, then trace the existing lint_config/LintsInfo mechanism that supplies per-target Clippy flags. The change is complete when individual crates or targets can provide their own clippy.toml while the existing workspace-wide configuration remains supported.

Written by the indexing model from the issue text.

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:

"_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.

Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.