Open
Description
The guide says right here:
Error: some fatal error has occurred in the parser. For example, this happens if there are more than one pattern match, since that indicates the macro is ambiguous.
This seems not to be the case.
macro_rules! times {
(a b) => (5000);
($x:ident b) => ($x * $x);
($x:ident $y:ident) => ($x * $y);
}
fn main() {
dbg!(times!(a b));
}
Output: 5000
Rust just chooses the first pattern that matches. In fact, you can use the exact same pattern twice and the Rust compiler won't complain.
macro_rules! times {
(a b) => (5000);
(a b) => (10000);
}
fn main() {
dbg!(times!(a b));
}
Output: 5000
Am I misunderstanding the description or is the description wrong?