about summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
diff options
context:
space:
mode:
authorTim Neumann <mail@timnn.me>2015-08-10 20:40:46 +0200
committerTim Neumann <mail@timnn.me>2015-08-10 20:43:11 +0200
commitd46e84081f88f22198fbfcd5221faaf922e0500d (patch)
tree81c9a3bbaab8586673d96f05ba5bb7822fe1d9a3 /src/libsyntax/codemap.rs
parentc115c513632b45d1a4d1b3fb648755a7023269e7 (diff)
downloadrust-d46e84081f88f22198fbfcd5221faaf922e0500d.tar.gz
rust-d46e84081f88f22198fbfcd5221faaf922e0500d.zip
add and use Span.substitute_dummy method
Diffstat (limited to 'src/libsyntax/codemap.rs')
-rw-r--r--src/libsyntax/codemap.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 17e6b2c2e12..0aeb572b6bc 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -135,6 +135,13 @@ pub const COMMAND_LINE_SP: Span = Span { lo: BytePos(0),
                                          hi: BytePos(0),
                                          expn_id: COMMAND_LINE_EXPN };
 
+impl Span {
+    /// Returns `self` if `self` is not the dummy span, and `other` otherwise.
+    pub fn substitute_dummy(self, other: Span) -> Span {
+        if self == DUMMY_SP { other } else { self }
+    }
+}
+
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
 pub struct Spanned<T> {
     pub node: T,