Fix `use_self` false positive on `use` statements

This commit is contained in:
Michael Wright 2018-11-13 06:15:33 +02:00
parent 82044946cd
commit 5ade9ff44e
2 changed files with 17 additions and 1 deletions

View File

@ -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)
}

View File

@ -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::*;
}
}
}