Skip to content

Commit

Permalink
Do not run lints that cannot emit
Browse files Browse the repository at this point in the history
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
  • Loading branch information
blyxyas committed Oct 19, 2024
1 parent 91a458f commit 6983631
Show file tree
Hide file tree
Showing 26 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/asm_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt;
use clippy_utils::diagnostics::span_lint_and_then;
use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions};
use rustc_ast::{InlineAsm, Item, ItemKind};
use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext};
use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintPass, LintContext};
use rustc_session::declare_lint_pass;
use rustc_span::Span;
use rustc_target::asm::InlineAsmArch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_span::symbol::{Ident, Symbol};
use std::cell::Cell;
use std::fmt::{Display, Formatter, Write as _};

declare_lint_pass!(
declare_clippy_lint!{
/// ### What it does
/// Generates clippy code that detects the offending pattern
///
Expand Down Expand Up @@ -44,8 +44,13 @@ declare_lint_pass!(
/// // report your lint here
/// }
/// ```
Author => []
);
#[clippy::version = "1.0.0"]
pub AUTHOR,
internal,
"The author lint, see documentation at <https://doc.rust-lang.org/nightly/clippy/development/adding_lints.html#author-lint>"
};

declare_lint_pass! { Author => [AUTHOR] }

/// Writes a line of output with indentation added
macro_rules! out {
Expand Down
1 change: 0 additions & 1 deletion clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod author;
pub mod dump_hir;
pub mod format_args_collector;
#[cfg(feature = "internal")]
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/author.rs → tests/ui-internal/author.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![warn(clippy::author)]

fn main() {
#[clippy::author]
let x: char = 0x45 as char;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/ui/no_lints.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#![deny(clippy::all)]

fn main() {}

0 comments on commit 6983631

Please sign in to comment.