Skip to content

Commit 808a9a1

Browse files
Add a more detailed description of how incremental compilation works.
1 parent 54bf204 commit 808a9a1

File tree

7 files changed

+376
-19
lines changed

7 files changed

+376
-19
lines changed

src/SUMMARY.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
- [The Rustc Driver](./rustc-driver.md)
2121
- [Rustdoc](./rustdoc.md)
2222
- [Queries: demand-driven compilation](./query.md)
23-
- [The Query Evaluation Model in Detail](./query-evaluation-model-in-detail.md)
24-
- [Incremental compilation](./incremental-compilation.md)
23+
- [The Query Evaluation Model in Detail](./queries/query-evaluation-model-in-detail.md)
24+
- [Incremental compilation](./queries/incremental-compilation.md)
25+
- [Incremental compilation In Detail](./queries/incremental-compilation-in-detail.md)
2526
- [Debugging and Testing](./incrcomp-debugging.md)
2627
- [The parser](./the-parser.md)
2728
- [`#[test]` Implementation](./test-implementation.md)

src/appendix/glossary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ completeness | completeness is a technical term in type theory. Comp
1515
control-flow graph | a representation of the control-flow of a program; see [the background chapter for more](./background.html#cfg)
1616
CTFE | Compile-Time Function Evaluation. This is the ability of the compiler to evaluate `const fn`s at compile time. This is part of the compiler's constant evaluation system. ([see more](../const-eval.html))
1717
cx | we tend to use "cx" as an abbreviation for context. See also `tcx`, `infcx`, etc.
18-
DAG | a directed acyclic graph is used during compilation to keep track of dependencies between queries. ([see more](../incremental-compilation.html))
18+
DAG | a directed acyclic graph is used during compilation to keep track of dependencies between queries. ([see more](../queries/incremental-compilation.html))
1919
data-flow analysis | a static analysis that figures out what properties are true at each point in the control-flow of a program; see [the background chapter for more](./background.html#dataflow)
2020
DefId | an index identifying a definition (see `librustc/hir/def_id.rs`). Uniquely identifies a `DefPath`.
2121
Double pointer | a pointer with additional metadata. See "fat pointer" for more.

src/queries/incremental-compilation-in-detail.md

Lines changed: 354 additions & 0 deletions
Large diffs are not rendered by default.

src/queries/query-evaluation-model-in-detail.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,24 @@ fn type_check_crate_provider(tcx, _key: ()) {
123123
}
124124
```
125125

126-
We see that the `type_check_crate` query accesses input data (`tcx.hir_map`)
127-
and invokes other queries (`type_check_item`). The `type_check_item`
126+
We see that the `type_check_crate` query accesses input data
127+
(`tcx.hir_map.list_of_items()`) and invokes other queries
128+
(`type_check_item`). The `type_check_item`
128129
invocations will themselves access input data and/or invoke other queries,
129130
so that in the end the DAG of query invocations will be built up backwards
130131
from the node that was initially executed:
131132

132-
```
133-
(1)
134-
hir_map <--------------------------------------------------- type_check_crate()
135-
^ |
136-
| (4) (3) (2) |
137-
+-- Hir(foo) <--- type_of(foo) <--- type_check_item(foo) <-------+
138-
| | |
139-
| +-----------------+ |
140-
| | |
141-
| (6) v (5) (7) |
142-
+-- Hir(bar) <--- type_of(bar) <--- type_check_item(bar) <-------+
133+
```ignore
134+
(2) (1)
135+
list_of_all_hir_items <----------------------------- type_check_crate()
136+
|
137+
(5) (4) (3) |
138+
Hir(foo) <--- type_of(foo) <--- type_check_item(foo) <-------+
139+
| |
140+
+-----------------+ |
141+
| |
142+
(7) v (6) (8) |
143+
Hir(bar) <--- type_of(bar) <--- type_check_item(bar) <-------+
143144
144145
// (x) denotes invocation order
145146
```

src/query.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ compiler (for example, generating MIR) work exactly like this.
3737

3838
### The Query Evaluation Model in Detail
3939

40-
The [Query Evaluation Model in Detail](query-evaluation-model-in-detail.html)
41-
chapter gives a more in-depth description of what queries are and how they work.
40+
The [Query Evaluation Model in Detail][query-model] chapter gives a more
41+
in-depth description of what queries are and how they work.
4242
If you intend to write a query of your own, this is a good read.
4343

4444
### Invoking queries
@@ -267,3 +267,4 @@ impl<'tcx> QueryDescription for queries::type_of<'tcx> {
267267
}
268268
```
269269

270+
[query-model]: queries/query-evaluation-model-in-detail.html

src/variance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ crate (through `crate_variances`), but since most changes will not result in a
139139
change to the actual results from variance inference, the `variances_of` query
140140
will wind up being considered green after it is re-evaluated.
141141

142-
[rga]: ./incremental-compilation.html
142+
[rga]: ./queries/incremental-compilation.html
143143

144144
<a name="addendum"></a>
145145

0 commit comments

Comments
 (0)