diff options
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/diagnostic.rs | 5 | ||||
| -rw-r--r-- | src/librustc_errors/diagnostic_builder.rs | 6 |
2 files changed, 6 insertions, 5 deletions
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<T: Into<String>>(&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<T: Into<String>>(&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, |
