@@ -15,7 +15,7 @@ use rustc_span::{MultiSpan, SourceFile, Span};
15
15
use crate :: snippet:: { Annotation , AnnotationType , Line , MultilineAnnotation , Style , StyledString } ;
16
16
use crate :: styled_buffer:: StyledBuffer ;
17
17
use crate :: {
18
- CodeSuggestion , Diagnostic , DiagnosticId , Level , SubDiagnostic , SubstitutionHighlight ,
18
+ CodeSuggestion , Diagnostic , DiagnosticId , Handler , Level , SubDiagnostic , SubstitutionHighlight ,
19
19
SuggestionStyle ,
20
20
} ;
21
21
@@ -527,14 +527,27 @@ impl Emitter for EmitterWriter {
527
527
}
528
528
}
529
529
530
- /// An emitter that does nothing when emitting a diagnostic.
531
- pub struct SilentEmitter ;
530
+ /// An emitter that does nothing when emitting a non-fatal diagnostic.
531
+ /// Fatal diagnostics are forwarded to `fatal_handler` to avoid silent
532
+ /// failures of rustc, as witnessed e.g. in issue #89358.
533
+ pub struct SilentEmitter {
534
+ pub fatal_handler : Handler ,
535
+ pub fatal_note : Option < String > ,
536
+ }
532
537
533
538
impl Emitter for SilentEmitter {
534
539
fn source_map ( & self ) -> Option < & Lrc < SourceMap > > {
535
540
None
536
541
}
537
- fn emit_diagnostic ( & mut self , _: & Diagnostic ) { }
542
+ fn emit_diagnostic ( & mut self , d : & Diagnostic ) {
543
+ if d. level == Level :: Fatal {
544
+ let mut d = d. clone ( ) ;
545
+ if let Some ( ref note) = self . fatal_note {
546
+ d. note ( note) ;
547
+ }
548
+ self . fatal_handler . emit_diagnostic ( & d) ;
549
+ }
550
+ }
538
551
}
539
552
540
553
/// Maximum number of lines we will print for a multiline suggestion; arbitrary.
0 commit comments