11#![ feature( rustc_private) ]
22
3- // NOTE: For the example to compile, you will need to first run the following:
4- // rustup component add rustc-dev llvm-tools-preview
5-
6- // version: 1.62.0-nightly (7c4b47696 2022-04-30)
7-
3+ extern crate rustc_driver;
84extern crate rustc_error_codes;
95extern crate rustc_errors;
106extern crate rustc_hash;
@@ -46,11 +42,10 @@ fn main() {
4642"#
4743 . into ( ) ,
4844 } ,
49- input_path : None , // Option<PathBuf>
5045 output_dir : None , // Option<PathBuf>
5146 output_file : None , // Option<PathBuf>
5247 file_loader : None , // Option<Box<dyn FileLoader + Send + Sync>>
53- diagnostic_output : rustc_session :: DiagnosticOutput :: Default ,
48+ locale_resources : rustc_driver :: DEFAULT_LOCALE_RESOURCES ,
5449 lint_caps : FxHashMap :: default ( ) , // FxHashMap<lint::LintId, lint::Level>
5550 // This is a callback from the driver that is called when [`ParseSess`] is created.
5651 parse_sess_created : None , //Option<Box<dyn FnOnce(&mut ParseSess) + Send>>
@@ -68,21 +63,23 @@ fn main() {
6863 // Registry of diagnostics codes.
6964 registry : registry:: Registry :: new ( & rustc_error_codes:: DIAGNOSTICS ) ,
7065 make_codegen_backend : None ,
66+ expanded_args : Vec :: new ( ) ,
67+ ice_file : None ,
7168 } ;
7269 rustc_interface:: run_compiler ( config, |compiler| {
7370 compiler. enter ( |queries| {
7471 // Parse the program and print the syntax tree.
75- let parse = queries. parse ( ) . unwrap ( ) . take ( ) ;
72+ let parse = queries. parse ( ) . unwrap ( ) . get_mut ( ) . clone ( ) ;
7673 println ! ( "{parse:?}" ) ;
7774 // Analyze the program and inspect the types of definitions.
78- queries. global_ctxt ( ) . unwrap ( ) . take ( ) . enter ( |tcx| {
75+ queries. global_ctxt ( ) . unwrap ( ) . enter ( |tcx| {
7976 for id in tcx. hir ( ) . items ( ) {
8077 let hir = tcx. hir ( ) ;
8178 let item = hir. item ( id) ;
8279 match item. kind {
8380 rustc_hir:: ItemKind :: Static ( _, _, _) | rustc_hir:: ItemKind :: Fn ( _, _, _) => {
8481 let name = item. ident ;
85- let ty = tcx. type_of ( hir . local_def_id ( item. hir_id ( ) ) ) ;
82+ let ty = tcx. type_of ( item. hir_id ( ) . owner . def_id ) ;
8683 println ! ( "{name:?}:\t {ty:?}" )
8784 }
8885 _ => ( ) ,
0 commit comments