diff options
| author | Seo Sanghyeon <sanxiyn@gmail.com> | 2015-09-26 10:44:37 +0900 |
|---|---|---|
| committer | Seo Sanghyeon <sanxiyn@gmail.com> | 2015-10-03 00:36:20 +0900 |
| commit | f3211b1578dc61faee1f6a0cfb2e6fd65526ee11 (patch) | |
| tree | bad023efd4bbdac41dc168050b95552d932ad1a4 /src/libsyntax | |
| parent | 5180a7ccc55bb9973ca1f9441b39563c14f7ca9f (diff) | |
| download | rust-f3211b1578dc61faee1f6a0cfb2e6fd65526ee11.tar.gz rust-f3211b1578dc61faee1f6a0cfb2e6fd65526ee11.zip | |
Add a method to test span containment
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 6 |
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: {:?}", |
