In rustc, eager expansion is implemented with a single line of code:
let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr();
In rust-analyzer, a comparatively huge amount of infrastructure seems to be responsible for handling eager macros. Is that a necessary consequence of doing it in a query-driven way, or is this complexity accidental and could be reduced?
Yeah, it's true that, overall, "eager macros are tricky". Our current impl is not in cache for me though it's quite likely we can simplify it substantionally.
IIRC, we just encode the whole of macro argument into macro ID for eager expansion.