diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-02-20 02:36:21 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-20 02:36:21 +0800 |
| commit | 342ced97dbebb611b54c172e9ec7c0e9225dcb49 (patch) | |
| tree | aac3b6d5ec699a9f0522b87cfc4c83b89a2f04d8 /src/doc/rustc-dev-guide/examples/rustc-driver-example.rs | |
| parent | 56f65381a1dec597b023b6ec55b2d2d9dc783689 (diff) | |
| parent | dce265224a7674814d4d81a81192bf9077ed2edd (diff) | |
| download | rust-342ced97dbebb611b54c172e9ec7c0e9225dcb49.tar.gz rust-342ced97dbebb611b54c172e9ec7c0e9225dcb49.zip | |
Merge pull request #2256 from torfsen/fix-examples-for-nightly-2025-02-13
Diffstat (limited to 'src/doc/rustc-dev-guide/examples/rustc-driver-example.rs')
| -rw-r--r-- | src/doc/rustc-dev-guide/examples/rustc-driver-example.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs b/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs index 14998965ac8..984bd3e37ae 100644 --- a/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs +++ b/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs @@ -1,3 +1,5 @@ +// Tested with nightly-2025-02-13 + #![feature(rustc_private)] extern crate rustc_ast; @@ -73,7 +75,7 @@ impl rustc_driver::Callbacks for MyCallbacks { let hir = tcx.hir(); let item = hir.item(id); match item.kind { - rustc_hir::ItemKind::Static(_, _, _) | rustc_hir::ItemKind::Fn(_, _, _) => { + rustc_hir::ItemKind::Static(_, _, _) | rustc_hir::ItemKind::Fn { .. } => { let name = item.ident; let ty = tcx.type_of(item.hir_id().owner.def_id); println!("{name:?}:\t{ty:?}") @@ -87,5 +89,13 @@ impl rustc_driver::Callbacks for MyCallbacks { } fn main() { - run_compiler(&["main.rs".to_string()], &mut MyCallbacks); + run_compiler( + &[ + // The first argument, which in practice contains the name of the binary being executed + // (i.e. "rustc") is ignored by rustc. + "ignored".to_string(), + "main.rs".to_string(), + ], + &mut MyCallbacks, + ); } |
