A Daft proc-macro trick: How to Emit Partial-Code + Errors

· Richard Schneeman · March 26, 2025, 6:32 p.m.
Summary
This blog post discusses a novel technique in Rust macros, specifically the Daft proc macro's approach to emitting both code and errors. It explains why this is important for tools like rust-analyzer, the mechanics of emitting tokens, and best practices for accumulating errors. The author shares insights from personal experience while working on the Ruby Cloud Native Buildpack and suggests that while emitting code with errors isn't critical for all macros, accumulating errors is essential for a smoother developer experience.
AUTHOR
Sponsored
Zulip logo Zulip
Organized team chat for people who take work seriously. Topic-based threading keeps conversations focused.
Try Zulip
Become a sponsor →
BLOG POST FEATURED ON

Add this plugin to your blog