diff options
Diffstat (limited to 'lib/src/lib.rs')
-rw-r--r-- | lib/src/lib.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 5347666..d96d9eb 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs | |||
@@ -255,31 +255,24 @@ pub trait Lint: Metadata + Explain + Rule + Send + Sync {} | |||
255 | /// | 255 | /// |
256 | /// See `lints.rs` for usage. | 256 | /// See `lints.rs` for usage. |
257 | #[macro_export] | 257 | #[macro_export] |
258 | macro_rules! lint_map { | 258 | macro_rules! lints { |
259 | ($($s:ident),*,) => { | 259 | ($($s:ident),*,) => { |
260 | lint_map!($($s),*); | 260 | lints!($($s),*); |
261 | }; | 261 | }; |
262 | ($($s:ident),*) => { | 262 | ($($s:ident),*) => { |
263 | use ::std::collections::HashMap; | ||
264 | use ::rnix::SyntaxKind; | ||
265 | $( | 263 | $( |
266 | mod $s; | 264 | mod $s; |
267 | )* | 265 | )* |
268 | ::lazy_static::lazy_static! { | 266 | ::lazy_static::lazy_static! { |
269 | pub static ref LINTS: HashMap<SyntaxKind, Vec<&'static Box<dyn $crate::Lint>>> = { | 267 | pub static ref LINTS: Vec<&'static Box<dyn $crate::Lint>> = { |
270 | let mut map = HashMap::new(); | 268 | let mut v = Vec::new(); |
271 | $( | 269 | $( |
272 | { | 270 | { |
273 | let temp_lint = &*$s::LINT; | 271 | let temp_lint = &*$s::LINT; |
274 | let temp_matches = temp_lint.match_kind(); | 272 | v.push(temp_lint); |
275 | for temp_match in temp_matches { | ||
276 | map.entry(temp_match) | ||
277 | .and_modify(|v: &mut Vec<_>| v.push(temp_lint)) | ||
278 | .or_insert_with(|| vec![temp_lint]); | ||
279 | } | ||
280 | } | 273 | } |
281 | )* | 274 | )* |
282 | map | 275 | v |
283 | }; | 276 | }; |
284 | } | 277 | } |
285 | } | 278 | } |