about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorSeo Sanghyeon <sanxiyn@gmail.com>2015-09-26 10:44:37 +0900
committerSeo Sanghyeon <sanxiyn@gmail.com>2015-10-03 00:36:20 +0900
commitf3211b1578dc61faee1f6a0cfb2e6fd65526ee11 (patch)
treebad023efd4bbdac41dc168050b95552d932ad1a4 /src/libsyntax
parent5180a7ccc55bb9973ca1f9441b39563c14f7ca9f (diff)
downloadrust-f3211b1578dc61faee1f6a0cfb2e6fd65526ee11.tar.gz
rust-f3211b1578dc61faee1f6a0cfb2e6fd65526ee11.zip
Add a method to test span containment
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/codemap.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 1f8c726bf68..aa4dd1d53c5 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -142,6 +142,10 @@ impl Span {
     pub fn substitute_dummy(self, other: Span) -> Span {
         if self == DUMMY_SP { other } else { self }
     }
+
+    pub fn contains(self, other: Span) -> bool {
+        self.lo <= other.lo && other.hi <= self.hi
+    }
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
@@ -1011,7 +1015,7 @@ impl CodeMap {
 
                     let span_comes_from_this_expansion =
                         info.callee.span.map_or(span == info.call_site, |mac_span| {
-                            mac_span.lo <= span.lo && span.hi <= mac_span.hi
+                            mac_span.contains(span)
                         });
 
                     debug!("span_allows_unstable: span: {:?} call_site: {:?} callee: {:?}",