Skip to content

Commit a9829ab

Browse files
committed
Add headings to overview.md
1 parent dc47b51 commit a9829ab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/overview.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ So first, let's look at what the compiler does to your code. For now, we will
1717
avoid mentioning how the compiler implements these steps except as needed;
1818
we'll talk about that later.
1919

20+
### Invokation
21+
2022
- The compile process begins when a user writes a Rust source program in text
2123
and invokes the `rustc` compiler on it. The work that the compiler needs to
2224
perform is defined by command-line options. For example, it is possible to
@@ -26,6 +28,9 @@ we'll talk about that later.
2628
- Command line argument parsing occurs in the [`rustc_driver`]. This crate
2729
defines the compile configuration that is requested by the user and passes it
2830
to the rest of the compilation process as a [`rustc_interface::Config`].
31+
32+
### Lexing and parsing
33+
2934
- The raw Rust source text is analyzed by a low-level lexer located in
3035
[`rustc_lexer`]. At this stage, the source text is turned into a stream of
3136
atomic source code units known as _tokens_. The lexer supports the
@@ -66,6 +71,9 @@ we'll talk about that later.
6671
- The parser uses the standard `DiagnosticBuilder` API for error handling, but we
6772
try to recover, parsing a superset of Rust's grammar, while also emitting an error.
6873
- `rustc_ast::ast::{Crate, Mod, Expr, Pat, ...}` AST nodes are returned from the parser.
74+
75+
### HIR lowering
76+
6977
- We then take the AST and [convert it to High-Level Intermediate
7078
Representation (HIR)][hir]. This is a compiler-friendly representation of the
7179
AST. This involves a lot of desugaring of things like loops and `async fn`.
@@ -77,6 +85,9 @@ we'll talk about that later.
7785
into the internal representation used by the compiler (`Ty<'tcx>`),
7886
and using that information to verify the type safety, correctness and
7987
coherence of the types used in the program).
88+
89+
### MIR lowering
90+
8091
- The HIR is then [lowered to Mid-Level Intermediate Representation (MIR)][mir].
8192
- Along the way, we construct the THIR, which is an even more desugared HIR.
8293
THIR is used for pattern and exhaustiveness checking. It is also more
@@ -93,6 +104,9 @@ we'll talk about that later.
93104
code with the type parameters replaced by concrete types. To do
94105
this, we need to collect a list of what concrete types to generate code for.
95106
This is called _monomorphization collection_.
107+
108+
### Code generation
109+
96110
- We then begin what is vaguely called _code generation_ or _codegen_.
97111
- The [code generation stage (codegen)][codegen] is when higher level
98112
representations of source are turned into an executable binary. `rustc`

0 commit comments

Comments
 (0)