-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #64887 - Centril:recover-trailing-vert, r=estebank
syntax: recover trailing `|` in or-patterns Fixes #64879. For example (this also shows that we are sensitive to the typo `||`): ``` error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:33:11 | LL | A || => {} | - ^^ help: remove the `||` | | | while parsing this or-pattern starting here | = note: alternatives in or-patterns are separated with `|`, not `||` ``` r? @estebank
- Loading branch information
Showing
8 changed files
with
323 additions
and
37 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
15 changes: 15 additions & 0 deletions
15
src/test/ui/or-patterns/issue-64879-trailing-before-guard.rs
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,15 @@ | ||
// In this regression test we check that a trailing `|` in an or-pattern just | ||
// before the `if` token of a `match` guard will receive parser recovery with | ||
// an appropriate error message. | ||
|
||
enum E { A, B } | ||
|
||
fn main() { | ||
match E::A { | ||
E::A | | ||
E::B | //~ ERROR a trailing `|` is not allowed in an or-pattern | ||
if true => { | ||
let recovery_witness: bool = 0; //~ ERROR mismatched types | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/ui/or-patterns/issue-64879-trailing-before-guard.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: a trailing `|` is not allowed in an or-pattern | ||
--> $DIR/issue-64879-trailing-before-guard.rs:10:14 | ||
| | ||
LL | E::A | | ||
| ---- while parsing this or-pattern starting here | ||
LL | E::B | | ||
| ^ help: remove the `|` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-64879-trailing-before-guard.rs:12:42 | ||
| | ||
LL | let recovery_witness: bool = 0; | ||
| ^ expected bool, found integer | ||
| | ||
= note: expected type `bool` | ||
found type `{integer}` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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
Oops, something went wrong.