@@ -3,7 +3,7 @@ use rustc_data_structures::sync::Lrc;
33use rustc_data_structures:: unord:: UnordSet ;
44use rustc_errors:: emitter:: { DynEmitter , HumanEmitter } ;
55use rustc_errors:: json:: JsonEmitter ;
6- use rustc_errors:: { codes:: * , TerminalUrl } ;
6+ use rustc_errors:: { codes:: * , ErrorGuaranteed , TerminalUrl } ;
77use rustc_feature:: UnstableFeatures ;
88use rustc_hir:: def:: Res ;
99use rustc_hir:: def_id:: { DefId , DefIdMap , DefIdSet , LocalDefId } ;
@@ -306,7 +306,7 @@ pub(crate) fn run_global_ctxt(
306306 show_coverage : bool ,
307307 render_options : RenderOptions ,
308308 output_format : OutputFormat ,
309- ) -> ( clean:: Crate , RenderOptions , Cache ) {
309+ ) -> Result < ( clean:: Crate , RenderOptions , Cache ) , ErrorGuaranteed > {
310310 // Certain queries assume that some checks were run elsewhere
311311 // (see https://github.com/rust-lang/rust/pull/73566#issuecomment-656954425),
312312 // so type-check everything other than function bodies in this crate before running lints.
@@ -331,7 +331,10 @@ pub(crate) fn run_global_ctxt(
331331 } ) ;
332332 } ) ;
333333
334- tcx. dcx ( ) . abort_if_errors ( ) ;
334+ if let Some ( guar) = tcx. dcx ( ) . has_errors ( ) {
335+ return Err ( guar) ;
336+ }
337+
335338 tcx. sess . time ( "missing_docs" , || rustc_lint:: check_crate ( tcx) ) ;
336339 tcx. sess . time ( "check_mod_attrs" , || {
337340 tcx. hir ( ) . for_each_module ( |module| tcx. ensure ( ) . check_mod_attrs ( module) )
@@ -452,13 +455,13 @@ pub(crate) fn run_global_ctxt(
452455
453456 tcx. sess . time ( "check_lint_expectations" , || tcx. check_expectations ( Some ( sym:: rustdoc) ) ) ;
454457
455- if tcx. dcx ( ) . has_errors ( ) . is_some ( ) {
456- rustc_errors :: FatalError . raise ( ) ;
458+ if let Some ( guar ) = tcx. dcx ( ) . has_errors ( ) {
459+ return Err ( guar ) ;
457460 }
458461
459462 krate = tcx. sess . time ( "create_format_cache" , || Cache :: populate ( & mut ctxt, krate) ) ;
460463
461- ( krate, ctxt. render_options , ctxt. cache )
464+ Ok ( ( krate, ctxt. render_options , ctxt. cache ) )
462465}
463466
464467/// Due to <https://github.com/rust-lang/rust/pull/73566>,
0 commit comments