diff options
| author | Tshepang Mbambo <tshepang@gmail.com> | 2025-03-29 23:10:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-29 23:10:13 +0200 |
| commit | 9448b79201adddf493ba36e1aaedee31ea17c293 (patch) | |
| tree | 89e70cd234b4013a17cbb054b9cb5753ad3ec120 /src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs | |
| parent | 70cbe19fe005166c4321b3fcfedd0010b7d69d9d (diff) | |
| parent | 9a2d1fdb141ec2db9be1802316c66722f7b678f8 (diff) | |
| download | rust-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.rs | 8 |
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 |
