]> git.lizzy.rs Git - rust.git/blob - tests/ui/parser/intersection-patterns-1.fixed
Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into sync_cg_clif-2023-01-24
[rust.git] / tests / ui / parser / intersection-patterns-1.fixed
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
9 // run-rustfix
10
11 #![allow(unused_variables)]
12
13 fn main() {
14     let s: Option<u8> = None;
15
16     match s {
17         y @ Some(x) => {}
18         //~^ ERROR pattern on wrong side of `@`
19         //~| pattern on the left, should be on the right
20         //~| binding on the right, should be on the left
21         //~| HELP switch the order
22         //~| SUGGESTION y @ Some(x)
23         _ => {}
24     }
25
26     match 2 {
27         e @ 1..=5 => {}
28         //~^ ERROR pattern on wrong side of `@`
29         //~| pattern on the left, should be on the right
30         //~| binding on the right, should be on the left
31         //~| HELP switch the order
32         //~| SUGGESTION e @ 1..=5
33         _ => {}
34     }
35 }