@@ -101,8 +101,8 @@ impl PpMode {
101
101
102
102
pub fn needs_analysis ( & self ) -> bool {
103
103
match * self {
104
- PpmMir | PpmMirCFG | PpmFlowGraph ( _) => true ,
105
- _ => false ,
104
+ PpmMir | PpmMirCFG | PpmFlowGraph ( _) => true ,
105
+ _ => false ,
106
106
}
107
107
}
108
108
}
@@ -233,14 +233,11 @@ impl PpSourceMode {
233
233
arenas,
234
234
id,
235
235
|tcx, _, _, _| {
236
- let annotation = TypedAnnotation {
237
- tcx : tcx,
238
- } ;
236
+ let annotation = TypedAnnotation { tcx : tcx } ;
239
237
let _ignore = tcx. dep_graph . in_ignore ( ) ;
240
- f ( & annotation,
241
- payload,
242
- ast_map. forest . krate ( ) )
243
- } ) , sess)
238
+ f ( & annotation, payload, ast_map. forest . krate ( ) )
239
+ } ) ,
240
+ sess)
244
241
}
245
242
_ => panic ! ( "Should use call_with_pp_support" ) ,
246
243
}
@@ -281,9 +278,11 @@ trait HirPrinterSupport<'ast>: pprust_hir::PpAnn {
281
278
/// Computes an user-readable representation of a path, if possible.
282
279
fn node_path ( & self , id : ast:: NodeId ) -> Option < String > {
283
280
self . ast_map ( ) . and_then ( |map| map. def_path_from_id ( id) ) . map ( |path| {
284
- path. data . into_iter ( ) . map ( |elem| {
285
- elem. data . to_string ( )
286
- } ) . collect :: < Vec < _ > > ( ) . join ( "::" )
281
+ path. data
282
+ . into_iter ( )
283
+ . map ( |elem| elem. data . to_string ( ) )
284
+ . collect :: < Vec < _ > > ( )
285
+ . join ( "::" )
287
286
} )
288
287
}
289
288
}
@@ -352,7 +351,8 @@ impl<'ast> pprust::PpAnn for IdentifiedAnnotation<'ast> {
352
351
}
353
352
fn post ( & self , s : & mut pprust:: State , node : pprust:: AnnNode ) -> io:: Result < ( ) > {
354
353
match node {
355
- pprust:: NodeIdent ( _) | pprust:: NodeName ( _) => Ok ( ( ) ) ,
354
+ pprust:: NodeIdent ( _) |
355
+ pprust:: NodeName ( _) => Ok ( ( ) ) ,
356
356
357
357
pprust:: NodeItem ( item) => {
358
358
pp:: space ( & mut s. s ) ?;
@@ -617,15 +617,14 @@ impl ReplaceBodyWithLoop {
617
617
impl fold:: Folder for ReplaceBodyWithLoop {
618
618
fn fold_item_kind ( & mut self , i : ast:: ItemKind ) -> ast:: ItemKind {
619
619
match i {
620
- ast:: ItemKind :: Static ( ..) | ast:: ItemKind :: Const ( ..) => {
620
+ ast:: ItemKind :: Static ( ..) |
621
+ ast:: ItemKind :: Const ( ..) => {
621
622
self . within_static_or_const = true ;
622
623
let ret = fold:: noop_fold_item_kind ( i, self ) ;
623
624
self . within_static_or_const = false ;
624
625
return ret;
625
626
}
626
- _ => {
627
- fold:: noop_fold_item_kind ( i, self )
628
- }
627
+ _ => fold:: noop_fold_item_kind ( i, self ) ,
629
628
}
630
629
}
631
630
@@ -656,11 +655,15 @@ impl fold::Folder for ReplaceBodyWithLoop {
656
655
fn fold_block ( & mut self , b : P < ast:: Block > ) -> P < ast:: Block > {
657
656
fn expr_to_block ( rules : ast:: BlockCheckMode , e : Option < P < ast:: Expr > > ) -> P < ast:: Block > {
658
657
P ( ast:: Block {
659
- stmts : e. map ( |e| ast:: Stmt {
660
- id : ast:: DUMMY_NODE_ID ,
661
- span : e. span ,
662
- node : ast:: StmtKind :: Expr ( e) ,
663
- } ) . into_iter ( ) . collect ( ) ,
658
+ stmts : e. map ( |e| {
659
+ ast:: Stmt {
660
+ id : ast:: DUMMY_NODE_ID ,
661
+ span : e. span ,
662
+ node : ast:: StmtKind :: Expr ( e) ,
663
+ }
664
+ } )
665
+ . into_iter ( )
666
+ . collect ( ) ,
664
667
rules : rules,
665
668
id : ast:: DUMMY_NODE_ID ,
666
669
span : syntax_pos:: DUMMY_SP ,
@@ -721,9 +724,7 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
721
724
}
722
725
blocks:: FnLikeCode ( fn_like) => {
723
726
let ( bccx, analysis_data) =
724
- borrowck:: build_borrowck_dataflow_data_for_fn ( tcx,
725
- fn_like. to_fn_parts ( ) ,
726
- & cfg) ;
727
+ borrowck:: build_borrowck_dataflow_data_for_fn ( tcx, fn_like. to_fn_parts ( ) , & cfg) ;
727
728
728
729
let lcfg = borrowck_dot:: DataflowLabeller {
729
730
inner : lcfg,
@@ -756,13 +757,13 @@ pub fn fold_crate(krate: ast::Crate, ppm: PpMode) -> ast::Crate {
756
757
fn get_source ( input : & Input , sess : & Session ) -> ( Vec < u8 > , String ) {
757
758
let src_name = driver:: source_name ( input) ;
758
759
let src = sess. codemap ( )
759
- . get_filemap ( & src_name)
760
- . unwrap ( )
761
- . src
762
- . as_ref ( )
763
- . unwrap ( )
764
- . as_bytes ( )
765
- . to_vec ( ) ;
760
+ . get_filemap ( & src_name)
761
+ . unwrap ( )
762
+ . src
763
+ . as_ref ( )
764
+ . unwrap ( )
765
+ . as_bytes ( )
766
+ . to_vec ( ) ;
766
767
( src, src_name)
767
768
}
768
769
@@ -795,17 +796,18 @@ pub fn print_after_parsing(sess: &Session,
795
796
// Silently ignores an identified node.
796
797
let out: & mut Write = & mut out;
797
798
s. call_with_pp_support ( sess, None , box out, |annotation, out| {
798
- debug ! ( "pretty printing source code {:?}" , s) ;
799
- let sess = annotation. sess ( ) ;
800
- pprust:: print_crate ( sess. codemap ( ) ,
801
- sess. diagnostic ( ) ,
802
- krate,
803
- src_name. to_string ( ) ,
804
- & mut rdr,
805
- out,
806
- annotation. pp_ann ( ) ,
807
- false )
808
- } ) . unwrap ( )
799
+ debug ! ( "pretty printing source code {:?}" , s) ;
800
+ let sess = annotation. sess ( ) ;
801
+ pprust:: print_crate ( sess. codemap ( ) ,
802
+ sess. diagnostic ( ) ,
803
+ krate,
804
+ src_name. to_string ( ) ,
805
+ & mut rdr,
806
+ out,
807
+ annotation. pp_ann ( ) ,
808
+ false )
809
+ } )
810
+ . unwrap ( )
809
811
} else {
810
812
unreachable ! ( ) ;
811
813
} ;
@@ -828,8 +830,15 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
828
830
let _ignore = dep_graph. in_ignore ( ) ;
829
831
830
832
if ppm. needs_analysis ( ) {
831
- print_with_analysis ( sess, ast_map, analysis, resolutions,
832
- crate_name, arenas, ppm, opt_uii, ofile) ;
833
+ print_with_analysis ( sess,
834
+ ast_map,
835
+ analysis,
836
+ resolutions,
837
+ crate_name,
838
+ arenas,
839
+ ppm,
840
+ opt_uii,
841
+ ofile) ;
833
842
return ;
834
843
}
835
844
@@ -839,82 +848,82 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
839
848
let mut out = Vec :: new ( ) ;
840
849
841
850
match ( ppm, opt_uii) {
842
- ( PpmSource ( s) , _) => {
843
- // Silently ignores an identified node.
844
- let out: & mut Write = & mut out;
845
- s. call_with_pp_support ( sess, Some ( ast_map) , box out, |annotation, out| {
846
- debug ! ( "pretty printing source code {:?}" , s) ;
847
- let sess = annotation. sess ( ) ;
848
- pprust:: print_crate ( sess. codemap ( ) ,
849
- sess. diagnostic ( ) ,
850
- krate,
851
- src_name. to_string ( ) ,
852
- & mut rdr,
853
- out,
854
- annotation. pp_ann ( ) ,
855
- true )
856
- } )
857
- }
851
+ ( PpmSource ( s) , _) => {
852
+ // Silently ignores an identified node.
853
+ let out: & mut Write = & mut out;
854
+ s. call_with_pp_support ( sess, Some ( ast_map) , box out, |annotation, out| {
855
+ debug ! ( "pretty printing source code {:?}" , s) ;
856
+ let sess = annotation. sess ( ) ;
857
+ pprust:: print_crate ( sess. codemap ( ) ,
858
+ sess. diagnostic ( ) ,
859
+ krate,
860
+ src_name. to_string ( ) ,
861
+ & mut rdr,
862
+ out,
863
+ annotation. pp_ann ( ) ,
864
+ true )
865
+ } )
866
+ }
858
867
859
- ( PpmHir ( s) , None ) => {
860
- let out: & mut Write = & mut out;
861
- s. call_with_pp_support_hir ( sess,
862
- ast_map,
863
- analysis,
864
- resolutions,
865
- arenas,
866
- crate_name,
867
- box out,
868
- |annotation, out, krate| {
869
- debug ! ( "pretty printing source code {:?}" , s) ;
870
- let sess = annotation. sess ( ) ;
871
- pprust_hir:: print_crate ( sess. codemap ( ) ,
872
- sess. diagnostic ( ) ,
873
- krate,
874
- src_name. to_string ( ) ,
875
- & mut rdr,
876
- out,
877
- annotation. pp_ann ( ) ,
878
- true )
879
- } )
880
- }
868
+ ( PpmHir ( s) , None ) => {
869
+ let out: & mut Write = & mut out;
870
+ s. call_with_pp_support_hir ( sess,
871
+ ast_map,
872
+ analysis,
873
+ resolutions,
874
+ arenas,
875
+ crate_name,
876
+ box out,
877
+ |annotation, out, krate| {
878
+ debug ! ( "pretty printing source code {:?}" , s) ;
879
+ let sess = annotation. sess ( ) ;
880
+ pprust_hir:: print_crate ( sess. codemap ( ) ,
881
+ sess. diagnostic ( ) ,
882
+ krate,
883
+ src_name. to_string ( ) ,
884
+ & mut rdr,
885
+ out,
886
+ annotation. pp_ann ( ) ,
887
+ true )
888
+ } )
889
+ }
881
890
882
- ( PpmHir ( s) , Some ( uii) ) => {
883
- let out: & mut Write = & mut out;
884
- s. call_with_pp_support_hir ( sess,
885
- ast_map,
886
- analysis,
887
- resolutions,
888
- arenas,
889
- crate_name,
890
- ( out, uii) ,
891
- |annotation, ( out, uii) , _| {
892
- debug ! ( "pretty printing source code {:?}" , s) ;
893
- let sess = annotation. sess ( ) ;
894
- let ast_map = annotation. ast_map ( ) . expect ( "--unpretty missing HIR map" ) ;
895
- let mut pp_state =
896
- pprust_hir :: State :: new_from_input ( sess. codemap ( ) ,
897
- sess . diagnostic ( ) ,
898
- src_name . to_string ( ) ,
899
- & mut rdr ,
900
- box out ,
901
- annotation . pp_ann ( ) ,
902
- true ,
903
- Some ( ast_map . krate ( ) ) ) ;
904
- for node_id in uii . all_matching_node_ids ( ast_map ) {
905
- let node = ast_map . get ( node_id ) ;
906
- pp_state . print_node ( & node ) ?;
907
- pp :: space ( & mut pp_state . s ) ? ;
908
- let path = annotation . node_path ( node_id )
909
- . expect ( "--unpretty missing node paths" ) ;
910
- pp_state. synth_comment ( path ) ?;
911
- pp :: hardbreak ( & mut pp_state . s ) ? ;
912
- }
913
- pp :: eof ( & mut pp_state . s )
914
- } )
915
- }
916
- _ => unreachable ! ( ) ,
917
- } . unwrap ( ) ;
891
+ ( PpmHir ( s) , Some ( uii) ) => {
892
+ let out: & mut Write = & mut out;
893
+ s. call_with_pp_support_hir ( sess,
894
+ ast_map,
895
+ analysis,
896
+ resolutions,
897
+ arenas,
898
+ crate_name,
899
+ ( out, uii) ,
900
+ |annotation, ( out, uii) , _| {
901
+ debug ! ( "pretty printing source code {:?}" , s) ;
902
+ let sess = annotation. sess ( ) ;
903
+ let ast_map = annotation. ast_map ( ) . expect ( "--unpretty missing HIR map" ) ;
904
+ let mut pp_state = pprust_hir :: State :: new_from_input ( sess . codemap ( ) ,
905
+ sess. diagnostic ( ) ,
906
+ src_name . to_string ( ) ,
907
+ & mut rdr ,
908
+ box out ,
909
+ annotation . pp_ann ( ) ,
910
+ true ,
911
+ Some ( ast_map . krate ( ) ) ) ;
912
+ for node_id in uii . all_matching_node_ids ( ast_map ) {
913
+ let node = ast_map . get ( node_id ) ;
914
+ pp_state . print_node ( & node ) ? ;
915
+ pp :: space ( & mut pp_state . s ) ?;
916
+ let path = annotation . node_path ( node_id )
917
+ . expect ( "--unpretty missing node paths" ) ;
918
+ pp_state . synth_comment ( path ) ? ;
919
+ pp :: hardbreak ( & mut pp_state. s ) ?;
920
+ }
921
+ pp :: eof ( & mut pp_state . s )
922
+ } )
923
+ }
924
+ _ => unreachable ! ( ) ,
925
+ }
926
+ . unwrap ( ) ;
918
927
919
928
write_output ( out, ofile) ;
920
929
}
@@ -955,27 +964,28 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
955
964
let def_id = tcx. map . local_def_id ( nodeid) ;
956
965
match ppm {
957
966
PpmMir => write_mir_pretty ( tcx, iter:: once ( def_id) , & mut out) ,
958
- PpmMirCFG => {
959
- write_mir_graphviz ( tcx, iter:: once ( def_id) , & mut out)
960
- }
967
+ PpmMirCFG => write_mir_graphviz ( tcx, iter:: once ( def_id) , & mut out) ,
961
968
_ => unreachable ! ( ) ,
962
969
} ?;
963
970
} else {
964
971
match ppm {
965
- PpmMir => write_mir_pretty ( tcx,
966
- tcx. mir_map . borrow ( ) . keys ( ) . into_iter ( ) ,
967
- & mut out) ,
968
- PpmMirCFG => write_mir_graphviz ( tcx,
969
- tcx. mir_map . borrow ( ) . keys ( ) . into_iter ( ) ,
970
- & mut out) ,
972
+ PpmMir => {
973
+ write_mir_pretty ( tcx, tcx. mir_map . borrow ( ) . keys ( ) . into_iter ( ) , & mut out)
974
+ }
975
+ PpmMirCFG => {
976
+ write_mir_graphviz ( tcx,
977
+ tcx. mir_map . borrow ( ) . keys ( ) . into_iter ( ) ,
978
+ & mut out)
979
+ }
971
980
_ => unreachable ! ( ) ,
972
981
} ?;
973
982
}
974
983
Ok ( ( ) )
975
984
}
976
985
PpmFlowGraph ( mode) => {
977
- let nodeid = nodeid. expect ( "`pretty flowgraph=..` needs NodeId (int) or \
978
- unique path suffix (b::c::d)") ;
986
+ let nodeid =
987
+ nodeid. expect ( "`pretty flowgraph=..` needs NodeId (int) or unique path \
988
+ suffix (b::c::d)") ;
979
989
let node = tcx. map . find ( nodeid) . unwrap_or_else ( || {
980
990
tcx. sess . fatal ( & format ! ( "--pretty flowgraph couldn't find id: {}" , nodeid) )
981
991
} ) ;
@@ -990,8 +1000,8 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
990
1000
print_flowgraph ( variants, tcx, code, mode, out)
991
1001
}
992
1002
None => {
993
- let message = format ! ( "--pretty=flowgraph needs block, fn, or method; got \
994
- {:?}",
1003
+ let message = format ! ( "--pretty=flowgraph needs block, fn, or method; \
1004
+ got {:?}",
995
1005
node) ;
996
1006
997
1007
// Point to what was found, if there's an accessible span.
@@ -1004,7 +1014,9 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
1004
1014
}
1005
1015
_ => unreachable ! ( ) ,
1006
1016
}
1007
- } ) , sess) . unwrap ( ) ;
1017
+ } ) ,
1018
+ sess)
1019
+ . unwrap ( ) ;
1008
1020
1009
1021
write_output ( out, ofile) ;
1010
1022
}
0 commit comments