diff options
| author | Michael Wright <mikerite@lavabit.com> | 2018-11-13 06:15:33 +0200 |
|---|---|---|
| committer | Michael Wright <mikerite@lavabit.com> | 2018-11-13 06:15:33 +0200 |
| commit | 5ade9ff44ebd466d5658a6666990c84a73dcec86 (patch) | |
| tree | ee7b9d3df4f4142ac0a6cc3cfcd19652e7af0c52 | |
| parent | 82044946cd7afaba1189a4134bb8f874b24b4aec (diff) | |
| download | rust-5ade9ff44ebd466d5658a6666990c84a73dcec86.tar.gz rust-5ade9ff44ebd466d5658a6666990c84a73dcec86.zip | |
Fix `use_self` false positive on `use` statements
| -rw-r--r-- | clippy_lints/src/use_self.rs | 5 | ||||
| -rw-r--r-- | tests/ui/use_self.rs | 13 |
2 files changed, 17 insertions, 1 deletions
diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index db393616ff2..ad4ced995ba 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -16,6 +16,7 @@ use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use crate::rustc::ty; use crate::rustc::{declare_tool_lint, lint_array}; use crate::syntax_pos::symbol::keywords::SelfType; +use crate::syntax::ast::NodeId; /// **What it does:** Checks for unnecessary repetition of structure name when a /// replacement with `Self` is applicable. @@ -234,6 +235,10 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> { walk_path(self, path); } + fn visit_use(&mut self, _path: &'tcx Path, _id: NodeId, _hir_id: HirId) { + // Don't check use statements + } + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::All(&self.cx.tcx.hir) } diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 4c1ec2ad2b9..60dc2d54d05 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -225,7 +225,7 @@ mod issue3410 { struct A; struct B; - trait Trait<T>: Sized { + trait Trait<T> { fn a(v: T); } @@ -233,3 +233,14 @@ mod issue3410 { fn a(_: Vec<A>) {} } } + +mod issue3425 { + enum Enum { + A, + } + impl Enum { + fn a () { + use self::Enum::*; + } + } +} |
