Lint cleanups#157689
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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 @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (secondary 2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 525.47s -> 516.715s (-1.67%) |
These structs can own the `Vec`.
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.
c0abbd2 to
fe67847
Compare
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/clippy |
|
@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, |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (f45cfe7): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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 countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (secondary -3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 517.481s -> 517.406s (-0.01%) |
| 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); |
There was a problem hiding this comment.
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!?
| 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); |
|
☔ The latest upstream changes (presumably #157779) made this pull request unmergeable. Please resolve the merge conflicts. |
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