about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs
diff options
context:
space:
mode:
authorYang Lin <yanglin@smail.nju.edu.cn>2025-03-16 23:27:10 +0800
committerYang Lin <yanglin@smail.nju.edu.cn>2025-03-16 23:27:10 +0800
commita4b76e31f8f906e31256b2c8f696e39b2ee36c41 (patch)
tree6f2bc8e8cf2ed8a77ddc4a89c111ddbc0e263a19 /src/doc/rustc-dev-guide/examples/rustc-interface-example.rs
parentb30d1970ab99dd31e3ba30bd6dcf815b3fc75aee (diff)
downloadrust-a4b76e31f8f906e31256b2c8f696e39b2ee36c41.tar.gz
rust-a4b76e31f8f906e31256b2c8f696e39b2ee36c41.zip
Adapt to rust-lang/rust#136466:
Start removing `rustc_middle::hir::map::Map`

Following commit f86f7ad from pull request #136466
in the Rust project
(https://github.com/rust-lang/rust),
some methods in `Map` were moved to `TyCtxt`.
This update reimplements `rustc-drive-example.rs`,
`rustc-driver-interacting-with-the-ast.rs`,
and `rustc-interface-example.rs` using the new
versions of these methods, ensuring compatibility
with the nightly-2025-03-08 toolchain.
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.rs7
1 files changed, 3 insertions, 4 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..11125caec70 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-08
 
 #![feature(rustc_private)]
 
@@ -64,9 +64,8 @@ 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;