forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#101362 - compiler-errors:unnecessary-let, r=c…
…jgillot Suggest removing unnecessary prefix let in patterns Helps with rust-lang#101291, though I think `@estebank` probably wants this: > Finally, I think it'd be nice if we could detect that we don't know for sure and "just" swallow the rest of the expression (find the next ; accounting for nested braces) or the end of the item (easier). ... to be implemented before we close that issue out completely.
- Loading branch information
Showing
6 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fn main() { | ||
for let x of [1, 2, 3] {} | ||
//~^ ERROR expected pattern, found `let` | ||
//~| ERROR missing `in` in `for` loop | ||
|
||
match 1 { | ||
let 1 => {} | ||
//~^ ERROR expected pattern, found `let` | ||
_ => {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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 | ||
|
||
error: missing `in` in `for` loop | ||
--> $DIR/unnecessary-let.rs:2:15 | ||
| | ||
LL | for let x of [1, 2, 3] {} | ||
| ^^ help: try using `in` here instead | ||
|
||
error: expected pattern, found `let` | ||
--> $DIR/unnecessary-let.rs:7:9 | ||
| | ||
LL | let 1 => {} | ||
| ^^^ help: remove the unnecessary `let` keyword | ||
|
||
error: aborting due to 3 previous errors | ||
|