Skip to content

[WIP] Support lint level configuration in clippy.toml - #15155

Draft
odysa wants to merge 4 commits into
rust-lang:masterfrom
odysa:feat/more-config-path
Draft

[WIP] Support lint level configuration in clippy.toml#15155
odysa wants to merge 4 commits into
rust-lang:masterfrom
odysa:feat/more-config-path

Conversation

@odysa

@odysa odysa commented Jun 27, 2025

Copy link
Copy Markdown
Contributor

changelog: Add support for lint level configuration in clippy.toml

Fixes #15128

Add support for configuring lint levels in clippy.toml using the same format as Cargo.toml. This allows users to move lint configurations from Cargo.toml to clippy.toml to keep dependency management and linting separate.

Example

clippy.toml:

[lints.clippy]
needless_return = "allow"
single_match = { level = "warn", priority = 5 }

[lints.rust]
dead_code = "allow"

@odysa odysa changed the title Support lint level configuration in clippy.toml [WIP] Support lint level configuration in clippy.toml Jun 27, 2025
@odysa
odysa force-pushed the feat/more-config-path branch from df97a9a to aa7b2a2 Compare August 9, 2025 04:54
@git-staus

Copy link
Copy Markdown

I wanted to mention that the following note in the README probably should be updated/removed as part of this PR as well:

rust-clippy/README.md

Lines 229 to 233 in 49e2f37

> **Note**
>
> `clippy.toml` or `.clippy.toml` cannot be used to allow/deny lints.

Additionally, the "Clippy book" confusingly seems to contain very similar information to the README. Perhaps a paragraph on this (I guess also mentioning both a ~/.cargo/clippy.toml or a project-local .clippy.toml) should also be added to the "Allowing/Denying Lints" section there as well.

I am not sure to what standards changes to the documentation should conform; I just thought I'd point it out.

@rustbot

This comment has been minimized.

odysa added 2 commits April 9, 2026 09:23
- Remove outdated note in README.md that clippy.toml cannot be used to
  allow/deny lints (this was the old behavior before this PR)
- Add a `[lints]` section example in README.md showing the new syntax
- Add a new "Lints Section in clippy.toml" subsection in
  book/src/configuration.md documenting the supported format and fields
@odysa
odysa force-pushed the feat/more-config-path branch from aa7b2a2 to 699ceaa Compare April 9, 2026 09:25
odysa added 2 commits April 9, 2026 10:22
Mark find_conf_file_from, read_clippy_toml_overrides_from, and
apply_merged_clippy_lints_from_path with #[cfg(test)] since they are
only used within the test module. The non-path variant
apply_merged_clippy_lints is the one integrated into the driver and
remains unconditionally compiled.
@rustbot

rustbot commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #17369) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow all lints to be configured via clippy.toml

3 participants