Skip to content

Commit 9349441

Browse files
committed
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. 😄 changelog: Truncates multi-line RHS in shadow_unrelated message if it has more than 5 lines.
2 parents b3614b4 + a064045 commit 9349441

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

clippy_lints/src/shadow.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,7 @@ fn lint_shadow<'tcx>(
295295
cx,
296296
SHADOW_UNRELATED,
297297
pattern_span,
298-
&format!(
299-
"`{}` is shadowed by `{}`",
300-
snippet(cx, pattern_span, "_"),
301-
snippet(cx, expr.span, "..")
302-
),
298+
&format!("`{}` is being shadowed", snippet(cx, pattern_span, "_")),
303299
|diag| {
304300
diag.span_note(expr.span, "initialization happens here");
305301
diag.span_note(prev_span, "previous binding is here");

tests/ui/shadow.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ note: previous binding is here
104104
LL | let x = (1, x);
105105
| ^
106106

107-
error: `x` is shadowed by `y`
107+
error: `x` is being shadowed
108108
--> $DIR/shadow.rs:34:9
109109
|
110110
LL | let x = y;

0 commit comments

Comments
 (0)