@@ -3,7 +3,7 @@ use rustc_data_structures::sync::Lrc;
3
3
use rustc_data_structures:: unord:: UnordSet ;
4
4
use rustc_errors:: emitter:: { DynEmitter , HumanEmitter } ;
5
5
use rustc_errors:: json:: JsonEmitter ;
6
- use rustc_errors:: { codes:: * , TerminalUrl } ;
6
+ use rustc_errors:: { codes:: * , ErrorGuaranteed , TerminalUrl } ;
7
7
use rustc_feature:: UnstableFeatures ;
8
8
use rustc_hir:: def:: Res ;
9
9
use rustc_hir:: def_id:: { DefId , DefIdMap , DefIdSet , LocalDefId } ;
@@ -306,7 +306,7 @@ pub(crate) fn run_global_ctxt(
306
306
show_coverage : bool ,
307
307
render_options : RenderOptions ,
308
308
output_format : OutputFormat ,
309
- ) -> ( clean:: Crate , RenderOptions , Cache ) {
309
+ ) -> Result < ( clean:: Crate , RenderOptions , Cache ) , ErrorGuaranteed > {
310
310
// Certain queries assume that some checks were run elsewhere
311
311
// (see https://github.com/rust-lang/rust/pull/73566#issuecomment-656954425),
312
312
// so type-check everything other than function bodies in this crate before running lints.
@@ -331,7 +331,10 @@ pub(crate) fn run_global_ctxt(
331
331
} ) ;
332
332
} ) ;
333
333
334
- tcx. dcx ( ) . abort_if_errors ( ) ;
334
+ if let Some ( guar) = tcx. dcx ( ) . has_errors ( ) {
335
+ return Err ( guar) ;
336
+ }
337
+
335
338
tcx. sess . time ( "missing_docs" , || rustc_lint:: check_crate ( tcx) ) ;
336
339
tcx. sess . time ( "check_mod_attrs" , || {
337
340
tcx. hir ( ) . for_each_module ( |module| tcx. ensure ( ) . check_mod_attrs ( module) )
@@ -452,13 +455,13 @@ pub(crate) fn run_global_ctxt(
452
455
453
456
tcx. sess . time ( "check_lint_expectations" , || tcx. check_expectations ( Some ( sym:: rustdoc) ) ) ;
454
457
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 ) ;
457
460
}
458
461
459
462
krate = tcx. sess . time ( "create_format_cache" , || Cache :: populate ( & mut ctxt, krate) ) ;
460
463
461
- ( krate, ctxt. render_options , ctxt. cache )
464
+ Ok ( ( krate, ctxt. render_options , ctxt. cache ) )
462
465
}
463
466
464
467
/// Due to <https://github.com/rust-lang/rust/pull/73566>,
0 commit comments