Skip to content

Commit

Permalink
Move to clippy_lints
Browse files Browse the repository at this point in the history
  • Loading branch information
blyxyas committed Sep 23, 2024
1 parent 205a2d4 commit c4d3198
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// warn on lints, that are included in `rust-lang/rust`s bootstrap
#![warn(rust_2018_idioms, unused_lifetimes)]

#[macro_export]
#[allow(clippy::crate_in_macro_def)]
macro_rules! declare_clippy_lint {
(@
// $(#[$($attrss:tt)*])*
$(#[doc = $lit:literal])*
pub $lint_name:ident,
$category:ident,
Expand All @@ -17,19 +13,19 @@ macro_rules! declare_clippy_lint {
rustc_session::declare_tool_lint! {
$(#[doc = $lit])*
#[clippy::version = $version_lit]
pub clippy::$lint_name,$category,$desc,
report_in_external_macro:true
pub clippy::$lint_name,
$category,
$desc,
report_in_external_macro:true
}

$crate::paste::paste! {
pub(crate) static ${concat($lint_name, _INFO)}: &'static crate::LintInfo = &crate::LintInfo {
lint: &$lint_name,
category: $lintcategory,
explanation: concat!($($lit,"\n",)*),
location: concat!(file!(), "#L", line!()),
version: $version_expr
};
}
pub(crate) static ${concat($lint_name, _INFO)}: &'static crate::LintInfo = &crate::LintInfo {
lint: &$lint_name,
category: $lintcategory,
explanation: concat!($($lit,"\n",)*),
location: concat!(file!(), "#L", line!()),
version: $version_expr
};
};
(
$(#[doc = $lit:literal])*
Expand All @@ -40,7 +36,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name,Allow, crate::LintCategory::Restriction,$desc,
pub $lint_name, Allow, crate::LintCategory::Restriction, $desc,
declare_clippy_lint!(__version = $version), $version
}
};
Expand All @@ -53,7 +49,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name, Warn, crate::LintCategory::Style,$desc,
pub $lint_name, Warn, crate::LintCategory::Style, $desc,
declare_clippy_lint!(__version = $version), $version

}
Expand All @@ -67,7 +63,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name,Deny, crate::LintCategory::Correctness,$desc,
pub $lint_name, Deny, crate::LintCategory::Correctness, $desc,
declare_clippy_lint!(__version = $version), $version

}
Expand All @@ -81,7 +77,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name, Warn, crate::LintCategory::Perf,$desc,
pub $lint_name, Warn, crate::LintCategory::Perf, $desc,
declare_clippy_lint!(__version = $version), $version
}
};
Expand All @@ -94,7 +90,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name, Warn, crate::LintCategory::Complexity,$desc,
pub $lint_name, Warn, crate::LintCategory::Complexity, $desc,
declare_clippy_lint!(__version = $version), $version
}
};
Expand All @@ -107,7 +103,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name, Warn, crate::LintCategory::Suspicious,$desc,
pub $lint_name, Warn, crate::LintCategory::Suspicious, $desc,
declare_clippy_lint!(__version = $version), $version
}
};
Expand All @@ -120,7 +116,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name,Allow, crate::LintCategory::Nursery,$desc,
pub $lint_name, Allow, crate::LintCategory::Nursery, $desc,
declare_clippy_lint!(__version = $version), $version
}
};
Expand All @@ -133,7 +129,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name,Allow, crate::LintCategory::Pedantic,$desc,
pub $lint_name, Allow, crate::LintCategory::Pedantic, $desc,
declare_clippy_lint!(__version = $version), $version
}
};
Expand All @@ -146,7 +142,7 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name,Allow, crate::LintCategory::Cargo,$desc,
pub $lint_name, Allow, crate::LintCategory::Cargo, $desc,
declare_clippy_lint!(__version = $version), $version
}
};
Expand All @@ -160,8 +156,8 @@ macro_rules! declare_clippy_lint {
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name,Allow, crate::LintCategory::Internal,$desc,
declare_clippy_lint!(__version = $($version)?), "0.0.0"
pub $lint_name, Allow, crate::LintCategory::Internal, $desc,
None, "0.0.0"
}
};

Expand Down
3 changes: 3 additions & 0 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ extern crate rustc_target;
extern crate rustc_trait_selection;
extern crate thin_vec;

#[macro_use]
mod declare_clippy_lint;

#[macro_use]
extern crate clippy_utils;

Expand Down
5 changes: 0 additions & 5 deletions clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub mod attrs;
mod check_proc_macro;
pub mod comparisons;
pub mod consts;
pub mod declare_clippy_lint;
pub mod diagnostics;
pub mod eager_or_lazy;
pub mod higher;
Expand Down Expand Up @@ -131,10 +130,6 @@ use crate::consts::{mir_to_const, ConstEvalCtxt, Constant};
use crate::higher::Range;
use crate::ty::{adt_and_variant_of_res, can_partially_move_ty, expr_sig, is_copy, is_recursively_primitive_type};
use crate::visitors::for_each_expr_without_closures;

#[doc(hidden)]
pub use paste;

use rustc_middle::hir::nested_filter;

#[macro_export]
Expand Down
1 change: 0 additions & 1 deletion tests/versioncheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ fn consistent_clippy_crate_versions() {
let clippy_version = read_version("Cargo.toml");

let paths = [
"declare_clippy_lint/Cargo.toml",
"clippy_config/Cargo.toml",
"clippy_lints/Cargo.toml",
"clippy_utils/Cargo.toml",
Expand Down

0 comments on commit c4d3198

Please sign in to comment.