mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
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.
This commit is contained in:
commit
9349441863
@ -295,11 +295,7 @@ fn lint_shadow<'tcx>(
|
|||||||
cx,
|
cx,
|
||||||
SHADOW_UNRELATED,
|
SHADOW_UNRELATED,
|
||||||
pattern_span,
|
pattern_span,
|
||||||
&format!(
|
&format!("`{}` is being shadowed", snippet(cx, pattern_span, "_")),
|
||||||
"`{}` is shadowed by `{}`",
|
|
||||||
snippet(cx, pattern_span, "_"),
|
|
||||||
snippet(cx, expr.span, "..")
|
|
||||||
),
|
|
||||||
|diag| {
|
|diag| {
|
||||||
diag.span_note(expr.span, "initialization happens here");
|
diag.span_note(expr.span, "initialization happens here");
|
||||||
diag.span_note(prev_span, "previous binding is here");
|
diag.span_note(prev_span, "previous binding is here");
|
||||||
|
@ -104,7 +104,7 @@ note: previous binding is here
|
|||||||
LL | let x = (1, x);
|
LL | let x = (1, x);
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `x` is shadowed by `y`
|
error: `x` is being shadowed
|
||||||
--> $DIR/shadow.rs:34:9
|
--> $DIR/shadow.rs:34:9
|
||||||
|
|
|
|
||||||
LL | let x = y;
|
LL | let x = y;
|
||||||
|
Loading…
Reference in New Issue
Block a user