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
rust-bors bot added a commit to rust-lang/rust that referenced this pull request Jan 9, 2026
Update cargo submodule

27 commits in 94c368ad2b9db0f0da5bdd8421cea13786ce4412..8c133afcd5e0d69932fe11f5907683723f8d361d
2025-12-26 19:39:15 +0000 to 2026-01-09 03:50:15 +0000
- Isolate build script metadata progation between std and non-std crates (rust-lang/cargo#16489)
- Add Clippy like lint groups (rust-lang/cargo#16464)
- feat: in-memory only `Manifest` (rust-lang/cargo#16409)
- Fixed incorrect version comparision during build script dependency selection (rust-lang/cargo#16486)
- refactor: new type for unit index (rust-lang/cargo#16485)
- feat(test): Make CARGO_BIN_EXE_ available at runtime  (rust-lang/cargo#16421)
- fix(package): detect dirty files when run from workspace member (rust-lang/cargo#16479)
- fix(timing)!: remove `--timings=<FMT>` optional format values (rust-lang/cargo#16420)
- docs(unstable): expand docs for `-Zbuild-analysis` (rust-lang/cargo#16476)
- test: add `-Zunstable-options` with custom targets (rust-lang/cargo#16467)
- feat(report): add cargo report rebuilds  (rust-lang/cargo#16456)
- feat(test-support): Use test name for dir when running tests (rust-lang/cargo#16121)
- refactor: Migrate some cases to expect/reason (rust-lang/cargo#16461)
- docs(build-script): clarify OUT_DIR is not cleaned between builds (rust-lang/cargo#16437)
- chore: Update dependencies (rust-lang/cargo#16460)
- Update handlebars to 6.4.0 (rust-lang/cargo#16457)
- chore(deps): update alpine docker tag to v3.23 (rust-lang/cargo#16454)
- Any build scripts can now use cargo::metadata=KEY=VALUE (rust-lang/cargo#16436)
- fix(log): add `dependencies` field to `UnitRegistered` (rust-lang/cargo#16448)
- Implement fine grain locking for `build-dir` (rust-lang/cargo#16155)
- feat(resolver): List features when no close match (rust-lang/cargo#16445)
- feat(report): new command `cargo report sessions` (rust-lang/cargo#16428)
- feat (patch): Display where the patch was defined in patch-related error messages (rust-lang/cargo#16407)
- test(build-rs): Reduce from 'build' to 'check' where possible (rust-lang/cargo#16444)
- feat(toml): TOML 1.1 parse support (rust-lang/cargo#16415)
- feat(report): support --manifest-path in `cargo report timings` (rust-lang/cargo#16441)
- fix(vendor): recursively filter git files in subdirectories (rust-lang/cargo#16439)
@rustbot rustbot added this to the 1.94.0 milestone Jan 9, 2026
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