Is it possible to evaluate inner macro before outer macro in proc macro?

For example, I wrote an attribute proc macro #[foo],
and it uses by the Rust code


#[foo]
stringify!(bar)

The handler of #[foo] see the token stream as stringify!(bar).

Is it possible to let the handler of #[foo] see the token stream of "bar" (The evaluation result of stringify!(bar))

The question is that if this is possible for a proc macro handler, to evaluate another macro,
then the handler acts based on the final evaluation result.

On nightly you could use proc_macro::TokenStream::expand_expr I reckon. Tracking issue can be found here.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.