Skip to content

Commit 6983631

Browse files
committed
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
1 parent 91a458f commit 6983631

26 files changed

+14
-5
lines changed

clippy_lints/src/asm_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt;
33
use clippy_utils::diagnostics::span_lint_and_then;
44
use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions};
55
use rustc_ast::{InlineAsm, Item, ItemKind};
6-
use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext};
6+
use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintPass, LintContext};
77
use rustc_session::declare_lint_pass;
88
use rustc_span::Span;
99
use rustc_target::asm::InlineAsmArch;

clippy_lints/src/utils/author.rs renamed to clippy_lints/src/utils/internal_lints/author.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_span::symbol::{Ident, Symbol};
1212
use std::cell::Cell;
1313
use std::fmt::{Display, Formatter, Write as _};
1414

15-
declare_lint_pass!(
15+
declare_clippy_lint!{
1616
/// ### What it does
1717
/// Generates clippy code that detects the offending pattern
1818
///
@@ -44,8 +44,13 @@ declare_lint_pass!(
4444
/// // report your lint here
4545
/// }
4646
/// ```
47-
Author => []
48-
);
47+
#[clippy::version = "1.0.0"]
48+
pub AUTHOR,
49+
internal,
50+
"The author lint, see documentation at <https://doc.rust-lang.org/nightly/clippy/development/adding_lints.html#author-lint>"
51+
};
52+
53+
declare_lint_pass! { Author => [AUTHOR] }
4954

5055
/// Writes a line of output with indentation added
5156
macro_rules! out {

clippy_lints/src/utils/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub mod author;
21
pub mod dump_hir;
32
pub mod format_args_collector;
43
#[cfg(feature = "internal")]

tests/ui/author.rs renamed to tests/ui-internal/author.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![warn(clippy::author)]
2+
13
fn main() {
24
#[clippy::author]
35
let x: char = 0x45 as char;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)