From d92355c1db65035e508020e746c141c79dfdbd99 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Sat, 23 Nov 2019 16:01:20 -0800 Subject: 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. --- src/librustc_errors/diagnostic.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/librustc_errors') 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>(&mut self, t: S) { self.0.push(StringPart::Highlighted(t.into())); } + pub fn push>(&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>(t: S) -> DiagnosticStyledString { DiagnosticStyledString(vec![StringPart::Normal(t.into())]) } -- cgit 1.4.1-3-g733a5