Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

rust-analyzer: Orientation

Language serverIncremental computationRevision 2d6e364

rust-analyzer keeps an in-memory model of Rust code responsive while files, project structure, compiler output, and editor requests change continuously. Its architectural center is a mutable coordinator that applies input changes and hands immutable analysis snapshots to cancellable worker computations.

LSP/VFS/Cargo events → main loop → GlobalState → AnalysisHost/Salsa inputs
                                      ↓ snapshot
                                worker request
                                      ↓
                              Task::Response → main loop → LSP

new input → new Salsa revision → old computations cancel/unwind

Design thesis

rust-analyzer serializes changes to ground truth in one coordinator while lending immutable database revisions to parallel, cancellable computations that derive only what the current editor request demands.

  • Salsa snapshots give workers a coherent read world.
  • New input cancels CPU work whose answer would already be stale.
  • Memoized dependency graphs preserve unaffected computation.
  • Process isolation contains proc-macro crashes and unstable compiler code.

The reconstruction preserves lossless parsing, a VFS/input boundary, incremental memoized queries, immutable snapshots, serial mutation, background read requests, revision cancellation, latency classes, and subprocess isolation.