@@ -471,21 +471,6 @@ pub fn print_after_hir_lowering<'tcx>(
471
471
format ! ( "{:#?}" , krate)
472
472
} ) ,
473
473
474
- ThirTree => {
475
- let mut out = String :: new ( ) ;
476
- abort_on_err ( rustc_typeck:: check_crate ( tcx) , tcx. sess ) ;
477
- debug ! ( "pretty printing THIR tree" ) ;
478
- for did in tcx. body_owners ( ) {
479
- let hir = tcx. hir ( ) ;
480
- let body = hir. body ( hir. body_owned_by ( hir. local_def_id_to_hir_id ( did) ) ) ;
481
- let arena = thir:: Arena :: default ( ) ;
482
- let thir =
483
- thir:: build_thir ( tcx, ty:: WithOptConstParam :: unknown ( did) , & arena, & body. value ) ;
484
- let _ = writeln ! ( out, "{:?}:\n {:#?}\n " , did, thir) ;
485
- }
486
- out
487
- }
488
-
489
474
_ => unreachable ! ( ) ,
490
475
} ;
491
476
@@ -501,18 +486,40 @@ fn print_with_analysis(
501
486
ppm : PpMode ,
502
487
ofile : Option < & Path > ,
503
488
) -> Result < ( ) , ErrorReported > {
504
- let mut out = Vec :: new ( ) ;
505
-
506
489
tcx. analysis ( LOCAL_CRATE ) ?;
507
490
508
- match ppm {
509
- Mir => write_mir_pretty ( tcx, None , & mut out) . unwrap ( ) ,
510
- MirCFG => write_mir_graphviz ( tcx, None , & mut out) . unwrap ( ) ,
491
+ let out = match ppm {
492
+ Mir => {
493
+ let mut out = Vec :: new ( ) ;
494
+ write_mir_pretty ( tcx, None , & mut out) . unwrap ( ) ;
495
+ String :: from_utf8 ( out) . unwrap ( )
496
+ }
497
+
498
+ MirCFG => {
499
+ let mut out = Vec :: new ( ) ;
500
+ write_mir_graphviz ( tcx, None , & mut out) . unwrap ( ) ;
501
+ String :: from_utf8 ( out) . unwrap ( )
502
+ }
503
+
504
+ ThirTree => {
505
+ let mut out = String :: new ( ) ;
506
+ abort_on_err ( rustc_typeck:: check_crate ( tcx) , tcx. sess ) ;
507
+ debug ! ( "pretty printing THIR tree" ) ;
508
+ for did in tcx. body_owners ( ) {
509
+ let hir = tcx. hir ( ) ;
510
+ let body = hir. body ( hir. body_owned_by ( hir. local_def_id_to_hir_id ( did) ) ) ;
511
+ let arena = thir:: Arena :: default ( ) ;
512
+ let thir =
513
+ thir:: build_thir ( tcx, ty:: WithOptConstParam :: unknown ( did) , & arena, & body. value ) ;
514
+ let _ = writeln ! ( out, "{:?}:\n {:#?}\n " , did, thir) ;
515
+ }
516
+ out
517
+ }
518
+
511
519
_ => unreachable ! ( ) ,
512
- }
520
+ } ;
513
521
514
- let out = std:: str:: from_utf8 ( & out) . unwrap ( ) ;
515
- write_or_print ( out, ofile) ;
522
+ write_or_print ( & out, ofile) ;
516
523
517
524
Ok ( ( ) )
518
525
}
0 commit comments