Example in "Getting diagnostic through `rustc_interface`" is outdated and meaningless
CSharperMantle opened this issue · 0 comments
Description
The code in the latest tutorial rustc-driver-getting-diagnostics.md
no longer functions starting from as far as commit 7352353.
This struct DiagnosticSink
is never instantiated, nor is it referenced. The reference to this struct is removed in 7352353 but the definition of it was left there.
rustc-dev-guide/examples/rustc-driver-getting-diagnostics.rs
Lines 21 to 32 in 44b2f27
This variable buffer
is never written into after the removal of DiagnosticSink
.
rustc-dev-guide/examples/rustc-driver-getting-diagnostics.rs
Lines 40 to 42 in 44b2f27
In commit 4383648, the config::Options
did seem to expose the diagnostic_output
prop, but it was later removed, rendering the above two definitions useless and the example pointless.
The comments on the Markdown page claim that the examples are tested on some date, and this date has been updated in every commit. Yet it does not seem to reflect the truth. The diagnostics have never been intercepted and stored after the removal of diagnostic_output
.
Solutions
Solution 1
Remove this example.
Solution 2
Provide the documentation to an alternative interface to removed diagnostic_output
.
Remarks
I came across this issue when I tried to suppress the diagnostics produced by rustc_interface::run_compiler
and only fetch the compilation result (success or not). It would be better if a simpler approach to this could be provided.