rust/tests/ui/parser/macro/macro-expand-to-match-arm.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
538 B
Rust
Raw Normal View History

macro_rules! arm {
($pattern:pat => $block:block) => {
$pattern => $block
2023-11-26 20:15:56 -06:00
//~^ 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) => {},
2023-08-02 18:59:30 -05:00
arm!(None => {}),
2023-11-26 20:15:56 -06:00
//~^ NOTE caused by the macro expansion here
//~| ERROR `match` arm with no body
2023-07-24 12:05:10 -05:00
Some(2) => {},
_ => {},
};
}