22
33use rustc_ast as ast;
44use rustc_ast_pretty:: pprust as pprust_ast;
5+ use rustc_errors:: FatalError ;
56use rustc_hir as hir;
67use rustc_hir_pretty as pprust_hir;
78use rustc_middle:: bug;
@@ -18,7 +19,6 @@ use std::fmt::Write;
1819
1920pub use self :: PpMode :: * ;
2021pub use self :: PpSourceMode :: * ;
21- use crate :: abort_on_err;
2222
2323struct AstNoAnn ;
2424
@@ -243,7 +243,10 @@ impl<'tcx> PrintExtra<'tcx> {
243243
244244pub fn print < ' tcx > ( sess : & Session , ppm : PpMode , ex : PrintExtra < ' tcx > ) {
245245 if ppm. needs_analysis ( ) {
246- abort_on_err ( ex. tcx ( ) . analysis ( ( ) ) , sess) ;
246+ let res = ex. tcx ( ) . analysis ( ( ) ) ;
247+ if res. is_err ( ) {
248+ FatalError . raise ( ) ;
249+ }
247250 }
248251
249252 let ( src, src_name) = get_source ( sess) ;
@@ -334,7 +337,10 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
334337 ThirTree => {
335338 let tcx = ex. tcx ( ) ;
336339 let mut out = String :: new ( ) ;
337- abort_on_err ( rustc_hir_analysis:: check_crate ( tcx) , tcx. sess ) ;
340+ let res = rustc_hir_analysis:: check_crate ( tcx) ;
341+ if res. is_err ( ) {
342+ FatalError . raise ( ) ;
343+ }
338344 debug ! ( "pretty printing THIR tree" ) ;
339345 for did in tcx. hir ( ) . body_owners ( ) {
340346 let _ = writeln ! ( out, "{:?}:\n {}\n " , did, tcx. thir_tree( did) ) ;
@@ -344,7 +350,10 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
344350 ThirFlat => {
345351 let tcx = ex. tcx ( ) ;
346352 let mut out = String :: new ( ) ;
347- abort_on_err ( rustc_hir_analysis:: check_crate ( tcx) , tcx. sess ) ;
353+ let res = rustc_hir_analysis:: check_crate ( tcx) ;
354+ if res. is_err ( ) {
355+ FatalError . raise ( ) ;
356+ }
348357 debug ! ( "pretty printing THIR flat" ) ;
349358 for did in tcx. hir ( ) . body_owners ( ) {
350359 let _ = writeln ! ( out, "{:?}:\n {}\n " , did, tcx. thir_flat( did) ) ;
0 commit comments