summaryrefslogtreecommitdiffstats
path: root/src/doc/rustc-dev-guide/src/rustc-driver-getting-diagnostics.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
commit2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch)
treed325add32978dbdc1db975a438b3a77d571b1ab8 /src/doc/rustc-dev-guide/src/rustc-driver-getting-diagnostics.md
parentReleasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff)
downloadrustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz
rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/doc/rustc-dev-guide/src/rustc-driver-getting-diagnostics.md')
-rw-r--r--src/doc/rustc-dev-guide/src/rustc-driver-getting-diagnostics.md30
1 files changed, 2 insertions, 28 deletions
diff --git a/src/doc/rustc-dev-guide/src/rustc-driver-getting-diagnostics.md b/src/doc/rustc-dev-guide/src/rustc-driver-getting-diagnostics.md
index bb19ad9d3..3c2102a50 100644
--- a/src/doc/rustc-dev-guide/src/rustc-driver-getting-diagnostics.md
+++ b/src/doc/rustc-dev-guide/src/rustc-driver-getting-diagnostics.md
@@ -7,34 +7,8 @@
To get diagnostics from the compiler,
configure `rustc_interface::Config` to output diagnostic to a buffer,
and run `TyCtxt.analysis`. The following was tested
-with <!-- date-check: Jan 2023 --> `nightly-2022-12-19` (See [here][example]
-for the complete example):
-
-[example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-getting-diagnostics.rs
+with <!-- date-check: Feb 2023 --> `nightly-2023-02-13`:
```rust
-let buffer = sync::Arc::new(sync::Mutex::new(Vec::new()));
-let config = rustc_interface::Config {
- opts: config::Options {
- // Configure the compiler to emit diagnostics in compact JSON format.
- error_format: config::ErrorOutputType::Json {
- pretty: false,
- json_rendered: rustc_errors::emitter::HumanReadableErrorType::Default(
- rustc_errors::emitter::ColorConfig::Never,
- ),
- },
- /* other config */
- },
- /* other config */
-};
-rustc_interface::run_compiler(config, |compiler| {
- compiler.enter(|queries| {
- queries.global_ctxt().unwrap().take().enter(|tcx| {
- // Run the analysis phase on the local crate to trigger the type error.
- let _ = tcx.analysis(());
- });
- });
-});
-// Read buffered diagnostics.
-let diagnostics = String::from_utf8(buffer.lock().unwrap().clone()).unwrap();
+{{#include ../examples/rustc-driver-getting-diagnostics.rs}}
```