diff options
Diffstat (limited to 'macros/src/lib.rs')
-rw-r--r-- | macros/src/lib.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/macros/src/lib.rs b/macros/src/lib.rs index c33fcba..127b4cb 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs | |||
@@ -139,6 +139,12 @@ fn generate_match_with_fn(meta: &LintMeta) -> TokenStream2 { | |||
139 | #match_path == *with | 139 | #match_path == *with |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } else if let syn::Expr::Array(array_expr) = match_with_lit { | ||
143 | quote! { | ||
144 | fn match_with(&self, with: &SyntaxKind) -> bool { | ||
145 | #array_expr.contains(with) | ||
146 | } | ||
147 | } | ||
142 | } else { | 148 | } else { |
143 | panic!("`match_with` has non-path value") | 149 | panic!("`match_with` has non-path value") |
144 | } | 150 | } |
@@ -151,8 +157,14 @@ fn generate_match_kind(meta: &LintMeta) -> TokenStream2 { | |||
151 | .unwrap_or_else(|| panic!("`match_with` not present")); | 157 | .unwrap_or_else(|| panic!("`match_with` not present")); |
152 | if let syn::Expr::Path(match_path) = match_with_lit { | 158 | if let syn::Expr::Path(match_path) = match_with_lit { |
153 | quote! { | 159 | quote! { |
154 | fn match_kind(&self) -> SyntaxKind { | 160 | fn match_kind(&self) -> Vec<SyntaxKind> { |
155 | #match_path | 161 | vec![#match_path] |
162 | } | ||
163 | } | ||
164 | } else if let syn::Expr::Array(array_expr) = match_with_lit { | ||
165 | quote! { | ||
166 | fn match_kind(&self) -> Vec<SyntaxKind> { | ||
167 | #array_expr.to_vec() | ||
156 | } | 168 | } |
157 | } | 169 | } |
158 | } else { | 170 | } else { |