Skip to content

Commit 269b5f0

Browse files
mark-i-mJohnTitorchrissimpkins
authored
Reorganize the guide (#651)
* start on guide reorg * backend intro * part 2, 3, 4 intros * some missing files * Fix typos Co-Authored-By: Yuki Okushi <huyuumi.dev@gmail.com> Co-Authored-By: Chris Simpkins <git.simpkins@gmail.com> * add links from intro * rename compiler source chapter and add placeholder for overview * rename parts, mv rustc_driver to part 3, make syntax chapter * update part intros * add syntax ch intro * address review comments * Better overview chapter placeholder Co-Authored-By: Chris Simpkins <git.simpkins@gmail.com> * fix link Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com> Co-authored-by: Chris Simpkins <git.simpkins@gmail.com>
1 parent c33f0c6 commit 269b5f0

13 files changed

+139
-60
lines changed

src/SUMMARY.md

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@
3333
- ["Cleanup Crew" ICE-breakers](ice-breaker/cleanup-crew.md)
3434
- [LLVM ICE-breakers](ice-breaker/llvm.md)
3535
- [Licenses](./licenses.md)
36-
- [Part 2: How rustc works](./part-2-intro.md)
37-
- [High-level overview of the compiler source](./high-level-overview.md)
38-
- [The Rustc Driver and Interface](./rustc-driver.md)
39-
- [Rustdoc](./rustdoc.md)
40-
- [Ex: Type checking through `rustc_interface`](./rustc-driver-interacting-with-the-ast.md)
36+
37+
- [Part 2: High-level Compiler Architecture](./part-2-intro.md)
38+
- [Overview of the Compiler](./overview.md)
39+
- [The compiler source code](./compiler-src.md)
4140
- [Queries: demand-driven compilation](./query.md)
4241
- [The Query Evaluation Model in Detail](./queries/query-evaluation-model-in-detail.md)
4342
- [Incremental compilation](./queries/incremental-compilation.md)
@@ -46,15 +45,29 @@
4645
- [Profiling Queries](./queries/profiling.md)
4746
- [Salsa](./salsa.md)
4847
- [Memory Management in Rustc](./memory.md)
49-
- [Lexing and Parsing](./the-parser.md)
50-
- [`#[test]` Implementation](./test-implementation.md)
51-
- [Panic Implementation](./panic-implementation.md)
52-
- [Macro expansion](./macro-expansion.md)
53-
- [Name resolution](./name-resolution.md)
48+
49+
- [Part 3: Source Code Representations](./part-3-intro.md)
50+
- [The Rustc Driver and Interface](./rustc-driver.md)
51+
- [Rustdoc](./rustdoc.md)
52+
- [Ex: Type checking through `rustc_interface`](./rustc-driver-interacting-with-the-ast.md)
53+
- [Syntax and the AST](./syntax-intro.md)
54+
- [Lexing and Parsing](./the-parser.md)
55+
- [`#[test]` Implementation](./test-implementation.md)
56+
- [Panic Implementation](./panic-implementation.md)
57+
- [Macro expansion](./macro-expansion.md)
58+
- [Name resolution](./name-resolution.md)
59+
- [AST Validation](./ast-validation.md)
60+
- [Feature Gate Checking](./feature-gate-ck.md)
5461
- [The HIR (High-level IR)](./hir.md)
5562
- [Lowering AST to HIR](./lowering.md)
5663
- [Debugging](./hir-debugging.md)
64+
- [The MIR (Mid-level IR)](./mir/index.md)
65+
- [HAIR and MIR construction](./mir/construction.md)
66+
- [MIR visitor and traversal](./mir/visitor.md)
67+
- [MIR passes: getting the MIR for a function](./mir/passes.md)
5768
- [Closure expansion](./closure.md)
69+
70+
- [Part 4: Analysis](./part-4-intro.md)
5871
- [The `ty` module: representing types](./ty.md)
5972
- [Generics and substitutions](./generics.md)
6073
- [`TypeFolder` and `TypeFoldable`](./ty-fold.md)
@@ -82,12 +95,7 @@
8295
- [Method Lookup](./method-lookup.md)
8396
- [Variance](./variance.md)
8497
- [Opaque Types](./opaque-types-type-alias-impl-trait.md)
85-
- [The MIR (Mid-level IR)](./mir/index.md)
86-
- [MIR construction](./mir/construction.md)
87-
- [MIR visitor and traversal](./mir/visitor.md)
88-
- [MIR passes: getting the MIR for a function](./mir/passes.md)
89-
- [MIR optimizations](./mir/optimizations.md)
90-
- [Debugging](./mir/debugging.md)
98+
- [Pattern and Exhaustiveness Checking](./pat-exhaustive-checking.md)
9199
- [The borrow checker](./borrow_check.md)
92100
- [Tracking moves and initialization](./borrow_check/moves_and_initialization.md)
93101
- [Move paths](./borrow_check/moves_and_initialization/move_paths.md)
@@ -100,20 +108,24 @@
100108
- [Closure constraints](./borrow_check/region_inference/closure_constraints.md)
101109
- [Error reporting](./borrow_check/region_inference/error_reporting.md)
102110
- [Two-phase-borrows](./borrow_check/two_phase_borrows.md)
111+
- [Parameter Environments](./param_env.md)
112+
113+
- [Part 5: From MIR to binaries](./part-5-intro.md)
114+
- [The MIR (Mid-level IR)](./mir/index.md)
115+
- [MIR optimizations](./mir/optimizations.md)
116+
- [Debugging](./mir/debugging.md)
103117
- [Constant evaluation](./const-eval.md)
104118
- [miri const evaluator](./miri.md)
105-
- [Parameter Environments](./param_env.md)
106-
- [Compiler Backend](./backend/backend.md)
107-
- [Monomorphization](./backend/monomorph.md)
108-
- [Lowering MIR](./backend/lowering-mir.md)
109-
- [Code Generation](./backend/codegen.md)
110-
- [Updating LLVM](./backend/updating-llvm.md)
111-
- [Debugging LLVM](./backend/debugging.md)
112-
- [Backend Agnostic Codegen](./backend/backend-agnostic.md)
113-
- [Implicit Caller Location](./codegen/implicit-caller-location.md)
114-
- [Profile-guided Optimization](./profile-guided-optimization.md)
115-
- [Sanitizers Support](./sanitizers.md)
116-
- [Debugging Support in Rust Compiler](./debugging-support-in-rustc.md)
119+
- [Monomorphization](./backend/monomorph.md)
120+
- [Lowering MIR](./backend/lowering-mir.md)
121+
- [Code Generation](./backend/codegen.md)
122+
- [Updating LLVM](./backend/updating-llvm.md)
123+
- [Debugging LLVM](./backend/debugging.md)
124+
- [Backend Agnostic Codegen](./backend/backend-agnostic.md)
125+
- [Implicit Caller Location](./codegen/implicit-caller-location.md)
126+
- [Profile-guided Optimization](./profile-guided-optimization.md)
127+
- [Sanitizers Support](./sanitizers.md)
128+
- [Debugging Support in Rust Compiler](./debugging-support-in-rustc.md)
117129

118130
---
119131

src/about-this-guide.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22

33
This guide is meant to help document how rustc – the Rust compiler –
44
works, as well as to help new contributors get involved in rustc
5-
development. It is not meant to replace code documentation – each
6-
chapter gives only high-level details, the kinds of things that
7-
(ideally) don't change frequently.
8-
9-
There are three parts to this guide. Part 1 contains information that should
10-
be useful no matter how you are contributing. Part 2 contains information
11-
about how the compiler works. Finally, there are some appendices at the
12-
end with useful reference information.
5+
development.
6+
7+
There are six parts to this guide:
8+
9+
1. [Contributing][p1]: Contains information that should be useful no matter how
10+
you are contributing, such as procedures for contribution, building the
11+
compiler, etc.
12+
2. [High-level Compiler Architecture][p2]: Discusses the high-level
13+
architecture of the compiler, especially the query system.
14+
3. [The Compiler Frontend][p3]: Discusses the compiler frontend and internal
15+
representations.
16+
4. [The Type System][p4]: Discusses the type system.
17+
5. [The Compiler Backend][p5]: Discusses the compiler backend, code generation,
18+
linking, and debug info.
19+
6. [Appendices][app] at the end with useful reference information. There are a
20+
few of these with different information, inluding a glossary.
21+
22+
[p1]: ./part-1-intro.md
23+
[p2]: ./part-2-intro.md
24+
[p3]: ./part-3-intro.md
25+
[p4]: ./part-4-intro.md
26+
[p5]: ./part-5-intro.md
27+
[app]: ./appendix/background.md
1328

1429
The guide itself is of course open-source as well, and the sources can
1530
be found at the [GitHub repository]. If you find any mistakes in the

src/ast-validation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# AST Validation
2+
3+
AST validation is the process of checking various correctness properties about
4+
the AST after macro expansion.
5+
6+
**TODO**: write this chapter.
File renamed without changes.

src/feature-gate-ck.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Feature Gate Checking
2+
3+
**TODO**: this chapter

src/mir/construction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MIR construction
1+
# HAIR and MIR construction
22

33
The lowering of [HIR] to [MIR] occurs for the following (probably incomplete)
44
list of items:

src/overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Overview of the Compiler
2+
3+
Coming soon! Work is in progress on this chapter. See https://github.com/rust-lang/rustc-dev-guide/pull/633 for the source and the [project README](https://github.com/rust-lang/rustc-dev-guide) for local build instructions.

src/part-2-intro.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Part 2: How rustc works
22

3-
This part of the guide describes how the compiler works. It goes through
4-
everything from high-level structure of the compiler to how each stage of
5-
compilation works.
3+
The remaining parts of this guide discuss how the compiler works. They go
4+
through everything from high-level structure of the compiler to how each stage
5+
of compilation works. They should be friendly to both readers interested in the
6+
end-to-end process of compilation _and_ readers interested in learning about a
7+
specific system they wish to contribute to. If anything is unclear, feel free
8+
to file an issue on the [rustc-dev-guide
9+
repo](https://github.com/rust-lang/rustc-dev-guide/issues) or contact the compiler
10+
team, as detailed in [this chapter from Part 1](./compiler-team.md).
611

7-
This section should be friendly to both readers interested in the end-to-end
8-
process of compilation _and_ readers interested in learning about a specific
9-
system they wish to contribute to. If anything is unclear, feel free to file
10-
an issue on the [rustc-dev-guide repo](https://github.com/rust-lang/rustc-dev-guide)
11-
or contact the compiler team, as detailed in [this chapter from Part
12-
1](./compiler-team.md).
12+
In this part, we will specifically look at the high-level architecture of the
13+
compiler. Specifically, will look at the query system, incremental compilation,
14+
and interning. These are three overarching design choices that impact the whole
15+
compiler.

src/part-3-intro.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Part 3: Source Code Representations
2+
3+
This part describes the process of taking raw source code from the user and
4+
transforming it into various forms that the compiler can work with easily.
5+
These are called intermediate representations.
6+
7+
This process starts with compiler understanding what the user has asked for:
8+
parsing the command line arguments given and determining what it is to compile.

src/part-4-intro.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Part 4: Analysis
2+
3+
This part discusses the many analyses that the compiler uses to check various
4+
properties of the code and to inform later stages. Typically, this is what people
5+
mean when they talk about "Rust's type system". This includes the
6+
representation, inference, and checking of types, the trait system, and the
7+
borrow checker. These analyses do not happen as one big pass or set of
8+
contiguous passes. Rather, they are spread out throughout various parts of the
9+
compilation process and use different intermediate representations. For example,
10+
type checking happens on the HIR, while borrow checking happens on the MIR.
11+
Nonetheless, for the sake of presentation, we will discuss all of these
12+
analyses in this part of the guide.

0 commit comments

Comments
 (0)