Skip to content

Commit

Permalink
Auto merge of rust-lang#5788 - Leulz:shadow-unrelated-fix-rhs, r=flip…
Browse files Browse the repository at this point in the history
…1995

Removing RHS snippet from SHADOW_UNRELATED message.

Fixes rust-lang#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. 😄

changelog: Truncates multi-line RHS in shadow_unrelated message if it has more than 5 lines.
  • Loading branch information
bors committed Jul 15, 2020
2 parents b3614b4 + a064045 commit 9349441
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions clippy_lints/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/shadow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9349441

Please sign in to comment.