rustc_interfaceThe rustc_interface allows you to intercept diagnostics that would otherwise be printed to stderr.
To get diagnostics from the compiler, configure rustc_interface::Config to output diagnostic to a buffer, and run rustc_hir_typeck::typeck for each item.
{{#include ../../examples/rustc-interface-getting-diagnostics.rs}}