summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-03-11 13:29:06 -0500
committerNiko Matsakis <niko@alum.mit.edu>2016-03-25 06:44:14 -0400
commit05baf645e47a0ed3893f2413696e56be180249ff (patch)
tree74204ea214726f32461351740403a146f0bde46b /src/libsyntax/codemap.rs
parent99c2a6b335d953eca64e631f3e9946b1cc6643e1 (diff)
downloadrust-05baf645e47a0ed3893f2413696e56be180249ff.tar.gz
rust-05baf645e47a0ed3893f2413696e56be180249ff.zip
do not overwrite spans as eagerly
this was required to preserve the span from
the #[structural_match] attribute -- but honestly
I am not 100% sure if it makes sense.
Diffstat (limited to 'src/libsyntax/codemap.rs')
-rw-r--r--src/libsyntax/codemap.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 804ca6705ec..f771ee95bd1 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -1304,6 +1304,31 @@ impl CodeMap {
         return a;
     }
 
+    /// Check if the backtrace `subtrace` contains `suptrace` as a prefix.
+    pub fn more_specific_trace(&self,
+                              mut subtrace: ExpnId,
+                              suptrace: ExpnId)
+                              -> bool {
+        loop {
+            if subtrace == suptrace {
+                return true;
+            }
+
+            let stop = self.with_expn_info(subtrace, |opt_expn_info| {
+                if let Some(expn_info) = opt_expn_info {
+                    subtrace = expn_info.call_site.expn_id;
+                    false
+                } else {
+                    true
+                }
+            });
+
+            if stop {
+                return false;
+            }
+        }
+    }
+
     pub fn record_expansion(&self, expn_info: ExpnInfo) -> ExpnId {
         let mut expansions = self.expansions.borrow_mut();
         expansions.push(expn_info);