diff options
| author | Hiroki Fujino <hirokifujino0108@gmail.com> | 2023-02-09 10:56:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-09 18:56:06 +0900 |
| commit | c1658f32a0eeef823559ae29c7ad9dcd6fdbb0bb (patch) | |
| tree | 55c504beb2d054b7379a63e28b3eb4fa2888f49b /src/doc/rustc-dev-guide/examples/rustc-driver-example.rs | |
| parent | ee58570fffaa6a59d13a1b1d6b3ae5ebf07c27fd (diff) | |
| download | rust-c1658f32a0eeef823559ae29c7ad9dcd6fdbb0bb.tar.gz rust-c1658f32a0eeef823559ae29c7ad9dcd6fdbb0bb.zip | |
update examples for rustc 1.69.0-nightly (e1eaa2d5d 2023-02-06) (#1590)
Closes https://github.com/rust-lang/rustc-dev-guide/issues/1581
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 | 8 |
1 files changed, 4 insertions, 4 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 8d8b40cd7ea..13a3ebcc99e 100644 --- a/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs +++ b/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs @@ -12,6 +12,7 @@ extern crate rustc_hir; extern crate rustc_interface; extern crate rustc_session; extern crate rustc_span; +extern crate rustc_driver; use std::{path, process, str}; @@ -46,7 +47,6 @@ fn main() { "# .into(), }, - input_path: None, // Option<PathBuf> output_dir: None, // Option<PathBuf> output_file: None, // Option<PathBuf> file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>> @@ -71,17 +71,17 @@ fn main() { rustc_interface::run_compiler(config, |compiler| { compiler.enter(|queries| { // Parse the program and print the syntax tree. - let parse = queries.parse().unwrap().take(); + let parse = queries.parse().unwrap().get_mut().clone(); println!("{parse:?}"); // Analyze the program and inspect the types of definitions. - queries.global_ctxt().unwrap().take().enter(|tcx| { + queries.global_ctxt().unwrap().enter(|tcx| { for id in tcx.hir().items() { let hir = tcx.hir(); let item = hir.item(id); match item.kind { rustc_hir::ItemKind::Static(_, _, _) | rustc_hir::ItemKind::Fn(_, _, _) => { let name = item.ident; - let ty = tcx.type_of(hir.local_def_id(item.hir_id())); + let ty = tcx.type_of(item.hir_id().owner.def_id); println!("{name:?}:\t{ty:?}") } _ => (), |
