about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-23 06:13:18 +0000
committerbors <bors@rust-lang.org>2021-10-23 06:13:18 +0000
commitcf708558b758f4473c4f35986d9492ace7bf906d (patch)
tree2f4b1fb7cff6c2182d10cc4903ed7826f9a72e06 /compiler/rustc_errors/src
parenta3f7c4db0373aa077f86cdd1bf11122845d3b65a (diff)
parenta05a1294d08e285f7039293298d9170fb3117013 (diff)
downloadrust-cf708558b758f4473c4f35986d9492ace7bf906d.tar.gz
rust-cf708558b758f4473c4f35986d9492ace7bf906d.zip
Auto merge of #90188 - matthiaskrgr:rollup-74cwv5c, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #83233 (Implement split_array and split_array_mut)
 - #88300 (Stabilise unix_process_wait_more, extra ExitStatusExt methods)
 - #89416 (nice_region_error: Include lifetime placeholders in error output)
 - #89468 (Report fatal lexer errors in `--cfg` command line arguments)
 - #89730 (add feature flag for `type_changing_struct_update`)
 - #89920 (Implement -Z location-detail flag)
 - #90070 (Add edition configuration to compiletest)
 - #90087 (Sync rustfmt subtree)
 - #90117 (Make RSplit<T, P>: Clone not require T: Clone)
 - #90122 (CI: make docker cache download and `docker load` time out after 10 minutes)
 - #90166 (Add comment documenting why we can't use a simpler solution)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/emitter.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 849ffa881df..e17604740f0 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -15,7 +15,7 @@ use rustc_span::{MultiSpan, SourceFile, Span};
 use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, Style, StyledString};
 use crate::styled_buffer::StyledBuffer;
 use crate::{
-    CodeSuggestion, Diagnostic, DiagnosticId, Level, SubDiagnostic, SubstitutionHighlight,
+    CodeSuggestion, Diagnostic, DiagnosticId, Handler, Level, SubDiagnostic, SubstitutionHighlight,
     SuggestionStyle,
 };
 
@@ -523,14 +523,27 @@ impl Emitter for EmitterWriter {
     }
 }
 
-/// An emitter that does nothing when emitting a diagnostic.
-pub struct SilentEmitter;
+/// An emitter that does nothing when emitting a non-fatal diagnostic.
+/// Fatal diagnostics are forwarded to `fatal_handler` to avoid silent
+/// failures of rustc, as witnessed e.g. in issue #89358.
+pub struct SilentEmitter {
+    pub fatal_handler: Handler,
+    pub fatal_note: Option<String>,
+}
 
 impl Emitter for SilentEmitter {
     fn source_map(&self) -> Option<&Lrc<SourceMap>> {
         None
     }
-    fn emit_diagnostic(&mut self, _: &Diagnostic) {}
+    fn emit_diagnostic(&mut self, d: &Diagnostic) {
+        if d.level == Level::Fatal {
+            let mut d = d.clone();
+            if let Some(ref note) = self.fatal_note {
+                d.note(note);
+            }
+            self.fatal_handler.emit_diagnostic(&d);
+        }
+    }
 }
 
 /// Maximum number of lines we will print for a multiline suggestion; arbitrary.