summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-03-11 16:43:27 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-05-10 19:41:10 +0200
commit5cccda1770f76b8184ea55e4735ce88f824f7fd8 (patch)
tree8f40dad8b22d19fcc2e80657f40a1e5161c1d72b /src/librustc_errors
parent0ac53da03dad79655e2f3e65a58f94a2f3314d5f (diff)
downloadrust-5cccda1770f76b8184ea55e4735ce88f824f7fd8.tar.gz
rust-5cccda1770f76b8184ea55e4735ce88f824f7fd8.zip
Remove hir::ExprKind::If and replace it with lowering to hir::ExprKind::Match.
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/diagnostic_builder.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs
index f74dcd6070c..31f697a724a 100644
--- a/src/librustc_errors/diagnostic_builder.rs
+++ b/src/librustc_errors/diagnostic_builder.rs
@@ -100,6 +100,18 @@ impl<'a> DiagnosticBuilder<'a> {
         self.cancel();
     }
 
+    /// Emit the diagnostic unless `delay` is true,
+    /// in which case the emission will be delayed as a bug.
+    ///
+    /// See `emit` and `delay_as_bug` for details.
+    pub fn emit_unless(&mut self, delay: bool) {
+        if delay {
+            self.delay_as_bug()
+        } else {
+            self.emit()
+        }
+    }
+
     /// Buffers the diagnostic for later emission, unless handler
     /// has disabled such buffering.
     pub fn buffer(mut self, buffered_diagnostics: &mut Vec<Diagnostic>) {