Skip to content

Lint cleanups#157689

Open
nnethercote wants to merge 9 commits into
rust-lang:mainfrom
nnethercote:lint-cleanups
Open

Lint cleanups#157689
nnethercote wants to merge 9 commits into
rust-lang:mainfrom
nnethercote:lint-cleanups

Conversation

@nnethercote

@nnethercote nnethercote commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This PR is a precursor to #157762, which does some invasive changes to speed up clippy. This PR has various clean up commits I made in preparation for the invasive changes. Details in individual commits.

r? @GuillaumeGomez

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 10, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 10, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 10, 2026
@rust-bors

rust-bors Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 823510d (823510d73548f1ca5796a6ff7c04871b48c2ee61, parent: d56483a91d6cf5041351a3208b8d08f98f0c8b56)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (823510d): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.1%, 1.0%] 30
Regressions ❌
(secondary)
0.7% [0.1%, 1.9%] 57
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.1%, 1.0%] 30

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (secondary 2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [2.2%, 3.6%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 525.47s -> 516.715s (-1.67%)
Artifact size: 400.80 MiB -> 401.32 MiB (0.13%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 10, 2026
By using `retain` instead of `into_iter`/`filter`/`collect`.
It doesn't define any `check_*` methods so there's no point adding it to
the passes list. (It's only there for `HardwiredLints::lint_vec`.) This
makes it more like `SoftLints`.
All the other paired methods in this trait have the form
`check_foo`/`check_foo_post`.
Currently the use points need to handle method attributes, due to a
single low-value doc comment in each macro's body. This commit moves
those doc comments so the use points can be simplified. The comments are
also made more accurate -- there are now multiple `_post` methods and
the comments now cover all of them, not just one of them.
That reflects how they're mostly used and avoids the need for some long
signatures. And it matches `{Early,Late}LintPassObject` nicely. Also
make them public so that clippy can use them.
There's a lot of repetition here that can be avoided.
@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Jun 12, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 12, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
@nnethercote nnethercote marked this pull request as ready for review June 12, 2026 10:12
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 12, 2026
@rustbot

rustbot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 12, 2026
@samueltardieu

Copy link
Copy Markdown
Member

@nnethercote Those changes will conflict on the Clippy side with the ones being currently merged: https://github.com/rust-lang/rust/pull/157779/changes#diff-87bfc7a19a52188bf03cd0c38999b9a1adf259e1631f5c493cd30704340dd602

Also, clippy_dev/src/new_lint.rs should probably be modified as well as it auto-generates the initialization line for added lints, which should probably now use b!() or similar.

@rust-bors

rust-bors Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: f45cfe7 (f45cfe742c19a6dfd7dd26799f4fa71dbbe9998f, parent: 09a371361240e42b0d69438fd1179efcf212e576)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (f45cfe7): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (secondary -3.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.6%, -2.8%] 3
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 517.481s -> 517.406s (-0.01%)
Artifact size: 401.31 MiB -> 400.78 MiB (-0.13%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Jun 12, 2026
Comment on lines +669 to +696
macro_rules! early {
($register:ident, $lint:ident) => {
store.register_lints(&$lint::lint_vec());
store.$register(Box::new(|| Box::new($lint)));
};
}

macro_rules! late {
($register:ident, $lint:ident) => {
store.register_lints(&$lint::lint_vec());
store.$register(Box::new(|_| Box::new($lint)));
};
}

early!(register_early_pass, LintPassImpl);
early!(register_early_pass, ImplicitSysrootCrateImport);
early!(register_early_pass, BadUseOfFindAttr);

late!(register_late_mod_pass, DefaultHashTypes);
late!(register_late_mod_pass, QueryStability);
late!(register_late_mod_pass, TyTyKind);
late!(register_late_mod_pass, TypeIr);
late!(register_late_mod_pass, BadOptAccess);
late!(register_late_mod_pass, DisallowedPassByRef);
late!(register_late_mod_pass, SpanUseEqCtxt);
late!(register_late_mod_pass, SymbolInternStringLiteral);

late!(register_late_pass, RustcMustMatchExhaustively);

@ada4a ada4a Jun 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the bodies of the two macros ended up being identical, and the early/late distinction is already clear from the method name used (register_early_pass vs register_late(_mod)pass), maybe use one macro instead, called something like register!?

Suggested change
macro_rules! early {
($register:ident, $lint:ident) => {
store.register_lints(&$lint::lint_vec());
store.$register(Box::new(|| Box::new($lint)));
};
}
macro_rules! late {
($register:ident, $lint:ident) => {
store.register_lints(&$lint::lint_vec());
store.$register(Box::new(|_| Box::new($lint)));
};
}
early!(register_early_pass, LintPassImpl);
early!(register_early_pass, ImplicitSysrootCrateImport);
early!(register_early_pass, BadUseOfFindAttr);
late!(register_late_mod_pass, DefaultHashTypes);
late!(register_late_mod_pass, QueryStability);
late!(register_late_mod_pass, TyTyKind);
late!(register_late_mod_pass, TypeIr);
late!(register_late_mod_pass, BadOptAccess);
late!(register_late_mod_pass, DisallowedPassByRef);
late!(register_late_mod_pass, SpanUseEqCtxt);
late!(register_late_mod_pass, SymbolInternStringLiteral);
late!(register_late_pass, RustcMustMatchExhaustively);
macro_rules! register {
($register:ident, $lint:ident) => {
store.register_lints(&$lint::lint_vec());
store.$register(Box::new(|_| Box::new($lint)));
};
}
register!(register_early_pass, LintPassImpl);
register!(register_early_pass, ImplicitSysrootCrateImport);
register!(register_early_pass, BadUseOfFindAttr);
register!(register_late_mod_pass, DefaultHashTypes);
register!(register_late_mod_pass, QueryStability);
register!(register_late_mod_pass, TyTyKind);
register!(register_late_mod_pass, TypeIr);
register!(register_late_mod_pass, BadOptAccess);
register!(register_late_mod_pass, DisallowedPassByRef);
register!(register_late_mod_pass, SpanUseEqCtxt);
register!(register_late_mod_pass, SymbolInternStringLiteral);
register!(register_late_pass, RustcMustMatchExhaustively);

View changes since the review

@rust-bors

rust-bors Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #157779) 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

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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants