Apr 2026
13 Mon
14 Tue
15 Wed
16 Thu
17 Fri
18 Sat 09:00 AM – 06:00 PM IST
19 Sun 09:00 AM – 06:00 PM IST
Submitted Mar 18, 2026
Procedural macros in Rust enable developers to extend the language by writing code that runs during compilation to generate other Rust code. In other words, they consume an AST to produce another AST. Unlike declarative macros based on pattern matching, procedural macros operate on token streams and can perform transformations before the compiler proceeds. This makes them useful for reducing boilerplate and building abstractions in areas such as serialization, error handling, and domain specific languages.
This talk focuses on how these macros are implemented and what happens behind the scenes during compilation. We walk through the full lifecycle of a procedural macro, from receiving raw tokens to parsing them into structured representations, transforming them, and emitting new code back to the compiler using libraries such as syn and quote. Along the way, we examine important challenges including macro hygiene, limitations due to lack of type information, debugging expanded code, and the impact on compile time performance. We also introduce the different forms of procedural macros, function-like, derive, and attribute macros, and explore how each of them is used to shape real world Rust codebases such as tokio and serde.
macro_rules! can express.macro_rules!, and curious about more advanced language features.Hosted by
{{ gettext('Login to leave a comment') }}
{{ gettext('Post a comment…') }}{{ errorMsg }}
{{ gettext('No comments posted yet') }}