rust/tests/ui/parser/macro/macro-expand-to-match-arm.rs
Nadrieril a2dcb3a6d9 Disallow an arm without a body (except for never patterns)
Parsing now accepts a match arm without a body, so we must make sure to
only accept that if the pattern is a never pattern.
2023-12-03 12:25:46 +01:00

21 lines
538 B
Rust

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) => {},
_ => {},
};
}