1 // run-rustfix
2 // aux-build:or-pattern.rs
3 
4 #![deny(rust_2021_incompatible_or_patterns)]
5 #![allow(unused_macros)]
6 
7 #[macro_use]
8 extern crate or_pattern;
9 
10 macro_rules! foo { ($x:pat | $y:pat) => {} }
11 //~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
12 //~| WARN this is accepted in the current edition
13 macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} }
14 //~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
15 //~| WARN this is accepted in the current edition
16 
17 macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
18 macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
19 macro_rules! ogg { ($x:pat | $y:pat_param) => {} }
20 //~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
21 //~| WARN this is accepted in the current edition
22 macro_rules! match_any {
23     ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
24         //~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
25         //~| WARN this is accepted in the current edition
26         match $expr {
27             $(
28                 $( $pat => $expr_arm, )+
29             )+
30         }
31     };
32 }
33 
main()34 fn main() {
35     let result: Result<i64, i32> = Err(42);
36     let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
37     assert_eq!(int, 42);
38     a!(1|);
39 }
40