add and use Span.substitute_dummy method

This commit is contained in:
Tim Neumann
2015-08-10 20:40:46 +02:00
parent c115c51363
commit d46e84081f
3 changed files with 15 additions and 23 deletions

View File

@@ -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,