about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2018-11-05 16:27:28 -0800
committerEsteban Küber <esteban@kuber.com.ar>2018-11-23 15:37:31 -0800
commitc45871ba02430c3af6453d5636f8ad0afb7eb35f (patch)
tree49b8c1951ef8b2bd5207fe9385d7792299a4a7dd /src/librustc_errors
parent76449d86c0c0b85ff93912a450012f2ece16c3d4 (diff)
downloadrust-c45871ba02430c3af6453d5636f8ad0afb7eb35f.tar.gz
rust-c45871ba02430c3af6453d5636f8ad0afb7eb35f.zip
Keep label on moved spans and point at macro invocation on parse error
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/diagnostic.rs11
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,