Auto merge of #125116 - blyxyas:ignore-allowed-lints-final, r=cjgillot
(Big performance change) Do not run lints that cannot emit Before this change, adding a lint was a difficult matter because it always had some overhead involved. This was because all lints would run, no matter their default level, or if the user had `#![allow]`ed them. This PR changes that. This change would improve both the Rust lint infrastructure and Clippy, but Clippy will see the most benefit, as it has about 900 registered lints (and growing!) So yeah, with this little patch we filter all lints pre-linting, and remove any lint that is either: - Manually `#![allow]`ed in the whole crate, - Allowed in the command line, or - Not manually enabled with `#[warn]` or similar, and its default level is `Allow` As some lints **need** to run, this PR also adds **loadbearing lints**. On a lint declaration, you can use the ``@eval_always` = true` marker to label it as loadbearing. A loadbearing lint will never be filtered (it will always run) Fixes #106983
This commit is contained in:
commit
4d88de2acd
45 changed files with 291 additions and 56 deletions
|
@ -73,7 +73,6 @@ use crate::{
|
|||
EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext,
|
||||
fluent_generated as fluent,
|
||||
};
|
||||
|
||||
declare_lint! {
|
||||
/// The `while_true` lint detects `while true { }`.
|
||||
///
|
||||
|
@ -241,7 +240,8 @@ declare_lint! {
|
|||
/// behavior.
|
||||
UNSAFE_CODE,
|
||||
Allow,
|
||||
"usage of `unsafe` code and other potentially unsound constructs"
|
||||
"usage of `unsafe` code and other potentially unsound constructs",
|
||||
@eval_always = true
|
||||
}
|
||||
|
||||
declare_lint_pass!(UnsafeCode => [UNSAFE_CODE]);
|
||||
|
@ -389,6 +389,7 @@ declare_lint! {
|
|||
report_in_external_macro
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MissingDoc;
|
||||
|
||||
impl_lint_pass!(MissingDoc => [MISSING_DOCS]);
|
||||
|
@ -819,8 +820,8 @@ pub struct DeprecatedAttr {
|
|||
|
||||
impl_lint_pass!(DeprecatedAttr => []);
|
||||
|
||||
impl DeprecatedAttr {
|
||||
pub fn new() -> DeprecatedAttr {
|
||||
impl Default for DeprecatedAttr {
|
||||
fn default() -> Self {
|
||||
DeprecatedAttr { depr_attrs: deprecated_attributes() }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue