fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.5 KiB39 linesraw
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]
8extern crate or_pattern;
9
10macro_rules! foo { ($x:pat_param | $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
13macro_rules! bar { ($($x:pat_param)+ | $($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
17macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
18macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
19macro_rules! ogg { ($x:pat_param | $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
22macro_rules! match_any {
23    ( $expr:expr , $( $( $pat:pat_param )|+ => $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
34fn 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}