diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2019-10-14 17:52:42 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-14 17:52:42 -0700 |
| commit | 1b182371e1502a1a3a32c8335be40835f50db93a (patch) | |
| tree | 42d44aa7c0df30c59861eca54526a60737862c24 /src/test/ui/iterators/iter-sum-overflow-debug.rs | |
| parent | a14e35f382825549a506eb5c187fa5d58622bb1c (diff) | |
| parent | 16266a54058a71c943d064054bfe3a1b5704a444 (diff) | |
| download | rust-1b182371e1502a1a3a32c8335be40835f50db93a.tar.gz rust-1b182371e1502a1a3a32c8335be40835f50db93a.zip | |
Rollup merge of #65410 - Centril:intersection-pat-recover, r=davidtwco,varkor
syntax: add parser recovery for intersection- / and-patterns `p1 @ p2`
Fixes https://github.com/rust-lang/rust/issues/65400.
The recovery comes in two flavors:
1. We know that `p2` is a binding so we can invert as `p2 @ p1`:
```rust
error: pattern on wrong side of `@`
--> $DIR/intersection-patterns.rs:13:9
|
LL | Some(x) @ y => {}
| -------^^^-
| | |
| | binding on the right, should be to the left
| pattern on the left, should be to the right
| help: switch the order: `y @ Some(x)`
```
2. Otherwise we emit a generic diagnostic for the lack of support for intersection patterns:
```rust
error: left-hand side of `@` must be a binding
--> $DIR/intersection-patterns.rs:23:9
|
LL | Some(x) @ Some(y) => {}
| -------^^^-------
| | |
| | also a pattern
| interpreted as a pattern, not a binding
|
= note: bindings are `x`, `mut x`, `ref x`, and `ref mut x`
```
For more on and-patterns, see e.g. https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/pattern-matching#and-pattern.
r? @davidtwco
cc @varkor @lzutao
Diffstat (limited to 'src/test/ui/iterators/iter-sum-overflow-debug.rs')
0 files changed, 0 insertions, 0 deletions
