diff options
| author | klutzy <klutzytheklutzy@gmail.com> | 2014-01-01 15:53:22 +0900 |
|---|---|---|
| committer | klutzy <klutzytheklutzy@gmail.com> | 2014-01-01 19:51:35 +0900 |
| commit | 9cdad685a39fd826174a6cbcd283ad2dee41e175 (patch) | |
| tree | 5993d9e64b91a1d66672634cbc4b24962e54980d /src/libsyntax/codemap.rs | |
| parent | db204b20ab5ed7f27027a95c76c6d6e74eb443d6 (diff) | |
| download | rust-9cdad685a39fd826174a6cbcd283ad2dee41e175.tar.gz rust-9cdad685a39fd826174a6cbcd283ad2dee41e175.zip | |
syntax::codemap: Add static DUMMY_SP
It replaces `dummy_sp()`.
Diffstat (limited to 'src/libsyntax/codemap.rs')
| -rw-r--r-- | src/libsyntax/codemap.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 0509760120a..97d3db074bb 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -90,6 +90,8 @@ pub struct Span { expn_info: Option<@ExpnInfo> } +pub static DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_info: None }; + #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct Spanned<T> { node: T, @@ -112,7 +114,7 @@ impl<S:Encoder> Encodable<S> for Span { impl<D:Decoder> Decodable<D> for Span { fn decode(_d: &mut D) -> Span { - dummy_sp() + DUMMY_SP } } @@ -125,7 +127,7 @@ pub fn respan<T>(sp: Span, t: T) -> Spanned<T> { } pub fn dummy_spanned<T>(t: T) -> Spanned<T> { - respan(dummy_sp(), t) + respan(DUMMY_SP, t) } /* assuming that we're not in macro expansion */ @@ -133,11 +135,6 @@ pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span { Span {lo: lo, hi: hi, expn_info: None} } -// make this a const, once the compiler supports it -pub fn dummy_sp() -> Span { return mk_sp(BytePos(0), BytePos(0)); } - - - /// A source code location used for error reporting pub struct Loc { /// Information about the original source @@ -350,7 +347,7 @@ impl CodeMap { pub fn span_to_str(&self, sp: Span) -> ~str { let files = &*self.files; - if files.len() == 0 && sp == dummy_sp() { + if files.len() == 0 && sp == DUMMY_SP { return ~"no-location"; } |
