diff options
| author | The Miri Cronjob Bot <miri@cron.bot> | 2025-04-07 05:24:10 +0000 |
|---|---|---|
| committer | The Miri Cronjob Bot <miri@cron.bot> | 2025-04-07 05:24:10 +0000 |
| commit | 2eb7791a1bc72b5d2357d0ee8be7e1ece5dc26c5 (patch) | |
| tree | 5f316fbcf48a556c06e14f8b34c46880f5b4c2aa /src/doc/rustc-dev-guide/examples/rustc-interface-example.rs | |
| parent | fa06e723adb8ad4a4cc995b2fccfccc7caf80bff (diff) | |
| parent | 25a615bf829b9f6d6f22da537e3851043f92e5f2 (diff) | |
| download | rust-2eb7791a1bc72b5d2357d0ee8be7e1ece5dc26c5.tar.gz rust-2eb7791a1bc72b5d2357d0ee8be7e1ece5dc26c5.zip | |
Merge from rustc
Diffstat (limited to 'src/doc/rustc-dev-guide/examples/rustc-interface-example.rs')
| -rw-r--r-- | src/doc/rustc-dev-guide/examples/rustc-interface-example.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs b/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs index 70f27c2a82a..360f70c8e86 100644 --- a/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs +++ b/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs @@ -1,4 +1,4 @@ -// Tested with nightly-2025-02-13 +// Tested with nightly-2025-03-28 #![feature(rustc_private)] @@ -64,14 +64,13 @@ fn main() { println!("{krate:?}"); // Analyze the program and inspect the types of definitions. rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| { - for id in tcx.hir().items() { - let hir = tcx.hir(); - let item = hir.item(id); + for id in tcx.hir_free_items() { + let item = tcx.hir_item(id); match item.kind { - rustc_hir::ItemKind::Static(_, _, _) | rustc_hir::ItemKind::Fn { .. } => { - let name = item.ident; + rustc_hir::ItemKind::Static(ident, ..) + | rustc_hir::ItemKind::Fn { ident, .. } => { let ty = tcx.type_of(item.hir_id().owner.def_id); - println!("{name:?}:\t{ty:?}") + println!("{ident:?}:\t{ty:?}") } _ => (), } |
