@@ -728,11 +728,11 @@ pub fn print_after_parsing(sess: &Session,
728
728
let ( src, src_name) = get_source ( input, sess) ;
729
729
730
730
let mut rdr = & * src;
731
- let mut out = Vec :: new ( ) ;
731
+ let mut out = String :: new ( ) ;
732
732
733
733
if let PpmSource ( s) = ppm {
734
734
// Silently ignores an identified node.
735
- let out: & mut dyn Write = & mut out;
735
+ let out = & mut out;
736
736
s. call_with_pp_support ( sess, None , move |annotation| {
737
737
debug ! ( "pretty printing source code {:?}" , s) ;
738
738
let sess = annotation. sess ( ) ;
@@ -741,15 +741,15 @@ pub fn print_after_parsing(sess: &Session,
741
741
krate,
742
742
src_name,
743
743
& mut rdr,
744
- box out,
744
+ out,
745
745
annotation. pp_ann ( ) ,
746
746
false )
747
747
} ) . unwrap ( )
748
748
} else {
749
749
unreachable ! ( ) ;
750
750
} ;
751
751
752
- write_output ( out, ofile) ;
752
+ write_output ( out. into_bytes ( ) , ofile) ;
753
753
}
754
754
755
755
pub fn print_after_hir_lowering < ' tcx > (
@@ -773,12 +773,12 @@ pub fn print_after_hir_lowering<'tcx>(
773
773
let ( src, src_name) = get_source ( input, tcx. sess ) ;
774
774
775
775
let mut rdr = & src[ ..] ;
776
- let mut out = Vec :: new ( ) ;
776
+ let mut out = String :: new ( ) ;
777
777
778
778
match ( ppm, opt_uii) {
779
779
( PpmSource ( s) , _) => {
780
780
// Silently ignores an identified node.
781
- let out: & mut dyn Write = & mut out;
781
+ let out = & mut out;
782
782
s. call_with_pp_support ( tcx. sess , Some ( tcx) , move |annotation| {
783
783
debug ! ( "pretty printing source code {:?}" , s) ;
784
784
let sess = annotation. sess ( ) ;
@@ -787,14 +787,14 @@ pub fn print_after_hir_lowering<'tcx>(
787
787
krate,
788
788
src_name,
789
789
& mut rdr,
790
- box out,
790
+ out,
791
791
annotation. pp_ann ( ) ,
792
792
true )
793
793
} )
794
794
}
795
795
796
796
( PpmHir ( s) , None ) => {
797
- let out: & mut dyn Write = & mut out;
797
+ let out = & mut out;
798
798
s. call_with_pp_support_hir ( tcx, move |annotation, krate| {
799
799
debug ! ( "pretty printing source code {:?}" , s) ;
800
800
let sess = annotation. sess ( ) ;
@@ -803,21 +803,21 @@ pub fn print_after_hir_lowering<'tcx>(
803
803
krate,
804
804
src_name,
805
805
& mut rdr,
806
- box out,
806
+ out,
807
807
annotation. pp_ann ( ) )
808
808
} )
809
809
}
810
810
811
811
( PpmHirTree ( s) , None ) => {
812
- let out: & mut dyn Write = & mut out;
812
+ let out = & mut out;
813
813
s. call_with_pp_support_hir ( tcx, move |_annotation, krate| {
814
814
debug ! ( "pretty printing source code {:?}" , s) ;
815
- write ! ( out, "{:#?}" , krate)
816
- } )
815
+ * out = format ! ( "{:#?}" , krate) ;
816
+ } ) ;
817
817
}
818
818
819
819
( PpmHir ( s) , Some ( uii) ) => {
820
- let out: & mut dyn Write = & mut out;
820
+ let out = & mut out;
821
821
s. call_with_pp_support_hir ( tcx, move |annotation, _| {
822
822
debug ! ( "pretty printing source code {:?}" , s) ;
823
823
let sess = annotation. sess ( ) ;
@@ -826,7 +826,7 @@ pub fn print_after_hir_lowering<'tcx>(
826
826
& sess. parse_sess ,
827
827
src_name,
828
828
& mut rdr,
829
- box out,
829
+ out,
830
830
annotation. pp_ann ( ) ) ;
831
831
for node_id in uii. all_matching_node_ids ( hir_map) {
832
832
let hir_id = tcx. hir ( ) . node_to_hir_id ( node_id) ;
@@ -843,13 +843,13 @@ pub fn print_after_hir_lowering<'tcx>(
843
843
}
844
844
845
845
( PpmHirTree ( s) , Some ( uii) ) => {
846
- let out: & mut dyn Write = & mut out;
846
+ let out = & mut out;
847
847
s. call_with_pp_support_hir ( tcx, move |_annotation, _krate| {
848
848
debug ! ( "pretty printing source code {:?}" , s) ;
849
849
for node_id in uii. all_matching_node_ids ( tcx. hir ( ) ) {
850
850
let hir_id = tcx. hir ( ) . node_to_hir_id ( node_id) ;
851
851
let node = tcx. hir ( ) . get ( hir_id) ;
852
- write ! ( out , "{:#?}" , node) ? ;
852
+ out . push_str ( & format ! ( "{:#?}" , node) ) ;
853
853
}
854
854
Ok ( ( ) )
855
855
} )
@@ -859,7 +859,7 @@ pub fn print_after_hir_lowering<'tcx>(
859
859
}
860
860
. unwrap ( ) ;
861
861
862
- write_output ( out, ofile) ;
862
+ write_output ( out. into_bytes ( ) , ofile) ;
863
863
}
864
864
865
865
// In an ideal world, this would be a public function called by the driver after
0 commit comments