about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-07-15 19:09:21 +0000
committerbors <bors@rust-lang.org>2020-07-15 19:09:21 +0000
commit934944186366959b53df5948b25b1cfabd6c71d3 (patch)
tree1e5dcc8164e7a8d31dae67751ee521f97d775fb5
parentb3614b42d506d1707379cc978f41931f1872273f (diff)
parenta0640457a912720a5473d7feff40576a2f97df1e (diff)
downloadrust-934944186366959b53df5948b25b1cfabd6c71d3.tar.gz
rust-934944186366959b53df5948b25b1cfabd6c71d3.zip
Auto merge of #5788 - Leulz:shadow-unrelated-fix-rhs, r=flip1995
Removing RHS snippet from SHADOW_UNRELATED message.

Fixes #5703

I am not sure if I reinvented the wheel here, but I could not really find a snippet function that did this truncation, so I created the function. Please tell me if there was a more obvious way to do this, I am new here. :smile:

changelog: Truncates multi-line RHS in shadow_unrelated message if it has more than 5 lines.
-rw-r--r--clippy_lints/src/shadow.rs6
-rw-r--r--tests/ui/shadow.stderr2
2 files changed, 2 insertions, 6 deletions
diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs
index 194786c5c41..fab13c8c124 100644
--- a/clippy_lints/src/shadow.rs
+++ b/clippy_lints/src/shadow.rs
@@ -295,11 +295,7 @@ fn lint_shadow<'tcx>(
                 cx,
                 SHADOW_UNRELATED,
                 pattern_span,
-                &format!(
-                    "`{}` is shadowed by `{}`",
-                    snippet(cx, pattern_span, "_"),
-                    snippet(cx, expr.span, "..")
-                ),
+                &format!("`{}` is being shadowed", snippet(cx, pattern_span, "_")),
                 |diag| {
                     diag.span_note(expr.span, "initialization happens here");
                     diag.span_note(prev_span, "previous binding is here");
diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr
index 7fa58cf7649..8a831375b41 100644
--- a/tests/ui/shadow.stderr
+++ b/tests/ui/shadow.stderr
@@ -104,7 +104,7 @@ note: previous binding is here
 LL |     let x = (1, x);
    |         ^
 
-error: `x` is shadowed by `y`
+error: `x` is being shadowed
   --> $DIR/shadow.rs:34:9
    |
 LL |     let x = y;