rust-analyzer overview


History


Started out as an error-resilient parser


Few years later RFC2912, transition to r-a as the official LSP implementation, was filed


Implementation Details


  • ungrammar for concrete syntax tree definitions
  • rowan for syntax trees, inspired by Roslyn, Swift's libsyntax
  • lexer shared with rustc
  • handwritten recursive-descent parser, different needs
    • low latency incremental reparses
    • Concrete Syntax Tree

  • salsa, similar to rustc's query system
  • chalk for trait solving

Big Milestones


Semantic Highlighting

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’


Inlay Hints

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’


Procedural-Macro and Attribute support

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’


Current Shortcomings


  • no as-you-type error checking
    • need to run cargo check to get most errors and lints
  • no persistent state
    • new session takes time to index dependencies
  • completion slower than we would like
  • proc-macro ABI is unstable

Type System

  • type inference does not always agree with rustc
  • missing const generics support
  • missing lifetime generics support
    • 'static all the things

Contributor Experience


  • architecture docs and videos, style guide
  • point out style guide/architecture doc entries in PR reviews
    • Reduces need to write lengthy reviews for repeating problems
  • don't bother with clippy
    • defaults are subjectively questionable

Workflow differences from rust-lang


  • builds with and targets latest stable Rust
    • No compiler internals -> easier to reuse
  • low entry bar, just cargo
    • git clone -> cargo test
  • merge PRs optimistically, refactor later
  • it's okay for team members to self-approve PRs
  • no auto assigned reviewers
    • causes some PRs to not get reviewed for a long time

Meetings


  • weekly sync meeting
    • what has happened the past week
  • every 6 weeks steering meeting
    • plan ahead for the next 6 weeks

Showcase


  • @HKalbasi's WASM demos
    • Monaco/Playground integration
    • Mdbook hover hints for rust snippets
  • cargo-modules
    • A cargo plugin for showing an overview of a crate's modules.
  • evcxr
    • A Jupyter kernel and REPL
  • โ€ฆ

What's Next


Better const generics support

  • tracking issue r-a#8655
  • lots of work yet to be done

Librarification of rustc's exhaustiveness checking

  • so we can replace our sometimes incorrect copy

A request for Procedural (Attribute) Macro authors

  • Try to recover on parse errors, don't just discard the input and emit a compile_error!
  • Consider not using syn unless it is really required
  • Or explore an infallible alternative to syn