From f004120495b51c925fa72156b69ebd97f011b061 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 11 May 2016 16:45:06 +0200 Subject: [PATCH] properly lint function argument patterns in similar_names --- src/non_expressive_names.rs | 2 +- src/shadow.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/non_expressive_names.rs b/src/non_expressive_names.rs index e8f3858a37b..cbb083a3e16 100644 --- a/src/non_expressive_names.rs +++ b/src/non_expressive_names.rs @@ -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); diff --git a/src/shadow.rs b/src/shadow.rs index 4b6439c4eb3..4639a943965 100644 --- a/src/shadow.rs +++ b/src/shadow.rs @@ -195,7 +195,7 @@ fn check_pat(cx: &LateContext, pat: &Pat, init: &Option<&Expr>, span: Span, bind } } -fn lint_shadow(cx: &LateContext, name: Name, span: Span, lspan: Span, init: &Option, prev_span: Span) +fn lint_shadow(cx: &LateContext, name: Name, span: Span, pattern_span: Span, init: &Option, prev_span: Span) where T: Deref { 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); } } -- 2.44.0