Skip to content

Commit 6cc502d

Browse files
bors[bot]Michael Wright
and
Michael Wright
committed
3426: Fix `use_self` false positive on `use` statements r=flip1995 a=mikerite Fixes rust-lang#3425 Co-authored-by: Michael Wright <[email protected]>
2 parents 8204494 + 5ade9ff commit 6cc502d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

clippy_lints/src/use_self.rs

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
1616
use crate::rustc::ty;
1717
use crate::rustc::{declare_tool_lint, lint_array};
1818
use crate::syntax_pos::symbol::keywords::SelfType;
19+
use crate::syntax::ast::NodeId;
1920

2021
/// **What it does:** Checks for unnecessary repetition of structure name when a
2122
/// replacement with `Self` is applicable.
@@ -234,6 +235,10 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
234235
walk_path(self, path);
235236
}
236237

238+
fn visit_use(&mut self, _path: &'tcx Path, _id: NodeId, _hir_id: HirId) {
239+
// Don't check use statements
240+
}
241+
237242
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
238243
NestedVisitorMap::All(&self.cx.tcx.hir)
239244
}

tests/ui/use_self.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,22 @@ mod issue3410 {
225225
struct A;
226226
struct B;
227227

228-
trait Trait<T>: Sized {
228+
trait Trait<T> {
229229
fn a(v: T);
230230
}
231231

232232
impl Trait<Vec<A>> for Vec<B> {
233233
fn a(_: Vec<A>) {}
234234
}
235235
}
236+
237+
mod issue3425 {
238+
enum Enum {
239+
A,
240+
}
241+
impl Enum {
242+
fn a () {
243+
use self::Enum::*;
244+
}
245+
}
246+
}

0 commit comments

Comments
 (0)