From 45ab8abf76aa8157b43f3c7675b11fb51fac66d9 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 15 Oct 2021 13:06:29 +0530 Subject: allow match_kind to accept multiple kinds --- lib/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/src') diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 4065345..4374ac7 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -112,7 +112,7 @@ pub trait Metadata { where Self: Sized; fn match_with(&self, with: &SyntaxKind) -> bool; - fn match_kind(&self) -> SyntaxKind; + fn match_kind(&self) -> Vec; } /// Combines Rule and Metadata, do not implement manually, this is derived by @@ -140,10 +140,12 @@ macro_rules! lint_map { $( { let temp_lint = &*$s::LINT; - let temp_match = temp_lint.match_kind(); - map.entry(temp_match) - .and_modify(|v: &mut Vec<_>| v.push(temp_lint)) - .or_insert_with(|| vec![temp_lint]); + let temp_matches = temp_lint.match_kind(); + for temp_match in temp_matches { + map.entry(temp_match) + .and_modify(|v: &mut Vec<_>| v.push(temp_lint)) + .or_insert_with(|| vec![temp_lint]); + } } )* map -- cgit v1.2.3