about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-11-23 16:01:20 -0800
committerEsteban Küber <esteban@kuber.com.ar>2019-11-23 16:50:28 -0800
commitd92355c1db65035e508020e746c141c79dfdbd99 (patch)
treea0cf0d266824c1930c716d1e98d9b1b4a818f571 /src/librustc_errors
parentf11759d38c70d3df67135f88a682701c1cf9762a (diff)
downloadrust-d92355c1db65035e508020e746c141c79dfdbd99.tar.gz
rust-d92355c1db65035e508020e746c141c79dfdbd99.zip
Highlight parts of fn in type errors
When a type error arises between two fn items, fn pointers or tuples,
highlight only the differing parts of each.
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/diagnostic.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs
index 27ea0039354..530844ceee1 100644
--- a/src/librustc_errors/diagnostic.rs
+++ b/src/librustc_errors/diagnostic.rs
@@ -52,6 +52,13 @@ impl DiagnosticStyledString {
     pub fn push_highlighted<S: Into<String>>(&mut self, t: S) {
         self.0.push(StringPart::Highlighted(t.into()));
     }
+    pub fn push<S: Into<String>>(&mut self, t: S, highlight: bool) {
+        if highlight {
+            self.0.push(StringPart::Highlighted(t.into()));
+        } else {
+            self.0.push(StringPart::Normal(t.into()));
+        }
+    }
     pub fn normal<S: Into<String>>(t: S) -> DiagnosticStyledString {
         DiagnosticStyledString(vec![StringPart::Normal(t.into())])
     }