Powerful Macros, Good IDE Support, No Headaches. Choose Two
summary
rust-analyzer models macro semantics by tracking token spans and mapping input tokens to expansion tokens so hovers, completions and highlighting resolve correctly; a single change — setting the span only on the block_on identifier in Tokio::main — removes noisy highlights and returns the expected hover, showing the approach works in practice. proc macros must avoid forking compilers or emitting hard errors, prefer recoverable parsing over syn bails, and avoid stringy module paths like in serde to preserve IDE features.
AI-written summary · about
chapters (10)
- 0:00Macros and IDE challenges
- 1:40Spans and hygiene in Rust
- 3:48Spans for diagnostics
- 5:55IDE token mapping
- 8:25Tokio macro span fix
- 15:12Proc macro pain points
- 19:46Proc macro caching limits
- 21:34Declarative macros limits
- 22:16Macro completions constraints
- 23:18IDE-friendly macro best practices
related talks
24mMacros for a More Productive Rust
29mMacromancy: an introduction to Rust macros
39mRust metaprogramming - macro_rules! beyond basics
27mParsing Rust code considered harmful
25m"Eternal Sunshine of the Rustfmt'ed Mind"
25mAre we *actually* IDE yet? A look on the Rust IDE Story
29mProcedural Macros vs Sliced Bread
18mImpractical Macros
