Proving macro expansion with expandable
summary
Claim: expandable proves a declarative macro always expands to syntactically valid Rust by converting macro transcribers into state machines then into a custom VM parser. It ships as the crate "expandable" and runs via an attribute macro on a macro definition, finds real errors like using -> instead of . and emits helpful diagnostics. Current limits include a partial parser, trouble with recursive macros and macro rulesetion generation, but the prototype works end to end.
AI-written summary · about
chapters (12)
- 0:00Proving macro expansion
- 1:25Declarative macros in Rust
- 3:12Macro implementation example
- 5:22Macros need validation tools
- 7:30Defining valid macro expansion
- 8:36Language theory for macro validation
- 10:01Algorithm for macro validation
- 15:11Building interruptable parser
- 16:57Parser implementation approaches
- 18:00Demo of expandable crate
- 19:28Limitations of expandable
- 20:51Summary
related talks
29mMacromancy: an introduction to Rust macros
39mRust metaprogramming - macro_rules! beyond basics
24mMacros for a More Productive Rust
27mParsing Rust code considered harmful
18mImpractical Macros
31mFunctional programming guerilla in the land of Rust
25m"Eternal Sunshine of the Rustfmt'ed Mind"
29mProcedural Macros vs Sliced Bread
