a2dcb3a6d9
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.
21 lines
538 B
Rust
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) => {},
|
|
_ => {},
|
|
};
|
|
}
|