]> git.lizzy.rs Git - rust.git/blob - src/test/ui/macros/macro-pat-pattern-followed-by-or-in-2021.rs
Rollup merge of #87596 - jesyspa:issue-87318-hidden-whitespace, r=estebank
[rust.git] / src / test / ui / macros / macro-pat-pattern-followed-by-or-in-2021.rs
1 // edition:2021
2 #![allow(unused_macros)]
3 macro_rules! foo { ($x:pat | $y:pat) => {} } //~ ERROR `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
4 macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } //~ ERROR `$x:pat` is followed by `|`, which is not allowed for `pat` fragments
5 macro_rules! qux { ($x:pat, $y:pat) => {} } // should be ok
6 macro_rules! match_any {
7     ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { //~ ERROR `$pat:pat` may be followed by `|`, which is not allowed for `pat` fragments
8         match $expr {
9             $(
10                 $( $pat => $expr_arm, )+
11             )+
12         }
13     };
14 }
15
16 fn main() {
17     let result: Result<i64, i32> = Err(42);
18     let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
19     assert_eq!(int, 42);
20 }