about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs
diff options
context:
space:
mode:
authorTshepang Mbambo <tshepang@gmail.com>2025-03-29 23:10:13 +0200
committerGitHub <noreply@github.com>2025-03-29 23:10:13 +0200
commit9448b79201adddf493ba36e1aaedee31ea17c293 (patch)
tree89e70cd234b4013a17cbb054b9cb5753ad3ec120 /src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs
parent70cbe19fe005166c4321b3fcfedd0010b7d69d9d (diff)
parent9a2d1fdb141ec2db9be1802316c66722f7b678f8 (diff)
downloadrust-9448b79201adddf493ba36e1aaedee31ea17c293.tar.gz
rust-9448b79201adddf493ba36e1aaedee31ea17c293.zip
Merge pull request #2289 from y1lan/fix_compiler_err_of_examples
Fix compile errors of all the examples
Diffstat (limited to 'src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs')
-rw-r--r--src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs b/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs
index 39b236e1783..9bb93ab4958 100644
--- a/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs
+++ b/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs
@@ -1,4 +1,4 @@
-// Tested with nightly-2025-02-13
+// Tested with nightly-2025-03-08
 
 #![feature(rustc_private)]
 
@@ -86,8 +86,10 @@ fn main() {
     rustc_interface::run_compiler(config, |compiler| {
         let krate = rustc_interface::passes::parse(&compiler.sess);
         rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| {
-            // Run the analysis phase on the local crate to trigger the type error.
-            let _ = tcx.analysis(());
+            // Iterate all the items defined and perform type checking.
+            tcx.par_hir_body_owners(|item_def_id| {
+                tcx.ensure_ok().typeck(item_def_id);
+            });
         });
         // If the compiler has encountered errors when this closure returns, it will abort (!) the program.
         // We avoid this by resetting the error count before returning