summaryrefslogtreecommitdiffstats
path: root/tests/ui/parser/macro/macro-expand-to-match-arm.rs
blob: db38fa0d7bc6558762fff73e3b7208131ba628d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
macro_rules! arm {
    ($pattern:pat => $block:block) => {
        $pattern => $block
        //~^ ERROR macro expansion ignores token `=>` and any following
        //~| NOTE the usage of `arm!` is likely invalid in pattern context
        //~| NOTE macros cannot expand to match arms
    };
}

fn main() {
    let x = Some(1);
    match x {
        Some(1) => {},
        arm!(None => {}),
        //~^ NOTE caused by the macro expansion here
        //~| ERROR `match` arm with no body
        Some(2) => {},
        _ => {},
    };
}