Skip to content

Commit 9d0ed10

Browse files
Clarify debugging graph dependency (rust-lang#1862)
1 parent 351c9f3 commit 9d0ed10

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/doc/rustc-dev-guide/src/incrcomp-debugging.md

+22-11
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,41 @@
22

33
## Testing the dependency graph
44

5-
There are various ways to write tests against the dependency graph.
6-
The simplest mechanisms are the `#[rustc_if_this_changed]` and
7-
`#[rustc_then_this_would_need]` annotations. These are used in ui tests
8-
to test whether the expected set of paths exist in the dependency graph.
9-
As an example, see `tests/ui/dep-graph/dep-graph-caller-callee.rs`.
5+
There are various ways to write tests against the dependency graph. The
6+
simplest mechanisms are the `#[rustc_if_this_changed]` and
7+
`#[rustc_then_this_would_need]` annotations. These are used in [ui] tests to test
8+
whether the expected set of paths exist in the dependency graph.
109

11-
The idea is that you can annotate a test like:
10+
[`tests/ui/dep-graph/dep-graph-caller-callee.rs`]: https://github.com/rust-lang/rust/blob/master/tests/ui/dep-graph/dep-graph-caller-callee.rs
11+
[ui]: tests/ui.html
12+
13+
As an example, see [`tests/ui/dep-graph/dep-graph-caller-callee.rs`], or the
14+
tests below.
1215

1316
```rust,ignore
1417
#[rustc_if_this_changed]
1518
fn foo() { }
1619
1720
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
1821
fn bar() { foo(); }
22+
```
23+
24+
This should be read as
25+
> If this (`foo`) is changed, then this (i.e. `bar`)'s TypeckTables would need
26+
to be changed. Also, this
1927

28+
You could also add the lines
29+
30+
```rust,ignore
2031
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path
2132
fn baz() { }
2233
```
2334

24-
This will check whether there is a path in the dependency graph from `Hir(foo)`
25-
to `TypeckTables(bar)`. An error is reported for each
26-
`#[rustc_then_this_would_need]` annotation that indicates whether a path
27-
exists. `//~ ERROR` annotations can then be used to test if a path is found (as
28-
demonstrated above).
35+
Whose meaning is
36+
> If `foo` is changed, then `baz`'s TypeckTables does not need to be changed, as there is no path.
37+
38+
Recall that the `//~ ERROR OK` is a comment from the point of view of the Rust
39+
code we test, but is meaningful from the point of view of the test itself.
2940

3041
## Debugging the dependency graph
3142

0 commit comments

Comments
 (0)