A macro_rules! macro with two cases that match _ and ident might not match _ depending on the order of the cases. This works:
macro_rules! foo {
(_) => {};
($a:ident) => {};
}
fn main() {
foo!(_);
}
But this doesn't:
macro_rules! foo {
($a:ident) => {};
(_) => {};
}
fn main() {
foo!(_);
}
...giving the error message:
rustc 1.17.0-nightly (306035c21 2017-02-18)
error: expected ident, found _
--> <anon>:8:10
|
8 | foo!(_);
| ^
Why would it expect an ident there? If _ isn't an ident, shouldn't it just move on to the second macro case and match that?
A
macro_rules!macro with two cases that match_andidentmight not match_depending on the order of the cases. This works:But this doesn't:
...giving the error message:
Why would it expect an
identthere? If_isn't anident, shouldn't it just move on to the second macro case and match that?