|
9 | 9 |
|
10 | 10 |
|
11 | 11 | use crate::utils::{ |
12 | | - match_def_path, match_qpath, match_type, paths, span_help_and_lint, span_lint, span_lint_and_sugg, walk_ptrs_ty, |
| 12 | + match_def_path, match_type, paths, span_help_and_lint, span_lint, span_lint_and_sugg, walk_ptrs_ty, |
13 | 13 | }; |
14 | 14 | use if_chain::if_chain; |
15 | 15 | use crate::rustc::hir; |
@@ -161,16 +161,21 @@ impl LintPass for LintWithoutLintPass { |
161 | 161 |
|
162 | 162 | impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { |
163 | 163 | fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { |
164 | | - if let hir::ItemKind::Static(ref ty, MutImmutable, body_id) = item.node { |
165 | | - |
| 164 | + if let hir::ItemKind::Static(ref ty, MutImmutable, _) = item.node { |
166 | 165 | if is_lint_ref_type(cx, ty) { |
167 | 166 | self.declared_lints.insert(item.name, item.span); |
168 | | - } else if is_lint_array_type(ty) && item.name == "ARRAY" { |
169 | | - if let VisibilityKind::Inherited = item.vis.node { |
| 167 | + } |
| 168 | + } else if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node { |
| 169 | + if_chain! { |
| 170 | + if let hir::TraitRef{path, ..} = trait_ref; |
| 171 | + if let Def::Trait(def_id) = path.def; |
| 172 | + if match_def_path(cx.tcx, def_id, &paths::LINT_PASS); |
| 173 | + then { |
170 | 174 | let mut collector = LintCollector { |
171 | 175 | output: &mut self.registered_lints, |
172 | 176 | cx, |
173 | 177 | }; |
| 178 | + let body_id = cx.tcx.hir.body_owned_by(impl_item_refs[0].id.node_id); |
174 | 179 | collector.visit_expr(&cx.tcx.hir.body(body_id).value); |
175 | 180 | } |
176 | 181 | } |
@@ -223,14 +228,6 @@ fn is_lint_ref_type<'tcx>(cx: &LateContext<'_, 'tcx>, ty: &Ty) -> bool { |
223 | 228 | false |
224 | 229 | } |
225 | 230 |
|
226 | | -fn is_lint_array_type(ty: &Ty) -> bool { |
227 | | - if let TyKind::Path(ref path) = ty.node { |
228 | | - match_qpath(path, &paths::LINT_ARRAY) |
229 | | - } else { |
230 | | - false |
231 | | - } |
232 | | -} |
233 | | - |
234 | 231 | struct LintCollector<'a, 'tcx: 'a> { |
235 | 232 | output: &'a mut FxHashSet<Name>, |
236 | 233 | cx: &'a LateContext<'a, 'tcx>, |
|
0 commit comments