Open
Description
macro_rules! mac {
($expr:expr, $pat:pat) => {
match $expr {
$pat => {},
_ => panic!(),
}
};
}
fn main() {
mac!('a', ('a' | 'A'));
}
The current output is:
Compiling playground v0.0.1 (/playground)
warning: unnecessary parentheses around pattern
--> src/main.rs:12:15
|
12 | mac!('a', ('a' | 'A'));
| ^^^^^^^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
warning: 1 warning emitted
While it would be true that these parentheses are unnecessary in 2021 edition, (and also of course in the macro expanded output as well, which is why the warning occurs), they are required here in 2018 edition because :pat
cannot match 'a' | 'A'
in this edition, making the warning a nuisance.