Skip to content

Commit 2c77ea6

Browse files
committed
Refactor lint categories in macro
1 parent eb04beb commit 2c77ea6

File tree

1 file changed

+30
-50
lines changed

1 file changed

+30
-50
lines changed

clippy_lints/src/lib.rs

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -92,60 +92,40 @@ use rustc_session::Session;
9292
/// }
9393
/// ```
9494
/// [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
95-
#[macro_export]
96-
macro_rules! declare_clippy_lint {
97-
{ $(#[$attr:meta])* pub $name:tt, style, $description:tt } => {
98-
declare_tool_lint! {
99-
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
100-
}
101-
};
102-
{ $(#[$attr:meta])* pub $name:tt, correctness, $description:tt } => {
103-
declare_tool_lint! {
104-
$(#[$attr])* pub clippy::$name, Deny, $description, report_in_external_macro: true
105-
}
106-
};
107-
{ $(#[$attr:meta])* pub $name:tt, complexity, $description:tt } => {
108-
declare_tool_lint! {
109-
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
110-
}
111-
};
112-
{ $(#[$attr:meta])* pub $name:tt, perf, $description:tt } => {
113-
declare_tool_lint! {
114-
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
115-
}
116-
};
117-
{ $(#[$attr:meta])* pub $name:tt, pedantic, $description:tt } => {
118-
declare_tool_lint! {
119-
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
120-
}
121-
};
122-
{ $(#[$attr:meta])* pub $name:tt, restriction, $description:tt } => {
123-
declare_tool_lint! {
124-
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
125-
}
126-
};
127-
{ $(#[$attr:meta])* pub $name:tt, cargo, $description:tt } => {
128-
declare_tool_lint! {
129-
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
130-
}
131-
};
132-
{ $(#[$attr:meta])* pub $name:tt, nursery, $description:tt } => {
133-
declare_tool_lint! {
134-
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
135-
}
136-
};
137-
{ $(#[$attr:meta])* pub $name:tt, internal, $description:tt } => {
138-
declare_tool_lint! {
139-
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
140-
}
141-
};
142-
{ $(#[$attr:meta])* pub $name:tt, internal_warn, $description:tt } => {
143-
declare_tool_lint! {
144-
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
95+
macro_rules! declare_clippy_lint_macro {
96+
({ $($category:tt: $level:tt,)* }, $d:tt) => {
97+
macro_rules! declare_clippy_lint {
98+
$(
99+
($d(#[$d meta:meta])* pub $d name:tt, $category, $d description:tt) => {
100+
declare_tool_lint! {
101+
$d(#[$d meta])*
102+
pub clippy::$d name,
103+
$level,
104+
$d description,
105+
report_in_external_macro: true
106+
}
107+
};
108+
)*
145109
}
146110
};
147111
}
148112

113+
declare_clippy_lint_macro! {
114+
{
115+
correctness: Deny,
116+
complexity: Warn,
117+
perf: Warn,
118+
style: Warn,
119+
pedantic: Allow,
120+
restriction: Allow,
121+
cargo: Allow,
122+
nursery: Allow,
123+
internal: Allow,
124+
internal_warn: Warn,
125+
},
126+
$
127+
}
128+
149129
#[macro_export]
150130
macro_rules! sym {
151131
( $($x:tt)* ) => { clippy_utils::sym!($($x)*) }

0 commit comments

Comments
 (0)