Skip to content

Split LintExpectationIds#156596

Open
nnethercote wants to merge 5 commits into
rust-lang:mainfrom
nnethercote:split-LintExpectation
Open

Split LintExpectationIds#156596
nnethercote wants to merge 5 commits into
rust-lang:mainfrom
nnethercote:split-LintExpectation

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

This PR makes clearer where stable and unstable LintExpectationIds can occur, plus a few other small cleanups. Details in individual commits.

r? @GuillaumeGomez

It has a single call site.
`LintExpectationId` has two variants, `Unstable` and `Stable`. There are
some places where both variants are possible, but there are also places
where only one of `Unstable` or `Stable` is possible.

This commit encodes this into the type system by introducing
new types `UnstableLintExpectationId` and `StableLintExpectationId`. The
variants of `LintExpectationId` now enclose these. This makes it clearer
what values are possible where.

Other things of note:
- `LintLevelsProvider` gets an associated type and some method changes.
- `LintContext` gets an associated type.
- `LevelSpec` is made generic. `UnstableLevelSpec` and `StableLevelSpec`
  typedefs are added.
- The unstable types are now guaranteed by the type system to never be
  stably hashed. Previously this was a runtime check.
I find these make the code harder to understand.
Describing things that took me a while to work out.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 15, 2026

The Clippy subtree was changed

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants