Skip to content
Opensource internals
  • Posts

Macros

Capturing Tokens by Replaying Them: rustc's Lazy Token Capture

Oct 21, 2026 6 min read Jay Hubbert

rustc’s parser captures macro tokens by recording a cursor snapshot plus a bump count and replaying them on demand, so tokens are materialised only for nodes that actually need …

RustInternalsCompilerParsingMacrosPerformance

Read more →

One Token, Two Operators: How rustc Splices a >> Back Apart

Oct 21, 2026 6 min read Jay Hubbert

rustc’s parser unglues compound tokens like » and »= on demand, with exact span surgery so that a proc macro sees the same bytes the source had.

RustInternalsCompilerParsingMacros

Read more →

macro_rules! Is an NFA: How Rust Matches Repetitions Without Backtracking

Oct 21, 2026 8 min read Jay Hubbert

The macro_rules! matcher in rustc is an NFA-based parser: a set of live matcher positions advances one input token at a time, with epsilon transitions for repetitions and no …

RustInternalsCompilerMacrosParsingAlgorithms

Read more →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·