From dd87eabd83296baa4c2214d2cf3aeef24f753ba7 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 4 May 2017 14:17:23 +0200 Subject: Remove need for &format!(...) or &&"" dances in `span_label` calls --- src/librustc_errors/diagnostic.rs | 5 ++--- src/librustc_errors/diagnostic_builder.rs | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/librustc_errors') diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 38fa35ecb12..0822f713499 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -114,9 +114,8 @@ impl Diagnostic { /// all, and you just supplied a `Span` to create the diagnostic, /// then the snippet will just include that `Span`, which is /// called the primary span. - pub fn span_label(&mut self, span: Span, label: &fmt::Display) - -> &mut Self { - self.span.push_span_label(span, format!("{}", label)); + pub fn span_label>(&mut self, span: Span, label: T) -> &mut Self { + self.span.push_span_label(span, label.into()); self } diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 9dfd47b8464..a9c2bbeba2a 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -112,8 +112,10 @@ impl<'a> DiagnosticBuilder<'a> { /// all, and you just supplied a `Span` to create the diagnostic, /// then the snippet will just include that `Span`, which is /// called the primary span. - forward!(pub fn span_label(&mut self, span: Span, label: &fmt::Display) - -> &mut Self); + pub fn span_label>(&mut self, span: Span, label: T) -> &mut Self { + self.diagnostic.span_label(span, label); + self + } forward!(pub fn note_expected_found(&mut self, label: &fmt::Display, -- cgit 1.4.1-3-g733a5