about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-09-18 09:06:42 +0000
committerbors <bors@rust-lang.org>2018-09-18 09:06:42 +0000
commitf004cae5360c4a3f365c7f7525b4293559201ce2 (patch)
treea7b22fceebae88f7eceb23b669c63d88c4a37102 /src/librustc_errors
parent36c0ee97b9f888d576fe4302b0aad846b4446e6c (diff)
parent85d214e7bdbb587878b2ff691eaba23611729511 (diff)
downloadrust-f004cae5360c4a3f365c7f7525b4293559201ce2.tar.gz
rust-f004cae5360c4a3f365c7f7525b4293559201ce2.zip
Auto merge of #54319 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - #53522 (Add doc for impl From for Addr)
 - #54097 (rustdoc: Remove namespace for keywords)
 - #54205 (Add treat-err-as-bug flag in rustdoc)
 - #54225 (Regression test for rust-lang/rust#53675.)
 - #54232 (add `-Z dont-buffer-diagnostics`)
 - #54273 (Suggest to change numeric literal instead of casting)
 - #54299 (Issue 54246)
 - #54311 (Remove README with now-out-of-date docs about docs.)
 - #54313 (OsStr: Document that it's not NUL terminated)

Failed merges:

r? @ghost
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/diagnostic_builder.rs14
-rw-r--r--src/librustc_errors/lib.rs11
2 files changed, 23 insertions, 2 deletions
diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs
index 1b34898b990..5e962a4af32 100644
--- a/src/librustc_errors/diagnostic_builder.rs
+++ b/src/librustc_errors/diagnostic_builder.rs
@@ -21,6 +21,10 @@ use std::thread::panicking;
 use syntax_pos::{MultiSpan, Span};
 
 /// Used for emitting structured error messages and other diagnostic information.
+///
+/// If there is some state in a downstream crate you would like to
+/// access in the methods of `DiagnosticBuilder` here, consider
+/// extending `HandlerFlags`, accessed via `self.handler.flags`.
 #[must_use]
 #[derive(Clone)]
 pub struct DiagnosticBuilder<'a> {
@@ -89,8 +93,14 @@ impl<'a> DiagnosticBuilder<'a> {
         self.cancel();
     }
 
-    /// Buffers the diagnostic for later emission.
-    pub fn buffer(self, buffered_diagnostics: &mut Vec<Diagnostic>) {
+    /// Buffers the diagnostic for later emission, unless handler
+    /// has disabled such buffering.
+    pub fn buffer(mut self, buffered_diagnostics: &mut Vec<Diagnostic>) {
+        if self.handler.flags.dont_buffer_diagnostics || self.handler.flags.treat_err_as_bug {
+            self.emit();
+            return;
+        }
+
         // We need to use `ptr::read` because `DiagnosticBuilder`
         // implements `Drop`.
         let diagnostic;
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 3582c2359c8..d0ea6fba5eb 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -303,9 +303,20 @@ thread_local!(pub static TRACK_DIAGNOSTICS: Cell<fn(&Diagnostic)> =
 
 #[derive(Default)]
 pub struct HandlerFlags {
+    /// If false, warning-level lints are suppressed.
+    /// (rustc: see `--allow warnings` and `--cap-lints`)
     pub can_emit_warnings: bool,
+    /// If true, error-level diagnostics are upgraded to bug-level.
+    /// (rustc: see `-Z treat-err-as-bug`)
     pub treat_err_as_bug: bool,
+    /// If true, immediately emit diagnostics that would otherwise be buffered.
+    /// (rustc: see `-Z dont-buffer-diagnostics` and `-Z treat-err-as-bug`)
+    pub dont_buffer_diagnostics: bool,
+    /// If true, immediately print bugs registered with `delay_span_bug`.
+    /// (rustc: see `-Z report-delayed-bugs`)
     pub report_delayed_bugs: bool,
+    /// show macro backtraces even for non-local macros.
+    /// (rustc: see `-Z external-macro-backtrace`)
     pub external_macro_backtrace: bool,
 }