Skip to content

Commit

Permalink
Rollup merge of #132996 - clubby789:unn-let-space, r=jieyouxu
Browse files Browse the repository at this point in the history
Trim extra space when suggesting removing bad `let`

Fixes #132969
  • Loading branch information
matthiaskrgr authored Nov 13, 2024
2 parents a1923b3 + 1136bbf commit e6b3a55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,9 @@ impl<'a> Parser<'a> {
})
{
self.bump();
self.dcx().emit_err(RemoveLet { span: lo });
// Trim extra space after the `let`
let span = lo.with_hi(self.token.span.lo());
self.dcx().emit_err(RemoveLet { span });
lo = self.token.span;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/parser/unnecessary-let.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ error: expected pattern, found `let`
--> $DIR/unnecessary-let.rs:2:9
|
LL | for let x of [1, 2, 3] {}
| ^^^
| ^^^^
|
help: remove the unnecessary `let` keyword
|
LL - for let x of [1, 2, 3] {}
LL + for x of [1, 2, 3] {}
LL + for x of [1, 2, 3] {}
|

error: missing `in` in `for` loop
Expand All @@ -25,12 +25,12 @@ error: expected pattern, found `let`
--> $DIR/unnecessary-let.rs:7:9
|
LL | let 1 => {}
| ^^^
| ^^^^
|
help: remove the unnecessary `let` keyword
|
LL - let 1 => {}
LL + 1 => {}
LL + 1 => {}
|

error: aborting due to 3 previous errors
Expand Down

0 comments on commit e6b3a55

Please sign in to comment.