-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #13359 - blyxyas:declare_clippy_macro, r=Alexendoo
Turn declare_clippy_lint into a declarative macro Ease of development, and hopefully compile times (the dependencies are still there because of ui-test). The procedural macro was doing just some very basic processing (like assigning a lint level to each category), so it didn't have a reason to stay IMO changelog: None
- Loading branch information
Showing
10 changed files
with
196 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
#[macro_export] | ||
#[allow(clippy::crate_in_macro_def)] | ||
macro_rules! declare_clippy_lint { | ||
(@ | ||
$(#[doc = $lit:literal])* | ||
pub $lint_name:ident, | ||
$category:ident, | ||
$lintcategory:expr, | ||
$desc:literal, | ||
$version_expr:expr, | ||
$version_lit:literal | ||
) => { | ||
rustc_session::declare_tool_lint! { | ||
$(#[doc = $lit])* | ||
#[clippy::version = $version_lit] | ||
pub clippy::$lint_name, | ||
$category, | ||
$desc, | ||
report_in_external_macro:true | ||
} | ||
|
||
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])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
restriction, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Allow, crate::LintCategory::Restriction, $desc, | ||
Some($version), $version | ||
} | ||
}; | ||
( | ||
$(#[doc = $lit:literal])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
style, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Warn, crate::LintCategory::Style, $desc, | ||
Some($version), $version | ||
|
||
} | ||
}; | ||
( | ||
$(#[doc = $lit:literal])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
correctness, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Deny, crate::LintCategory::Correctness, $desc, | ||
Some($version), $version | ||
|
||
} | ||
}; | ||
( | ||
$(#[doc = $lit:literal])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
perf, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Warn, crate::LintCategory::Perf, $desc, | ||
Some($version), $version | ||
} | ||
}; | ||
( | ||
$(#[doc = $lit:literal])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
complexity, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Warn, crate::LintCategory::Complexity, $desc, | ||
Some($version), $version | ||
} | ||
}; | ||
( | ||
$(#[doc = $lit:literal])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
suspicious, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Warn, crate::LintCategory::Suspicious, $desc, | ||
Some($version), $version | ||
} | ||
}; | ||
( | ||
$(#[doc = $lit:literal])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
nursery, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Allow, crate::LintCategory::Nursery, $desc, | ||
Some($version), $version | ||
} | ||
}; | ||
( | ||
$(#[doc = $lit:literal])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
pedantic, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Allow, crate::LintCategory::Pedantic, $desc, | ||
Some($version), $version | ||
} | ||
}; | ||
( | ||
$(#[doc = $lit:literal])* | ||
#[clippy::version = $version:literal] | ||
pub $lint_name:ident, | ||
cargo, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Allow, crate::LintCategory::Cargo, $desc, | ||
Some($version), $version | ||
} | ||
}; | ||
|
||
( | ||
$(#[doc = $lit:literal])* | ||
pub $lint_name:ident, | ||
internal, | ||
$desc:literal | ||
) => { | ||
declare_clippy_lint! {@ | ||
$(#[doc = $lit])* | ||
pub $lint_name, Allow, crate::LintCategory::Internal, $desc, | ||
None, "0.0.0" | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.