]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/macro-pat2021-pattern-followed-by-or.rs
Auto merge of #106976 - tmiasko:borrowck-lazy-dominators, r=cjgillot
[rust.git] / tests / ui / macros / macro-pat2021-pattern-followed-by-or.rs
1 // edition:2021
2
3 #![allow(unused_macros)]
4 macro_rules! foo { ($x:pat | $y:pat) => {} } //~ ERROR `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
5 macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
6 macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
7 macro_rules! ogg { ($x:pat | $y:pat_param) => {} } //~ ERROR `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
8 macro_rules! match_any {
9     ( $expr:expr , $( $( $pat:pat)|+ => $expr_arm:pat),+ ) => { //~ ERROR  `$pat:pat` may be followed by `|`, which is not allowed for `pat` fragments
10         match $expr {
11             $(
12                 $( $pat => $expr_arm, )+
13             )+
14         }
15     };
16 }
17
18 fn main() {
19     let result: Result<i64, i32> = Err(42);
20     let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
21     assert_eq!(int, 42);
22 }