@@ -77,6 +77,7 @@ pub enum PpFlowGraphMode {
7777pub enum PpMode {
7878 PpmSource ( PpSourceMode ) ,
7979 PpmHir ( PpSourceMode ) ,
80+ PpmHirTree ( PpSourceMode ) ,
8081 PpmFlowGraph ( PpFlowGraphMode ) ,
8182 PpmMir ,
8283 PpmMirCFG ,
@@ -93,6 +94,7 @@ impl PpMode {
9394 PpmSource ( PpmExpandedIdentified ) |
9495 PpmSource ( PpmExpandedHygiene ) |
9596 PpmHir ( _) |
97+ PpmHirTree ( _) |
9698 PpmMir |
9799 PpmMirCFG |
98100 PpmFlowGraph ( _) => true ,
@@ -125,6 +127,7 @@ pub fn parse_pretty(sess: &Session,
125127 ( "hir" , true ) => PpmHir ( PpmNormal ) ,
126128 ( "hir,identified" , true ) => PpmHir ( PpmIdentified ) ,
127129 ( "hir,typed" , true ) => PpmHir ( PpmTyped ) ,
130+ ( "hir-tree" , true ) => PpmHirTree ( PpmNormal ) ,
128131 ( "mir" , true ) => PpmMir ,
129132 ( "mir-cfg" , true ) => PpmMirCFG ,
130133 ( "flowgraph" , true ) => PpmFlowGraph ( PpFlowGraphMode :: Default ) ,
@@ -971,6 +974,23 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
971974 } )
972975 }
973976
977+ ( PpmHirTree ( s) , None ) => {
978+ let out: & mut Write = & mut out;
979+ s. call_with_pp_support_hir ( sess,
980+ cstore,
981+ hir_map,
982+ analysis,
983+ resolutions,
984+ arena,
985+ arenas,
986+ output_filenames,
987+ crate_name,
988+ move |_annotation, krate| {
989+ debug ! ( "pretty printing source code {:?}" , s) ;
990+ write ! ( out, "{:#?}" , krate)
991+ } )
992+ }
993+
974994 ( PpmHir ( s) , Some ( uii) ) => {
975995 let out: & mut Write = & mut out;
976996 s. call_with_pp_support_hir ( sess,
@@ -1005,6 +1025,28 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
10051025 pp_state. s . eof ( )
10061026 } )
10071027 }
1028+
1029+ ( PpmHirTree ( s) , Some ( uii) ) => {
1030+ let out: & mut Write = & mut out;
1031+ s. call_with_pp_support_hir ( sess,
1032+ cstore,
1033+ hir_map,
1034+ analysis,
1035+ resolutions,
1036+ arena,
1037+ arenas,
1038+ output_filenames,
1039+ crate_name,
1040+ move |_annotation, _krate| {
1041+ debug ! ( "pretty printing source code {:?}" , s) ;
1042+ for node_id in uii. all_matching_node_ids ( hir_map) {
1043+ let node = hir_map. get ( node_id) ;
1044+ write ! ( out, "{:#?}" , node) ?;
1045+ }
1046+ Ok ( ( ) )
1047+ } )
1048+ }
1049+
10081050 _ => unreachable ! ( ) ,
10091051 }
10101052 . unwrap ( ) ;
0 commit comments