rustc-dev-guide/src/rustc-driver/getting-diagnostics.md

732 B

Example: Getting diagnostic through rustc_interface

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.

{{#include ../../examples/rustc-interface-getting-diagnostics.rs}}