diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2019-06-22 12:46:48 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2019-06-22 15:36:24 +0100 |
| commit | 95a32157af8291b452570319c2d035a4307b52e6 (patch) | |
| tree | 74a5d5e775928290deb37128295ec77b475a5b3e /src/librustc_errors | |
| parent | 30b6c59f24cfb0e451e3df14ef536e4e40fe2672 (diff) | |
| download | rust-95a32157af8291b452570319c2d035a4307b52e6.tar.gz rust-95a32157af8291b452570319c2d035a4307b52e6.zip | |
Count all errors for `track_errors`
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/lib.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 082f981338a..70bd25a9d57 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -307,7 +307,12 @@ pub use diagnostic_builder::DiagnosticBuilder; pub struct Handler { pub flags: HandlerFlags, + /// The number of errors that have been emitted, including duplicates. + /// + /// This is not necessarily the count that's reported to the user once + /// compilation ends. err_count: AtomicUsize, + deduplicated_err_count: AtomicUsize, emitter: Lock<Box<dyn Emitter + sync::Send>>, continue_after_error: AtomicBool, delayed_span_bugs: Lock<Vec<Diagnostic>>, @@ -407,6 +412,7 @@ impl Handler { Handler { flags, err_count: AtomicUsize::new(0), + deduplicated_err_count: AtomicUsize::new(0), emitter: Lock::new(e), continue_after_error: AtomicBool::new(true), delayed_span_bugs: Lock::new(Vec::new()), @@ -428,6 +434,7 @@ impl Handler { pub fn reset_err_count(&self) { // actually frees the underlying memory (which `clear` would not do) *self.emitted_diagnostics.borrow_mut() = Default::default(); + self.deduplicated_err_count.store(0, SeqCst); self.err_count.store(0, SeqCst); } @@ -660,10 +667,10 @@ impl Handler { } pub fn print_error_count(&self, registry: &Registry) { - let s = match self.err_count() { + let s = match self.deduplicated_err_count.load(SeqCst) { 0 => return, 1 => "aborting due to previous error".to_string(), - _ => format!("aborting due to {} previous errors", self.err_count()) + count => format!("aborting due to {} previous errors", count) }; if self.treat_err_as_bug() { return; @@ -769,9 +776,12 @@ impl Handler { if self.emitted_diagnostics.borrow_mut().insert(diagnostic_hash) { self.emitter.borrow_mut().emit_diagnostic(db); if db.is_error() { - self.bump_err_count(); + self.deduplicated_err_count.fetch_add(1, SeqCst); } } + if db.is_error() { + self.bump_err_count(); + } } pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) { |
