diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-01-19 02:14:51 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-02-02 14:13:07 +0100 |
| commit | 7af9ff3e699207da7a5220b98ba9831d66697c80 (patch) | |
| tree | 4b9405bef6a38c6476c7cb3ee29cf7c5812aca1b /src/librustc_errors | |
| parent | cef68945722fa593a4a1314f4a2f1ff095aab4f4 (diff) | |
| download | rust-7af9ff3e699207da7a5220b98ba9831d66697c80.tar.gz rust-7af9ff3e699207da7a5220b98ba9831d66697c80.zip | |
introduce `#![feature(move_ref_pattern)]`
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/diagnostic_builder.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 3c217c1d643..82bbae18a9c 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -186,11 +186,25 @@ 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. - pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self { + pub fn span_label(&mut self, span: Span, label: impl Into<String>) -> &mut Self { self.0.diagnostic.span_label(span, label); self } + /// Labels all the given spans with the provided label. + /// See `span_label` for more information. + pub fn span_labels( + &mut self, + spans: impl IntoIterator<Item = Span>, + label: impl AsRef<str>, + ) -> &mut Self { + let label = label.as_ref(); + for span in spans { + self.0.diagnostic.span_label(span, label); + } + self + } + forward!(pub fn note_expected_found( &mut self, expected_label: &dyn fmt::Display, |
