forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update rustc-driver-getting-diagnostics.md
- Loading branch information
Showing
1 changed file
with
8 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
# Example: Getting diagnostic through `rustc_interface` | ||
|
||
`rustc_interface` allows you to intercept diagnostics that would otherwise be printed to stderr. | ||
The [`rustc_interface`] allows you to intercept diagnostics that would | ||
otherwise be printed to stderr. | ||
|
||
## Getting diagnostics | ||
|
||
To get diagnostics from the compiler, | ||
configure `rustc_interface::Config` to output diagnostic to a buffer, | ||
and run `TyCtxt.analysis`. The following was tested | ||
configure [`rustc_interface::Config`] to output diagnostic to a buffer, | ||
and run [`TyCtxt.analysis`]. The following was tested | ||
with <!-- date-check: jan 2024 --> `nightly-2024-01-19`: | ||
|
||
```rust | ||
{{#include ../examples/rustc-driver-getting-diagnostics.rs}} | ||
``` | ||
|
||
[`rustc_interface`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/index.html | ||
[`rustc_interface::Config`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Config.html | ||
[`TyCtxt.analysis`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/passes/fn.analysis.html |