33// NOTE: For the example to compile, you will need to first run the following:
44// rustup component add rustc-dev llvm-tools-preview
55
6+ // version: 1.53.0-nightly (9b0edb7fd 2021-03-27)
7+
68extern crate rustc_ast_pretty;
79extern crate rustc_error_codes;
810extern crate rustc_errors;
@@ -15,8 +17,6 @@ extern crate rustc_span;
1517use rustc_ast_pretty:: pprust:: item_to_string;
1618use rustc_errors:: registry;
1719use rustc_session:: config;
18- use rustc_session:: config:: PpMode :: PpmSource ;
19- use rustc_session:: config:: PpSourceMode :: PpmExpanded ;
2020use rustc_span:: source_map;
2121use std:: path;
2222use std:: process;
@@ -46,8 +46,8 @@ fn main() {
4646 output_file : None ,
4747 file_loader : None ,
4848 stderr : None ,
49- crate_name : None ,
5049 lint_caps : rustc_hash:: FxHashMap :: default ( ) ,
50+ parse_sess_created : None ,
5151 register_lints : None ,
5252 override_queries : None ,
5353 make_codegen_backend : None ,
@@ -57,8 +57,7 @@ fn main() {
5757 compiler. enter ( |queries| {
5858 // TODO: add this to -Z unpretty
5959 let ast_krate = queries. parse ( ) . unwrap ( ) . take ( ) ;
60- let ast_krate_mod = ast_krate. module ;
61- for item in ast_krate_mod. items {
60+ for item in ast_krate. items {
6261 println ! ( "{}" , item_to_string( & item) ) ;
6362 }
6463
@@ -75,7 +74,7 @@ fn main() {
7574 if let rustc_hir:: StmtKind :: Local ( local) = block. stmts [ 0 ] . kind {
7675 if let Some ( expr) = local. init {
7776 let hir_id = expr. hir_id ; // hir_id identifies the string "Hello, world!"
78- let def_id = tcx. hir ( ) . local_def_id ( item. hir_id ) ; // def_id identifies the main function
77+ let def_id = tcx. hir ( ) . local_def_id ( item. hir_id ( ) ) ; // def_id identifies the main function
7978 let ty = tcx. typeck ( def_id) . node_type ( hir_id) ;
8079 println ! ( "{:?}: {:?}" , expr, ty) ; // prints expr(HirId { owner: DefIndex(3), local_id: 4 }: "Hello, world!"): &'static str
8180 }
0 commit comments