# rust-lang/rust architecture

> Architecture diagram of the GitHub repository rust-lang/rust, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rust-lang/rust
- Repository: https://github.com/rust-lang/rust
- Video tour (about a minute): https://gitdiagram.com/rust-lang/rust/video

## Overview

Rust’s repository contains the Rust compiler, standard library, documentation generator, and developer tools. The principal workflow is a developer submitting Rust source to rustc and receiving compiled output; the compiler’s tree also shows distinct parsing, lowering, type-checking, borrow-checking, and code-generation stages. The sampled files establish links within inference and trait solving, but do not expose the compiler’s top-level orchestration, so those broader workflow links are marked unverified. README capabilities such as rustdoc, rustfmt, Clippy, and rust-analyzer are included as product branches.

Main entry points: [`compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs`](https://github.com/rust-lang/rust/blob/main/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs) (Type Checking), [`compiler/rustc/src/main.rs`](https://github.com/rust-lang/rust/blob/main/compiler/rustc/src/main.rs) (rustc Driver), [`compiler/rustc_ast/src/ast.rs`](https://github.com/rust-lang/rust/blob/main/compiler/rustc_ast/src/ast.rs) (AST Parsing), [`compiler/rustc_ast_lowering/src/lib.rs`](https://github.com/rust-lang/rust/blob/main/compiler/rustc_ast_lowering/src/lib.rs) (AST Lowering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler"]
  node_rustc["rustc Driver<br/>[main.rs]"]
  node_ast["AST Parsing<br/>[ast.rs]"]
  node_lowering["AST Lowering<br/>[lib.rs]"]
  node_mir["MIR Transforms<br/>[pass_manager.rs]"]
  node_codegen["LLVM Codegen<br/>[base.rs]"]
end

subgraph group_analysis["Semantic Analysis"]
  node_typeck["Type Checking"]
  node_inference["Type Inference<br/>[mod.rs]"]
  node_traitsolve["Trait Solving<br/>[engine.rs]"]
  node_obligations["Obligation Engine<br/>[engine.rs]"]
  node_borrowck["Borrow Checking<br/>[lib.rs]"]
end

subgraph group_libraries["Runtime Libraries"]
  node_stdlib["Standard Library<br/>[lib.rs]"]
end

subgraph group_tools["Docs and Tools"]
  node_rustdoc["Rustdoc<br/>[lib.rs]"]
  node_rustfmt["Rustfmt<br/>[main.rs]"]
  node_clippy["Clippy"]
  node_analyzer["Rust Analyzer<br/>[storage.rs]"]
end

node_developer(("Developer"))
node_source["Rust Source"]
node_output["Compiled Program"]

node_developer -.->|"writes"| node_source
node_source -.->|"submits source"| node_rustc
node_rustc -.->|"parses"| node_ast
node_ast -.->|"lowers"| node_lowering
node_lowering -.->|"checks types"| node_typeck
node_typeck -.->|"uses inference"| node_inference
node_typeck -.->|"solves traits"| node_traitsolve
node_traitsolve -->|"registers obligations"| node_obligations
node_inference -->|"supports solving"| node_obligations
node_typeck -.->|"hands off analysis"| node_borrowck
node_borrowck -.->|"checks MIR"| node_mir
node_mir -.->|"provides MIR"| node_codegen
node_codegen -.->|"emits program"| node_output
node_rustc -.->|"uses library"| node_stdlib
node_developer -.->|"generates documentation"| node_rustdoc
node_developer -.->|"formats code"| node_rustfmt
node_developer -.->|"lints code"| node_clippy
node_developer -.->|"uses editor support"| node_analyzer

click node_rustc "https://github.com/rust-lang/rust/blob/main/compiler/rustc/src/main.rs"
click node_ast "https://github.com/rust-lang/rust/blob/main/compiler/rustc_ast/src/ast.rs"
click node_lowering "https://github.com/rust-lang/rust/blob/main/compiler/rustc_ast_lowering/src/lib.rs"
click node_typeck "https://github.com/rust-lang/rust/blob/main/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs"
click node_inference "https://github.com/rust-lang/rust/blob/main/compiler/rustc_infer/src/infer/mod.rs"
click node_traitsolve "https://github.com/rust-lang/rust/blob/main/compiler/rustc_trait_selection/src/traits/engine.rs"
click node_obligations "https://github.com/rust-lang/rust/blob/main/compiler/rustc_infer/src/traits/engine.rs"
click node_borrowck "https://github.com/rust-lang/rust/blob/main/compiler/rustc_borrowck/src/lib.rs"
click node_mir "https://github.com/rust-lang/rust/blob/main/compiler/rustc_mir_transform/src/pass_manager.rs"
click node_codegen "https://github.com/rust-lang/rust/blob/main/compiler/rustc_codegen_llvm/src/base.rs"
click node_stdlib "https://github.com/rust-lang/rust/blob/main/library/std/src/lib.rs"
click node_rustdoc "https://github.com/rust-lang/rust/blob/main/src/librustdoc/lib.rs"
click node_rustfmt "https://github.com/rust-lang/rust/blob/main/src/tools/rustfmt/src/bin/main.rs"
click node_analyzer "https://github.com/rust-lang/rust/blob/main/src/tools/rust-analyzer/crates/tt/src/storage.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rustc,node_ast,node_lowering,node_mir,node_codegen toneBlue
class node_typeck,node_inference,node_traitsolve,node_obligations,node_borrowck toneAmber
class node_stdlib toneMint
class node_rustdoc,node_rustfmt,node_clippy,node_analyzer toneRose
class node_developer,node_source,node_output toneIndigo
```

## Components

### Compiler

- [rustc Driver](https://github.com/rust-lang/rust/blob/main/compiler/rustc/src/main.rs): `compiler/rustc/src/main.rs`
- [AST Parsing](https://github.com/rust-lang/rust/blob/main/compiler/rustc_ast/src/ast.rs): `compiler/rustc_ast/src/ast.rs`
- [AST Lowering](https://github.com/rust-lang/rust/blob/main/compiler/rustc_ast_lowering/src/lib.rs): `compiler/rustc_ast_lowering/src/lib.rs`
- [MIR Transforms](https://github.com/rust-lang/rust/blob/main/compiler/rustc_mir_transform/src/pass_manager.rs): `compiler/rustc_mir_transform/src/pass_manager.rs`
- [LLVM Codegen](https://github.com/rust-lang/rust/blob/main/compiler/rustc_codegen_llvm/src/base.rs): `compiler/rustc_codegen_llvm/src/base.rs`

### Semantic Analysis

- [Type Checking](https://github.com/rust-lang/rust/blob/main/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs): `compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs`
- [Type Inference](https://github.com/rust-lang/rust/blob/main/compiler/rustc_infer/src/infer/mod.rs): `compiler/rustc_infer/src/infer/mod.rs`
- [Trait Solving](https://github.com/rust-lang/rust/blob/main/compiler/rustc_trait_selection/src/traits/engine.rs): `compiler/rustc_trait_selection/src/traits/engine.rs`
- [Obligation Engine](https://github.com/rust-lang/rust/blob/main/compiler/rustc_infer/src/traits/engine.rs): `compiler/rustc_infer/src/traits/engine.rs`
- [Borrow Checking](https://github.com/rust-lang/rust/blob/main/compiler/rustc_borrowck/src/lib.rs): `compiler/rustc_borrowck/src/lib.rs`

### Runtime Libraries

- [Standard Library](https://github.com/rust-lang/rust/blob/main/library/std/src/lib.rs): `library/std/src/lib.rs`

### Docs and Tools

- [Rustdoc](https://github.com/rust-lang/rust/blob/main/src/librustdoc/lib.rs): `src/librustdoc/lib.rs`
- [Rustfmt](https://github.com/rust-lang/rust/blob/main/src/tools/rustfmt/src/bin/main.rs): `src/tools/rustfmt/src/bin/main.rs`
- **Clippy**
- [Rust Analyzer](https://github.com/rust-lang/rust/blob/main/src/tools/rust-analyzer/crates/tt/src/storage.rs): `src/tools/rust-analyzer/crates/tt/src/storage.rs`

### Other components

- **Developer**
- **Rust Source**
- **Compiled Program**

## Connections

- Developer → Rust Source: writes
- Rust Source → rustc Driver: submits source
- rustc Driver → AST Parsing: parses
- AST Parsing → AST Lowering: lowers
- AST Lowering → Type Checking: checks types
- Type Checking → Type Inference: uses inference
- Type Checking → Trait Solving: solves traits
- Trait Solving → Obligation Engine: registers obligations (evidence: `compiler/rustc_trait_selection/src/traits/engine.rs`)
- Type Inference → Obligation Engine: supports solving (evidence: `compiler/rustc_infer/src/traits/engine.rs`)
- Type Checking → Borrow Checking: hands off analysis
- Borrow Checking → MIR Transforms: checks MIR
- MIR Transforms → LLVM Codegen: provides MIR
- LLVM Codegen → Compiled Program: emits program
- rustc Driver → Standard Library: uses library
- Developer → Rustdoc: generates documentation (evidence: `README.md`)
- Developer → Rustfmt: formats code (evidence: `README.md`)
- Developer → Clippy: lints code (evidence: `README.md`)
- Developer → Rust Analyzer: uses editor support (evidence: `README.md`)
