diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-03 07:39:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-03 07:39:08 +0200 |
| commit | 85c557e76eac68b1f94504f56c492b653706ee2c (patch) | |
| tree | c5c61fb576d0404a41ad3dbcf6c3affd2153bc74 /src/doc/rustc-dev-guide/examples/rustc-interface-example.rs | |
| parent | b5d5b6cd41dcf3495f9936bb6ce14a1922b513c1 (diff) | |
| parent | ead4d4c9514962bbec4ca22e561bad70a76242f4 (diff) | |
| download | rust-85c557e76eac68b1f94504f56c492b653706ee2c.tar.gz rust-85c557e76eac68b1f94504f56c492b653706ee2c.zip | |
Rollup merge of #139283 - BoxyUwU:rdg-push, r=jieyouxu
Rustc dev guide subtree update r? ``@jieyouxu`` ``@Kobzol``
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:?}") } _ => (), } |
