diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2017-05-04 14:17:23 +0200 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2017-05-08 12:56:15 +0200 |
| commit | dd87eabd83296baa4c2214d2cf3aeef24f753ba7 (patch) | |
| tree | 4d6b198ad0e356961a8b64603caa847a81b86b68 /src/librustc_errors | |
| parent | 70198a0a44633c7c9d14fce2159c1f750491287b (diff) | |
| download | rust-dd87eabd83296baa4c2214d2cf3aeef24f753ba7.tar.gz rust-dd87eabd83296baa4c2214d2cf3aeef24f753ba7.zip | |
Remove need for &format!(...) or &&"" dances in `span_label` calls
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, |
