I'm having a problem that that has to do with using a macro invocation as an argument to a separate proc-macro where it expects a literal
token. The specific macro I'm dealing with is include_spirv
from https://github.com/PENGUINLIONG/inline-spirv-rs, but I think this issue I'm facing can be generalized with this example:
// suppose I have a macro_rules or proc-macro from another crate like this
macro_rules! outer {
($inner:literal) => {$inner}
}
// and I want to invoke it like this, using a macro like concat that expands into a literal
dbg!(outer!(concat!("inner")));
However, I get the error:
Compiling playground v0.0.1 (/playground)
error: no rules expected the token `concat`
--> src/main.rs:27:13
|
23 | macro_rules! outer {
| ------------------ when calling this macro
...
27 | dbg!(outer!(concat!("inner")));
| ^^^^^^ no rules expected this token in macro call
error: aborting due to previous error
error: could not compile `playground`
To learn more, run the command again with --verbose.
It looks like this is because rust lazily evaluates it's macros. Is there some trickery I can do to eagerly evaluate the inner macro first, so that this will work?