3 ms·
Rust macros actually work more at the token level than at the AST level.
by foldr 9y ago
Rust macros actually work more at the token level than at the AST level.
- navaati 9y agoOh I see, thx !
- RReverser 9y agoThey work on both - for example, if you specify $expr:expr, it will actually parse it as an expression node and won't allow to simply pass it into another macro as $pat:pat because of AST node type mismatch even if actual tokens are still compatible.
- foldr 9y agoThat's a good point. What I was trying to get at is that Rust macros don't let you manipulate ASTs in any straightforward way. So they are not best thought of as AST -> AST transforms.