diff options
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/diagnostic.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index a323282f233..ea425ad4c47 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -139,6 +139,17 @@ impl Diagnostic { self } + pub fn replace_span_with(&mut self, after: Span) -> &mut Self { + let before = self.span.clone(); + self.set_span(after); + for span_label in before.span_labels() { + if let Some(label) = span_label.label { + self.span_label(after, label); + } + } + self + } + pub fn note_expected_found(&mut self, label: &dyn fmt::Display, expected: DiagnosticStyledString, |
