forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix rust-lang#100825.
- Loading branch information
Showing
5 changed files
with
132 additions
and
47 deletions.
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
28 changes: 24 additions & 4 deletions
28
tests/ui/parser/recover/recover-parens-around-match-arm-head.stderr
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 |
---|---|---|
@@ -1,8 +1,28 @@ | ||
error: expected one of `)`, `,`, `...`, `..=`, `..`, or `|`, found keyword `if` | ||
--> $DIR/recover-parens-around-match-arm-head.rs:4:12 | ||
error: unexpected parentheses surrounding `match` arm pattern | ||
--> $DIR/recover-parens-around-match-arm-head.rs:4:9 | ||
| | ||
LL | (0 if true) => { | ||
| ^^ expected one of `)`, `,`, `...`, `..=`, `..`, or `|` | ||
| ^ ^ | ||
| | ||
help: remove parentheses surrounding the pattern | ||
| | ||
LL - (0 if true) => { | ||
LL + 0 if true => { | ||
| | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/recover-parens-around-match-arm-head.rs:10:19 | ||
| | ||
LL | let _y: u32 = x; | ||
| --- ^ expected `u32`, found `u8` | ||
| | | ||
| expected due to this | ||
| | ||
help: you can convert a `u8` to a `u32` | ||
| | ||
LL | let _y: u32 = x.into(); | ||
| +++++++ | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |