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)
This commit is contained in:
Youngsuk Kim 2019-11-08 11:09:45 -05:00 committed by Yuki Okushi
parent 0caefaa384
commit 0f2d015241
1 changed files with 9 additions and 7 deletions

View File

@ -9,17 +9,18 @@ for running code at particular times during the compilation process, allowing
third parties to effectively use `rustc`'s internals as a library for third parties to effectively use `rustc`'s internals as a library for
analysing a crate or emulating the compiler in-process (e.g. the RLS or rustdoc). analysing a crate or emulating the compiler in-process (e.g. the RLS or rustdoc).
For those using `rustc` as a library, the `interface::run_compiler()` function is the main For those using `rustc` as a library, the [`rustc_interface::interface::run_compiler()`][i_rc]
entrypoint to the compiler. It takes a configuration for the compiler and a closure that function is the main entrypoint to the compiler. It takes a configuration for the compiler
takes a [`Compiler`]. `run_compiler` creates a `Compiler` from the configuration and passes and a closure that takes a [`Compiler`]. `run_compiler` creates a `Compiler` from the
it to the closure. Inside the closure, you can use the `Compiler` to drive queries to compile configuration and passes it to the closure. Inside the closure, you can use the `Compiler`
a crate and get the results. This is what the `rustc_driver` does too. to drive queries to compile a crate and get the results. This is what the `rustc_driver` does too.
You can see what queries are currently available through the rustdocs for [`Compiler`]. You can see what queries are currently available through the rustdocs for [`Compiler`].
You can see an example of how to use them by looking at the `rustc_driver` implementation, You can see an example of how to use them by looking at the `rustc_driver` implementation,
specifically the [`rustc_driver::run_compiler` function][rd_rc] (not to be confused with specifically the [`rustc_driver::run_compiler` function][rd_rc] (not to be confused with
`interface::run_compiler`). The `rustc_driver::run_compiler` function takes a bunch of [`rustc_interface::interface::run_compiler`][i_rc]). The `rustc_driver::run_compiler` function
command-line args and some other configurations and drives the compilation to completion. takes a bunch of command-line args and some other configurations and
drives the compilation to completion.
`rustc_driver::run_compiler` also takes a [`Callbacks`][cb]. In the past, when `rustc_driver::run_compiler` also takes a [`Callbacks`][cb]. In the past, when
the `rustc_driver::run_compiler` was the primary way to use the compiler as a 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.
[cb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html [cb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html
[rd_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.run_compiler.html [rd_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.run_compiler.html
[i_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/fn.run_compiler.html
[`rustc_interface`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/index.html [`rustc_interface`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/index.html
[`rustc_driver`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/ [`rustc_driver`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/
[`Compiler`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Compiler.html [`Compiler`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Compiler.html