How much code does that proc macro generate?
10 months ago
- #Proc Macros
- #Rust
- #Compile Time
- Rust's proc macros have compile-time costs including compiling the proc macro crate, its dependencies, running proc macro invocations, and compiling generated code.
- A new tool, `-Zmacro-stats`, helps quantify the amount of code generated by proc macros and declarative macros.
- Example usage shows that some proc macros, like `serde::Deserialize`, generate significantly more code than others.
- The tool can identify heavy proc macros, leading to potential compile-time reductions by replacing or removing them.
- The tool is most useful for large codebases with extensive proc macro usage.