Skip to content

Commit 5c827ef

Browse files
committed
address Zoxc's comments
1 parent e8370fd commit 5c827ef

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/appendix/stupid-stats.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
> a copy of the code on the GitHub repository.
55
>
66
> Due to the compiler's constantly evolving nature, the `rustc_driver`
7-
> mechanisms described in this chapter have been replaced by a new
7+
> mechanisms described in this chapter have changed. In particular, the
8+
> `CompilerCalls` and `CompileController` types have been replaced by
9+
> [`Callbacks`][cb]. Also, there is a new query-based interface in the
810
> [`rustc_interface`] crate. See [The Rustc Driver and Interface] for more
911
> information.
1012
@@ -409,6 +411,7 @@ analysis, rather than doing its own analysis). Other parts of the compiler
409411
internally (I already changed save-analysis to use `CompilerController`). I've
410412
been experimenting with a prototype rustfmt which also uses these APIs.
411413

414+
[cb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html
412415
[stupid-stats]: https://github.com/nrc/stupid-stats
413416
[`rustc_interface`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/index.html
414417
[The Rustc Driver and Interface]: ../rustc-driver.html

src/rustc-driver.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ specifically the [`rustc_driver::run_compiler` function][rd_rc] (not to be confu
2121
`interface::run_compiler`). The `rustc_driver::run_compiler` function takes a bunch of
2222
command-line args and some other configurations and drives the compilation to completion.
2323

24+
`rustc_driver::run_compiler` also takes a [`Callbacks`][cb]. In the past, when
25+
the `rustc_driver::run_compiler` was the primary way to use the compiler as a
26+
library, these callbacks were used to have some custom code run after different
27+
phases of the compilation. If you read [Appendix A], you may notice the use of the
28+
types `CompilerCalls` and `CompileController`, which no longer exist. `Callbacks`
29+
replaces this functionality.
30+
2431
> **Warning:** By its very nature, the internal compiler APIs are always going
2532
> to be unstable. That said, we do try not to break things unnecessarily.
2633
@@ -38,6 +45,7 @@ duplication while also preventing a lot of the ergonomic issues due to many
3845
pervasive lifetimes. The `rustc::ty::tls` module is used to access these
3946
thread-locals, although you should rarely need to touch it.
4047

48+
[cb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html
4149
[rd_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.run_compiler.html
4250
[`rustc_interface`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/index.html
4351
[`rustc_driver`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/

0 commit comments

Comments
 (0)