Repository navigation
Don't run allowed lints #74704
Copy link
Copy link
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
- addedI-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.
on Jul 24, 2020 - addedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on Jul 24, 2020 - addedI-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.and removedI-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.
on Jul 24, 2020 @flip1995 mentioned that this is a hard problem in general:
one LintPass can have multiple lints (which makes sense for performance and DRY) and only can be skipped, iff all lints in the lint pass are allowed. Clippy has a "workaround" for this:
https://github.com/rust-lang/rust-clippy/blob/06f190287848ceeee36be738cbbd8e008f3e7615/clippy_lints/src/utils/mod.rs#L1402
https://github.com/rust-lang/rust-clippy/blob/c493090a8a601baea39a592fdbe199bd64d6db22/clippy_lints/src/wildcard_dependencies.rs#L33Also, this only works for
LateLintPass.Reacted by Philipp KronesWe could put allow-by-default lints into a separate pass. Then disable the whole pass if all those lints are never enabled in the crate?
Fixed by #125116
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
First noticed in https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Output.20of.20.60collector.20eprintln.60/near/204875468. If a lint is allowed, there is no need to run the lint pass. This could have large performance improvements for any crate where all lints are allowed (e.g. any dependency compiled by cargo, which uses
--cap-lints allow).As a first pass this could check for
--cap-lints allowand run no lints if so. In the future it could skip individual lints. Rustc would have to be careful not to skip lints that are#![allow]ed at the crate level but re-enabled for individual items.The implementation would look similar to what I did in #73566 - override the query provider for
lint_modso that it doesn't run lints at all.