Skip to content

Commit 0aacf24

Browse files
committed
make suggestion text more legible
1 parent 10f1431 commit 0aacf24

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
19701970
{
19711971
if !ident_span.from_expansion() {
19721972
let (span, text) = match self.r.tcx.sess.source_map().span_to_snippet(ident_span) {
1973-
Ok(var_name) => {
1973+
Ok(var_name) if var_name.starts_with("let") => {
19741974
// a special case for #117894
19751975
let text = var_name.strip_prefix("let").and_then(|rest| {
19761976
match rest.starts_with("_") {

tests/ui/suggestions/suggest-let-for-assignment.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | demo = 1;
77
help: you might have meant to introduce a new binding
88
|
99
LL | let demo = 1;
10-
| ~~~~~~~~
10+
| +++
1111

1212
error[E0425]: cannot find value `demo` in this scope
1313
--> $DIR/suggest-let-for-assignment.rs:5:10
@@ -24,7 +24,7 @@ LL | x = "x";
2424
help: you might have meant to introduce a new binding
2525
|
2626
LL | let x = "x";
27-
| ~~~~~
27+
| +++
2828

2929
error[E0425]: cannot find value `x` in this scope
3030
--> $DIR/suggest-let-for-assignment.rs:8:23
@@ -81,7 +81,7 @@ LL | y = 1 + 2;
8181
help: you might have meant to introduce a new binding
8282
|
8383
LL | let y = 1 + 2;
84-
| ~~~~~
84+
| +++
8585

8686
error[E0425]: cannot find value `y` in this scope
8787
--> $DIR/suggest-let-for-assignment.rs:22:23

0 commit comments

Comments
 (0)