aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-15 08:36:29 +0100
committerAkshay <[email protected]>2021-10-15 08:36:29 +0100
commit45ab8abf76aa8157b43f3c7675b11fb51fac66d9 (patch)
tree6a2d7f6e52069b69e303381e9f89a32950d41a3b /lib
parentc6ea58410cb6145cf2791f0ae0d1918cf0d5bc62 (diff)
allow match_kind to accept multiple kinds
Diffstat (limited to 'lib')
-rw-r--r--lib/src/lib.rs12
1 files changed, 7 insertions, 5 deletions
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 {
112 where 112 where
113 Self: Sized; 113 Self: Sized;
114 fn match_with(&self, with: &SyntaxKind) -> bool; 114 fn match_with(&self, with: &SyntaxKind) -> bool;
115 fn match_kind(&self) -> SyntaxKind; 115 fn match_kind(&self) -> Vec<SyntaxKind>;
116} 116}
117 117
118/// Combines Rule and Metadata, do not implement manually, this is derived by 118/// Combines Rule and Metadata, do not implement manually, this is derived by
@@ -140,10 +140,12 @@ macro_rules! lint_map {
140 $( 140 $(
141 { 141 {
142 let temp_lint = &*$s::LINT; 142 let temp_lint = &*$s::LINT;
143 let temp_match = temp_lint.match_kind(); 143 let temp_matches = temp_lint.match_kind();
144 map.entry(temp_match) 144 for temp_match in temp_matches {
145 .and_modify(|v: &mut Vec<_>| v.push(temp_lint)) 145 map.entry(temp_match)
146 .or_insert_with(|| vec![temp_lint]); 146 .and_modify(|v: &mut Vec<_>| v.push(temp_lint))
147 .or_insert_with(|| vec![temp_lint]);
148 }
147 } 149 }
148 )* 150 )*
149 map 151 map