Skip to content

Commit e3d0056

Browse files
Addressed some of @nrc and @mark-i-m's comments
1 parent 42e4eee commit e3d0056

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/appendix-code-index.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ compiler.
66

77
Item | Kind | Short description | Chapter | Declaration
88
----------------|----------|-----------------------------|--------------------|-------------------
9-
`CodeMap` | struct | The CodeMap maps the AST nodes to their source code | [The parser](the-parser.html) | [src/libsyntax/codemap.rs](https://github.com/rust-lang/rust/blob/master/src/libsyntax/codemap.rs)
10-
`CompileState` | struct | State that is passed to a callback at each compiler pass | [The Rustc Driver](rustc-driver.html) | [src/librustc_driver/driver.rs](https://github.com/rust-lang/rust/blob/master/src/librustc_driver/driver.rs)
11-
`ast::Crate` | struct | Syntax-level representation of a parsed crate | | [src/librustc/hir/mod.rs](https://github.com/rust-lang/rust/blob/master/src/libsyntax/ast.rs)
12-
`hir::Crate` | struct | Top-level data structure representing the crate being compiled | | [src/librustc/hir/mod.rs](https://github.com/rust-lang/rust/blob/master/src/librustc/hir/mod.rs)
13-
`ParseSess` | struct | This struct contains information about a parsing session | [The parser](the-parser.html) | [src/libsyntax/parse/mod.rs](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/mod.rs)
14-
`StringReader` | struct | This is the lexer used during parsing. It consumes characters from the raw source code being compiled and produces a series of tokens for use by the rest of the parser | [The parser](the-parser.html) | [src/libsyntax/parse/lexer/mod.rs](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/lexer/mod.rs)
15-
`Session` | struct | The data associated with a compilation session | [the Parser](the-parser.html), [The Rustc Driver](rustc-driver.html) | [src/librustc/session/mod.html](https://github.com/rust-lang/rust/blob/master/src/librustc/session/mod.rs)
16-
`TraitDef` | struct | This struct contains a trait's definition with type information | [The `ty` modules](ty.html) | [src/librustc/ty/trait_def.rs](https://github.com/rust-lang/rust/blob/master/src/librustc/ty/trait_def.rs)
17-
`TyCtxt<'cx, 'tcx, 'tcx>` | type | The "typing context". This is the central data structure in the compiler. It is the context that you use to perform all manner of queries. | [The `ty` modules](ty.html) | [src/librustc/ty/context.rs](https://github.com/rust-lang/rust/blob/master/src/librustc/ty/context.rs)
9+
`CodeMap` | struct | The CodeMap maps the AST nodes to their source code | [The parser] | [src/libsyntax/codemap.rs](https://github.com/rust-lang/rust/blob/master/src/libsyntax/codemap.rs)
10+
`CompileState` | struct | State that is passed to a callback at each compiler pass | [The Rustc Driver] | [src/librustc_driver/driver.rs](https://github.com/rust-lang/rust/blob/master/src/librustc_driver/driver.rs)
11+
`ast::Crate` | struct | Syntax-level representation of a parsed crate | [The parser] | [src/librustc/hir/mod.rs](https://github.com/rust-lang/rust/blob/master/src/libsyntax/ast.rs)
12+
`hir::Crate` | struct | More abstract, compiler-friendly form of a crate's AST | [The Hir] | [src/librustc/hir/mod.rs](https://github.com/rust-lang/rust/blob/master/src/librustc/hir/mod.rs)
13+
`ParseSess` | struct | This struct contains information about a parsing session | [the Parser] | [src/libsyntax/parse/mod.rs](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/mod.rs)
14+
`Session` | struct | The data associated with a compilation session | [the Parser], [The Rustc Driver] | [src/librustc/session/mod.html](https://github.com/rust-lang/rust/blob/master/src/librustc/session/mod.rs)
15+
`StringReader` | struct | This is the lexer used during parsing. It consumes characters from the raw source code being compiled and produces a series of tokens for use by the rest of the parser | [The parser] | [src/libsyntax/parse/lexer/mod.rs](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/lexer/mod.rs)
16+
`TraitDef` | struct | This struct contains a trait's definition with type information | [The `ty` modules] | [src/librustc/ty/trait_def.rs](https://github.com/rust-lang/rust/blob/master/src/librustc/ty/trait_def.rs)
17+
`TyCtxt<'cx, 'tcx, 'tcx>` | type | The "typing context". This is the central data structure in the compiler. It is the context that you use to perform all manner of queries. | [The `ty` modules] | [src/librustc/ty/context.rs](https://github.com/rust-lang/rust/blob/master/src/librustc/ty/context.rs)
18+
19+
[The HIR]: hir.html
20+
[The parser]: the-parser.html
21+
[The Rustc Driver]: rustc-driver.html
22+
[The `ty` modules]: ty.html

src/rustc-driver.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ managing state such as the [`CodeMap`] \(maps AST nodes to source code),
88
stuff). The `rustc_driver` crate also provides external users with a method
99
for running code at particular times during the compilation process, allowing
1010
third parties to effectively use `rustc`'s internals as a library for
11-
analysing a crate.
11+
analysing a crate or emulating the compiler in-process (e.g. the RLS).
1212

1313
For those using `rustc` as a library, the `run_compiler()` function is the main
1414
entrypoint to the compiler. Its main parameters are a list of command-line
@@ -20,10 +20,12 @@ of each phase.
2020
From `rustc_driver`'s perspective, the main phases of the compiler are:
2121

2222
1. *Parse Input:* Initial crate parsing
23-
2. *Configure and Expand:* Resolve `#[cfg]` attributes and expand macros
24-
3. *Run Analysis Passes:* Run the resolution, typechecking, region checking
23+
2. *Configure and Expand:* Resolve `#[cfg]` attributes, name resolution, and
24+
expand macros
25+
3. *Run Analysis Passes:* Run trait resolution, typechecking, region checking
2526
and other miscellaneous analysis passes on the crate
26-
4. *Translate to LLVM:* Turn the analysed program into executable code
27+
4. *Translate to LLVM:* Translate to the in-memory form of LLVM IR and turn it
28+
into an executable/object files
2729

2830
The `CompileController` then gives users the ability to inspect the ongoing
2931
compilation process
@@ -37,6 +39,9 @@ compilation process
3739
The `CompileState`'s various `state_after_*()` constructors can be inspected to
3840
determine what bits of information are available to which callback.
3941

42+
> **Warning:** By its very nature, the internal compiler APIs are always going
43+
> to be unstable. That said, we do try not to break things unnecessarily.
44+
4045
## A Note On Lifetimes
4146

4247
The Rust compiler is a fairly large program containing lots of big data

0 commit comments

Comments
 (0)