|
1 | 1 | use crate::utils::{
|
2 |
| - match_def_path, match_type, method_calls, paths, span_help_and_lint, span_lint, span_lint_and_sugg, walk_ptrs_ty, |
| 2 | + is_expn_of, match_def_path, match_type, method_calls, paths, span_help_and_lint, span_lint, span_lint_and_sugg, |
| 3 | + walk_ptrs_ty, |
3 | 4 | };
|
4 | 5 | use if_chain::if_chain;
|
5 | 6 | use rustc::hir;
|
@@ -148,25 +149,23 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
|
148 | 149 | if is_lint_ref_type(cx, ty) {
|
149 | 150 | self.declared_lints.insert(item.ident.name, item.span);
|
150 | 151 | }
|
151 |
| - } else if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.kind { |
152 |
| - if_chain! { |
153 |
| - if let hir::TraitRef{path, ..} = trait_ref; |
154 |
| - if let Res::Def(DefKind::Trait, def_id) = path.res; |
155 |
| - if match_def_path(cx, def_id, &paths::LINT_PASS); |
156 |
| - then { |
157 |
| - let mut collector = LintCollector { |
158 |
| - output: &mut self.registered_lints, |
159 |
| - cx, |
160 |
| - }; |
161 |
| - let body_id = cx.tcx.hir().body_owned_by( |
162 |
| - impl_item_refs |
163 |
| - .iter() |
164 |
| - .find(|iiref| iiref.ident.as_str() == "get_lints") |
165 |
| - .expect("LintPass needs to implement get_lints") |
166 |
| - .id.hir_id |
167 |
| - ); |
168 |
| - collector.visit_expr(&cx.tcx.hir().body(body_id).value); |
169 |
| - } |
| 152 | + } else if is_expn_of(item.span, "impl_lint_pass").is_some() |
| 153 | + || is_expn_of(item.span, "declare_lint_pass").is_some() |
| 154 | + { |
| 155 | + if let hir::ItemKind::Impl(.., None, _, ref impl_item_refs) = item.kind { |
| 156 | + let mut collector = LintCollector { |
| 157 | + output: &mut self.registered_lints, |
| 158 | + cx, |
| 159 | + }; |
| 160 | + let body_id = cx.tcx.hir().body_owned_by( |
| 161 | + impl_item_refs |
| 162 | + .iter() |
| 163 | + .find(|iiref| iiref.ident.as_str() == "get_lints") |
| 164 | + .expect("LintPass needs to implement get_lints") |
| 165 | + .id |
| 166 | + .hir_id, |
| 167 | + ); |
| 168 | + collector.visit_expr(&cx.tcx.hir().body(body_id).value); |
170 | 169 | }
|
171 | 170 | }
|
172 | 171 | }
|
|
0 commit comments