Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 990ce1e

Browse files
authoredNov 14, 2024
Unrolled build for rust-lang#132996
Rollup merge of rust-lang#132996 - clubby789:unn-let-space, r=jieyouxu Trim extra space when suggesting removing bad `let` Fixes rust-lang#132969
2 parents 8adb4b3 + 1136bbf commit 990ce1e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed
 

‎compiler/rustc_parse/src/parser/pat.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,9 @@ impl<'a> Parser<'a> {
683683
})
684684
{
685685
self.bump();
686-
self.dcx().emit_err(RemoveLet { span: lo });
686+
// Trim extra space after the `let`
687+
let span = lo.with_hi(self.token.span.lo());
688+
self.dcx().emit_err(RemoveLet { span });
687689
lo = self.token.span;
688690
}
689691

‎tests/ui/parser/unnecessary-let.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ error: expected pattern, found `let`
22
--> $DIR/unnecessary-let.rs:2:9
33
|
44
LL | for let x of [1, 2, 3] {}
5-
| ^^^
5+
| ^^^^
66
|
77
help: remove the unnecessary `let` keyword
88
|
99
LL - for let x of [1, 2, 3] {}
10-
LL + for x of [1, 2, 3] {}
10+
LL + for x of [1, 2, 3] {}
1111
|
1212

1313
error: missing `in` in `for` loop
@@ -25,12 +25,12 @@ error: expected pattern, found `let`
2525
--> $DIR/unnecessary-let.rs:7:9
2626
|
2727
LL | let 1 => {}
28-
| ^^^
28+
| ^^^^
2929
|
3030
help: remove the unnecessary `let` keyword
3131
|
3232
LL - let 1 => {}
33-
LL + 1 => {}
33+
LL + 1 => {}
3434
|
3535

3636
error: aborting due to 3 previous errors

0 commit comments

Comments
 (0)
Failed to load comments.