I'm trying to write a macro which emits an enum definition. As part of this, I'd like to do something like:
enum Foo {
$(
__inner_normalize!($variant),
)*
}
Unfortunately, it looks like you can't use a macro invocation where a path AST node is expected. As a demonstration, the following code gives the following error:
error: no rules expected the token `!`
--> src/lib.rs:9:9
|
1 | macro_rules! foo {
| ---------------- when calling this macro
...
9 | foo!(bar!());
| ^ no rules expected this token in macro call
Is there any way around this limitation - to use a macro invocation in path position?
Also keep in mind the order of macro expansion - foo!(bar!()) will expand foo first, giving it the literal tokens bar!() as input. If and only if foo! retains the invocation of bar! in its output will bar! be run at all.