about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-04-07 07:18:31 +0000
committerGitHub <noreply@github.com>2025-04-07 07:18:31 +0000
commitf6e4d3bc5a22268292b620a570d47df2c204f9c6 (patch)
treeb451ad6d5c40298bbbf4b6bcd2c15e8776c1ccf8 /src/doc/rustc-dev-guide/examples/rustc-interface-example.rs
parent1a4e85a4e6ce99e4adf8f043fb9f2aa6b2e7ca94 (diff)
parent6ac0120a60d543d9557d2affd334ba02704c9fb8 (diff)
downloadrust-f6e4d3bc5a22268292b620a570d47df2c204f9c6.tar.gz
rust-f6e4d3bc5a22268292b620a570d47df2c204f9c6.zip
Merge pull request #4252 from rust-lang/rustup-2025-04-07
Automatic Rustup
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.rs13
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:?}")
                     }
                     _ => (),
                 }