about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorJonathan Turner <jturner@mozilla.com>2016-08-17 07:20:04 -0700
committerJonathan Turner <jturner@mozilla.com>2016-08-17 14:26:14 -0700
commit61865384b8fa6d79d2b36cbd7c899eaf15f4aeea (patch)
tree136502c033d49ba3e6e28f9460129586a381e92a /src/libsyntax_pos
parentd0a272b797fd538c4b4230bdefea534af8c1ffde (diff)
downloadrust-61865384b8fa6d79d2b36cbd7c899eaf15f4aeea.tar.gz
rust-61865384b8fa6d79d2b36cbd7c899eaf15f4aeea.zip
Replace local backtrace with def-use, repair std macro spans
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/lib.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index 0f171805bb0..b11bbea84ab 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -221,6 +221,25 @@ impl MultiSpan {
         &self.primary_spans
     }
 
+    /// Replaces all occurances of one Span with another. Used to move Spans in areas that don't
+    /// display well (like std macros). Returns true if replacements occurred.
+    pub fn replace(&mut self, before: Span, after: Span) -> bool {
+        let mut replacements_occurred = false;
+        for primary_span in &mut self.primary_spans {
+            if *primary_span == before {
+                *primary_span = after;
+                replacements_occurred = true;
+            }
+        }
+        for span_label in &mut self.span_labels {
+            if span_label.0 == before {
+                span_label.0 = after;
+                replacements_occurred = true;
+            }
+        }
+        replacements_occurred
+    }
+
     /// Returns the strings to highlight. We always ensure that there
     /// is an entry for each of the primary spans -- for each primary
     /// span P, if there is at least one label with span P, we return