Skip to content

Conversation

@Muscraft
Copy link
Member

@Muscraft Muscraft commented Jan 4, 2026

This PR overhauls how lint groups work within Cargo, aligning them with how Clippy handles groups1, all while simplifying the implementation (in my opinion). The first commit adds eight lint groups that mirror Clippy's groups, while the subsequent commits work towards matching how Clippy handles groups, as well as improving how lint groups work within the existing linting system.

The major changes:

  • Lints now have a primary group, instead of a set of groups they belong to
  • Lints now inherit their default level from their primary group
    • This vastly improved the code for getting the level for a lint
    • Surprisingly, I found this change helped with deciding what group a lint should belong to

Note: Dynamic groups (i.e., all or warnings) aren't supported at this time
Note: There are open questions about which Level we should default the groups to. This PR does not attempt to answer those questions and simply uses Clippy's default levels for convenience.

Footnotes

  1. Clippy uses groups and categories interchangeably

@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 4, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 4, 2026

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Comment on lines 7 to 16
| Group | Description | Default level |
|----------------------|------------------------------------------------------------------|---------------|
| `cargo::complexity` | code that does something simple but in a complex way | warn |
| `cargo::correctness` | code that is outright wrong or useless | deny |
| `cargo::nursery` | new lints that are still under development | allow |
| `cargo::pedantic` | lints which are rather strict or have occasional false positives | allow |
| `cargo::perf` | code that can be written to run faster | warn |
| `cargo::restriction` | lints which prevent the use of language and library features | allow |
| `cargo::style` | code that should be written in a more idiomatic way | warn |
| `cargo::suspicious` | code that is most likely wrong or useless | warn |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It is nice we have a similar set of groups as clippy's! Easy for users to learn.
  • It might be a bit confusing since we don't have that many lints right now. And also once we stabilize one group its hard to revert back.

Anyway, this is fine when being as a nightly feature. we need to revisit when stabilization.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Dynamic groups (i.e., all or warnings) aren't supported at this time

I am a bit unsure whether we want to have cargo::all. clippy::all is not a real "all" (it includes only all lints that are on by default). So sometimes the name is a bit surprising. Anyhow, this is not a blocker for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we should not mirror clippy::all

@Muscraft Muscraft force-pushed the clippy-like-lint-groups branch from 5e8bd81 to 11324cd Compare January 6, 2026 22:31
@rustbot

This comment has been minimized.

@Muscraft Muscraft force-pushed the clippy-like-lint-groups branch from 11324cd to 085d9d1 Compare January 8, 2026 03:51
@rustbot
Copy link
Collaborator

rustbot commented Jan 8, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@epage epage added this pull request to the merge queue Jan 8, 2026
Merged via the queue into rust-lang:master with commit c9895a1 Jan 8, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2026
@Muscraft Muscraft deleted the clippy-like-lint-groups branch January 8, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-documenting-cargo-itself Area: Cargo's documentation A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants