Skip to content

Commit 0f2d015

Browse files
JOE1994JohnTitor
authored andcommitted
Clarify function name and add links (#506)
* Clarify function name and add links rustc_interface::interface::run_compiler (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/fn.run_compiler.html)
1 parent 0caefaa commit 0f2d015

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/rustc-driver.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ for running code at particular times during the compilation process, allowing
99
third parties to effectively use `rustc`'s internals as a library for
1010
analysing a crate or emulating the compiler in-process (e.g. the RLS or rustdoc).
1111

12-
For those using `rustc` as a library, the `interface::run_compiler()` function is the main
13-
entrypoint to the compiler. It takes a configuration for the compiler and a closure that
14-
takes a [`Compiler`]. `run_compiler` creates a `Compiler` from the configuration and passes
15-
it to the closure. Inside the closure, you can use the `Compiler` to drive queries to compile
16-
a crate and get the results. This is what the `rustc_driver` does too.
12+
For those using `rustc` as a library, the [`rustc_interface::interface::run_compiler()`][i_rc]
13+
function is the main entrypoint to the compiler. It takes a configuration for the compiler
14+
and a closure that takes a [`Compiler`]. `run_compiler` creates a `Compiler` from the
15+
configuration and passes it to the closure. Inside the closure, you can use the `Compiler`
16+
to drive queries to compile a crate and get the results. This is what the `rustc_driver` does too.
1717

1818
You can see what queries are currently available through the rustdocs for [`Compiler`].
1919
You can see an example of how to use them by looking at the `rustc_driver` implementation,
2020
specifically the [`rustc_driver::run_compiler` function][rd_rc] (not to be confused with
21-
`interface::run_compiler`). The `rustc_driver::run_compiler` function takes a bunch of
22-
command-line args and some other configurations and drives the compilation to completion.
21+
[`rustc_interface::interface::run_compiler`][i_rc]). The `rustc_driver::run_compiler` function
22+
takes a bunch of command-line args and some other configurations and
23+
drives the compilation to completion.
2324

2425
`rustc_driver::run_compiler` also takes a [`Callbacks`][cb]. In the past, when
2526
the `rustc_driver::run_compiler` was the primary way to use the compiler as a
@@ -47,6 +48,7 @@ thread-locals, although you should rarely need to touch it.
4748

4849
[cb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html
4950
[rd_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.run_compiler.html
51+
[i_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/fn.run_compiler.html
5052
[`rustc_interface`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/index.html
5153
[`rustc_driver`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/
5254
[`Compiler`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Compiler.html

0 commit comments

Comments
 (0)