@@ -47,6 +47,23 @@ use rustc_data_structures::fx::FxHashSet;
47
47
use rustc_lint:: LintId ;
48
48
use rustc_session:: Session ;
49
49
50
+ macro_rules! clippy_lint_categories {
51
+ ( $macro: path, $( $tail: tt) * ) => {
52
+ $macro!( {
53
+ correctness: Deny ,
54
+ complexity: Warn ,
55
+ perf: Warn ,
56
+ style: Warn ,
57
+ pedantic: Allow ,
58
+ restriction: Allow ,
59
+ cargo: Allow ,
60
+ nursery: Allow ,
61
+ internal: Allow ,
62
+ internal_warn: Warn ,
63
+ } $( $tail) * ) ;
64
+ } ;
65
+ }
66
+
50
67
/// Macro used to declare a Clippy lint.
51
68
///
52
69
/// Every lint declaration consists of 4 parts:
@@ -92,60 +109,26 @@ use rustc_session::Session;
92
109
/// }
93
110
/// ```
94
111
/// [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
112
+ macro_rules! declare_clippy_lint_macro {
113
+ ( { $( $category: tt: $level: tt, ) * } $d: tt) => {
114
+ macro_rules! declare_clippy_lint {
115
+ $(
116
+ ( $d( #[ $d meta: meta] ) * pub $d name: tt, $category, $d description: tt) => {
117
+ declare_tool_lint! {
118
+ $d( #[ $d meta] ) *
119
+ pub clippy:: $d name,
120
+ $level,
121
+ $d description,
122
+ report_in_external_macro: true
123
+ }
124
+ } ;
125
+ ) *
145
126
}
146
127
} ;
147
128
}
148
129
130
+ clippy_lint_categories ! ( declare_clippy_lint_macro, $) ;
131
+
149
132
#[ macro_export]
150
133
macro_rules! sym {
151
134
( $( $x: tt) * ) => { clippy_utils:: sym!( $( $x) * ) }
0 commit comments