properly lint function argument patterns in similar_names
This commit is contained in:
parent
49e2570b77
commit
f004120495
@ -259,7 +259,7 @@ fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
|
||||
};
|
||||
// initialize with function arguments
|
||||
for arg in &decl.inputs {
|
||||
visit::walk_pat(&mut SimilarNamesNameVisitor(&mut visitor), &arg.pat);
|
||||
SimilarNamesNameVisitor(&mut visitor).visit_pat(&arg.pat);
|
||||
}
|
||||
// walk all other bindings
|
||||
walk_block(&mut visitor, blk);
|
||||
|
@ -195,7 +195,7 @@ fn check_pat(cx: &LateContext, pat: &Pat, init: &Option<&Expr>, span: Span, bind
|
||||
}
|
||||
}
|
||||
|
||||
fn lint_shadow<T>(cx: &LateContext, name: Name, span: Span, lspan: Span, init: &Option<T>, prev_span: Span)
|
||||
fn lint_shadow<T>(cx: &LateContext, name: Name, span: Span, pattern_span: Span, init: &Option<T>, prev_span: Span)
|
||||
where T: Deref<Target = Expr>
|
||||
{
|
||||
fn note_orig(cx: &LateContext, mut db: DiagnosticWrapper, lint: &'static Lint, span: Span) {
|
||||
@ -209,15 +209,15 @@ fn note_orig(cx: &LateContext, mut db: DiagnosticWrapper, lint: &'static Lint, s
|
||||
SHADOW_SAME,
|
||||
span,
|
||||
&format!("{} is shadowed by itself in {}",
|
||||
snippet(cx, lspan, "_"),
|
||||
snippet(cx, pattern_span, "_"),
|
||||
snippet(cx, expr.span, "..")));
|
||||
note_orig(cx, db, SHADOW_SAME, prev_span);
|
||||
} else if contains_self(name, expr) {
|
||||
let db = span_note_and_lint(cx,
|
||||
SHADOW_REUSE,
|
||||
lspan,
|
||||
pattern_span,
|
||||
&format!("{} is shadowed by {} which reuses the original value",
|
||||
snippet(cx, lspan, "_"),
|
||||
snippet(cx, pattern_span, "_"),
|
||||
snippet(cx, expr.span, "..")),
|
||||
expr.span,
|
||||
"initialization happens here");
|
||||
@ -225,9 +225,9 @@ fn note_orig(cx: &LateContext, mut db: DiagnosticWrapper, lint: &'static Lint, s
|
||||
} else {
|
||||
let db = span_note_and_lint(cx,
|
||||
SHADOW_UNRELATED,
|
||||
lspan,
|
||||
pattern_span,
|
||||
&format!("{} is shadowed by {}",
|
||||
snippet(cx, lspan, "_"),
|
||||
snippet(cx, pattern_span, "_"),
|
||||
snippet(cx, expr.span, "..")),
|
||||
expr.span,
|
||||
"initialization happens here");
|
||||
@ -238,7 +238,7 @@ fn note_orig(cx: &LateContext, mut db: DiagnosticWrapper, lint: &'static Lint, s
|
||||
let db = span_lint(cx,
|
||||
SHADOW_UNRELATED,
|
||||
span,
|
||||
&format!("{} shadows a previous declaration", snippet(cx, lspan, "_")));
|
||||
&format!("{} shadows a previous declaration", snippet(cx, pattern_span, "_")));
|
||||
note_orig(cx, db, SHADOW_UNRELATED, prev_span);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user