diff options
| author | Jonathan Turner <jturner@mozilla.com> | 2016-08-17 07:20:04 -0700 |
|---|---|---|
| committer | Jonathan Turner <jturner@mozilla.com> | 2016-08-17 14:26:14 -0700 |
| commit | 61865384b8fa6d79d2b36cbd7c899eaf15f4aeea (patch) | |
| tree | 136502c033d49ba3e6e28f9460129586a381e92a /src/libsyntax_pos | |
| parent | d0a272b797fd538c4b4230bdefea534af8c1ffde (diff) | |
| download | rust-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.rs | 19 |
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 |
