From 2c77ea6bd47609a0d21a2f988ddab15e132a1cb3 Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Tue, 2 Mar 2021 14:47:11 -0600 Subject: [PATCH] Refactor lint categories in macro --- clippy_lints/src/lib.rs | 80 ++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 1ace4c8a10c9..9b6cd376d4dc 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -92,60 +92,40 @@ use rustc_session::Session; /// } /// ``` /// [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints -#[macro_export] -macro_rules! declare_clippy_lint { - { $(#[$attr:meta])* pub $name:tt, style, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, correctness, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Deny, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, complexity, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, perf, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, pedantic, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, restriction, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, cargo, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, nursery, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, internal, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true - } - }; - { $(#[$attr:meta])* pub $name:tt, internal_warn, $description:tt } => { - declare_tool_lint! { - $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true +macro_rules! declare_clippy_lint_macro { + ({ $($category:tt: $level:tt,)* }, $d:tt) => { + macro_rules! declare_clippy_lint { + $( + ($d(#[$d meta:meta])* pub $d name:tt, $category, $d description:tt) => { + declare_tool_lint! { + $d(#[$d meta])* + pub clippy::$d name, + $level, + $d description, + report_in_external_macro: true + } + }; + )* } }; } +declare_clippy_lint_macro! { + { + correctness: Deny, + complexity: Warn, + perf: Warn, + style: Warn, + pedantic: Allow, + restriction: Allow, + cargo: Allow, + nursery: Allow, + internal: Allow, + internal_warn: Warn, + }, + $ +} + #[macro_export] macro_rules! sym { ( $($x:tt)* ) => { clippy_utils::sym!($($x)*) }