---
# System prepended metadata

title: rust-analyzer overview
tags: ['2021-10-18']

---

---
tags: "2021-10-18"
---

# rust-analyzer overview

---

## History

---

### Started out as an error-resilient parser

---

### Few years later [RFC2912](https://github.com/rust-lang/rfcs/pull/2912), transition to r-a as the official LSP implementation, was filed

---

## Implementation Details <!-- differences between r-a and rls -->

---

 - `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 <!-- most advanced piece of code in terms of analyzing semantics, not used as much as a lot of themes just do not support it/needs special theme support for specific language parts -->
![](https://i.imgur.com/M03ClkM.png)

---

### Inlay Hints <!-- fan favourite, VSCode hacked in via decorators, native api now exists -->

![](https://i.imgur.com/YJ0H9iX.png)

---

### Procedural-Macro and Attribute support <!-- Note how everything resolves even in the helper attributes thanks to spans -->

![](https://i.imgur.com/XORwyNd.png)

---

## 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 <!-- what's it liek to contribute -->

---

 - architecture docs and videos, style guide <!-- compare to rustc dev 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 <!-- simpler to build, no changes required when features change, not everyone has a nightly compiler, mention stdx? -->
     - No compiler internals -> easier to reuse
 - low entry bar, just cargo
     - `git clone` -> `cargo test`
 - merge PRs optimistically, refactor later <!-- faster merging, less likely to have the PR become stale due to inactivity -->
 - 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 <!-- one of the bigger fish to fry, so a next long term goal -->
- tracking issue [r-a#8655](https://github.com/rust-analyzer/rust-analyzer/issues/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` 
