|
10 | 10 | use crate::utils::span_lint_and_sugg; |
11 | 11 | use if_chain::if_chain; |
12 | 12 | use rustc::hir::def::{CtorKind, Def}; |
13 | | -use rustc::hir::intravisit::{walk_path, walk_ty, NestedVisitorMap, Visitor}; |
| 13 | +use rustc::hir::intravisit::{walk_item, walk_path, walk_ty, NestedVisitorMap, Visitor}; |
14 | 14 | use rustc::hir::*; |
15 | 15 | use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass}; |
16 | 16 | use rustc::ty; |
17 | 17 | use rustc::{declare_tool_lint, lint_array}; |
18 | 18 | use rustc_errors::Applicability; |
19 | | -use syntax::ast::NodeId; |
20 | 19 | use syntax_pos::symbol::keywords::SelfUpper; |
21 | 20 |
|
22 | 21 | /// **What it does:** Checks for unnecessary repetition of structure name when a |
@@ -242,8 +241,17 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> { |
242 | 241 | walk_path(self, path); |
243 | 242 | } |
244 | 243 |
|
245 | | - fn visit_use(&mut self, _path: &'tcx Path, _id: NodeId, _hir_id: HirId) { |
246 | | - // Don't check use statements |
| 244 | + fn visit_item(&mut self, item: &'tcx Item) { |
| 245 | + match item.node { |
| 246 | + ItemKind::Use(..) |
| 247 | + | ItemKind::Static(..) |
| 248 | + | ItemKind::Enum(..) |
| 249 | + | ItemKind::Struct(..) |
| 250 | + | ItemKind::Union(..) => { |
| 251 | + // Don't check statements that shadow `Self` or where `Self` can't be used |
| 252 | + }, |
| 253 | + _ => walk_item(self, item), |
| 254 | + } |
247 | 255 | } |
248 | 256 |
|
249 | 257 | fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { |
|
0 commit comments