]> git.proxmox.com Git - rustc.git/blame - src/test/ui/parser/intersection-patterns.rs
New upstream version 1.59.0+dfsg1
[rustc.git] / src / test / ui / parser / intersection-patterns.rs
CommitLineData
e74abb32
XL
1// This tests the parser recovery in `recover_intersection_pat`
2// and serves as a regression test for the diagnostics issue #65400.
3//
4// The general idea is that for `$pat_lhs @ $pat_rhs` where
5// `$pat_lhs` is not generated by `ref? mut? $ident` we want
6// to suggest either switching the order or note that intersection
7// patterns are not allowed.
8
9fn main() {
10 let s: Option<u8> = None;
11
12 match s {
13 Some(x) @ y => {}
14 //~^ ERROR pattern on wrong side of `@`
15 //~| pattern on the left, should be on the right
16 //~| binding on the right, should be on the left
17 //~| HELP switch the order
18 //~| SUGGESTION y @ Some(x)
19 _ => {}
20 }
21
22 match s {
23 Some(x) @ Some(y) => {}
24 //~^ ERROR left-hand side of `@` must be a binding
25 //~| interpreted as a pattern, not a binding
26 //~| also a pattern
27 //~| NOTE bindings are `x`, `mut x`, `ref x`, and `ref mut x`
28 _ => {}
29 }
30
31 match 2 {
32 1 ..= 5 @ e => {}
33 //~^ ERROR pattern on wrong side of `@`
34 //~| pattern on the left, should be on the right
35 //~| binding on the right, should be on the left
36 //~| HELP switch the order
a2a8927a 37 //~| SUGGESTION e @ 1..=5
e74abb32
XL
38 _ => {}
39 }
40}