diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2018-07-18 18:10:08 -0300 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-07-23 14:20:12 +0200 |
| commit | 3d3e0aa57190db4519d4e59ab606f685c21bfc7f (patch) | |
| tree | e8a3c3d4776e5fd085aee38b85e802cde873d062 /src/librustc_errors | |
| parent | da935e96a11973c4ee3470f1b831eba1ac7a87c3 (diff) | |
| download | rust-3d3e0aa57190db4519d4e59ab606f685c21bfc7f.tar.gz rust-3d3e0aa57190db4519d4e59ab606f685c21bfc7f.zip | |
Buffer errors in MIR borrow check
(pnkfelix updated to address tidy, and to change the buffer from `Vec<DiagnosticBuilder<'errs>>` to a `Vec<Diagnostic>` in order to avoid painful lifetime maintenance.)
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/diagnostic_builder.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 24ece514a47..8f99ad87cb8 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -88,6 +88,18 @@ impl<'a> DiagnosticBuilder<'a> { self.cancel(); } + /// Buffers the diagnostic for later emission. + pub fn buffer(self, buffered_diagnostics: &mut Vec<Diagnostic>) { + // We need to use `ptr::read` because `DiagnosticBuilder` + // implements `Drop`. + let diagnostic; + unsafe { + diagnostic = ::std::ptr::read(&self.diagnostic); + ::std::mem::forget(self); + }; + buffered_diagnostics.push(diagnostic); + } + pub fn is_error(&self) -> bool { match self.level { Level::Bug | |
