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 | |
| 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')
| -rw-r--r-- | src/libsyntax/codemap.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 4 |
7 files changed, 20 insertions, 23 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"; } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index e5f20950412..1a3513ab81c 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -12,7 +12,7 @@ use abi::AbiSet; use ast::{P, Ident}; use ast; use ast_util; -use codemap::{Span, respan, dummy_sp}; +use codemap::{Span, respan, DUMMY_SP}; use ext::base::ExtCtxt; use ext::quote::rt::*; use fold::ast_fold; @@ -321,7 +321,7 @@ impl AstBuilder for ExtCtxt { fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> { self.ty_path( - self.path_all(dummy_sp(), + self.path_all(DUMMY_SP, true, ~[ self.ident_of("std"), @@ -348,7 +348,7 @@ impl AstBuilder for ExtCtxt { P(ast::Ty { id: ast::DUMMY_NODE_ID, node: ast::ty_nil, - span: dummy_sp(), + span: DUMMY_SP, }) } @@ -361,13 +361,13 @@ impl AstBuilder for ExtCtxt { // incorrect code. fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[P<ast::Ty>] { opt_vec::take_vec( - ty_params.map(|p| self.ty_ident(dummy_sp(), p.ident))) + ty_params.map(|p| self.ty_ident(DUMMY_SP, p.ident))) } fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[P<ast::Ty>] { opt_vec::take_vec( ty_params.map(|p| self.ty_path( - self.path_global(dummy_sp(), ~[p.ident]), None))) + self.path_global(DUMMY_SP, ~[p.ident]), None))) } fn strip_bounds(&self, generics: &Generics) -> Generics { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index eb07353cda3..be336128275 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1279,12 +1279,12 @@ mod test { // make a MetaWord outer attribute with the given name fn make_dummy_attr(s: @str) -> ast::Attribute { Spanned { - span:codemap::dummy_sp(), + span:codemap::DUMMY_SP, node: Attribute_ { style: AttrOuter, value: @Spanned { node: MetaWord(s), - span: codemap::dummy_sp(), + span: codemap::DUMMY_SP, }, is_sugared_doc: false, } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index ae9bbdadf2c..05d402a2ba2 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -11,7 +11,7 @@ use ast::{Ident, matcher_, matcher, match_tok, match_nonterminal, match_seq}; use ast::{tt_delim}; use ast; -use codemap::{Span, Spanned, dummy_sp}; +use codemap::{Span, Spanned, DUMMY_SP}; use ext::base::{AnyMacro, ExtCtxt, MacResult, MRAny, MRDef, MacroDef}; use ext::base::{NormalTT, SyntaxExpanderTTTrait}; use ext::base; @@ -109,7 +109,7 @@ fn generic_extension(cx: &ExtCtxt, } // Which arm's failure should we report? (the one furthest along) - let mut best_fail_spot = dummy_sp(); + let mut best_fail_spot = DUMMY_SP; let mut best_fail_msg = ~"internal error: ran no matchers"; let s_d = cx.parse_sess().span_diagnostic; @@ -178,7 +178,7 @@ pub fn add_new_extension(cx: &mut ExtCtxt, fn ms(m: matcher_) -> matcher { Spanned { node: m.clone(), - span: dummy_sp() + span: DUMMY_SP } } diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index fc7d3d2b40c..cbce5fb16cb 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -10,7 +10,7 @@ use ast; use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,Ident}; -use codemap::{Span, dummy_sp}; +use codemap::{Span, DUMMY_SP}; use diagnostic::SpanHandler; use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident}; @@ -66,7 +66,7 @@ pub fn new_tt_reader(sp_diag: @mut SpanHandler, repeat_len: ~[], /* dummy values, never read: */ cur_tok: EOF, - cur_span: dummy_sp() + cur_span: DUMMY_SP }; tt_next_token(r); /* get cur_tok and cur_span set up */ return r; diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 8b7ef6d9cf8..2c3d03eefea 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -81,7 +81,7 @@ pub fn new_low_level_string_reader(span_diagnostic: @mut SpanHandler, filemap: filemap, /* dummy values; not read */ peek_tok: token::EOF, - peek_span: codemap::dummy_sp() + peek_span: codemap::DUMMY_SP }; bump(r); return r; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index fa0d2d4765b..960e28ca84f 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2422,7 +2422,7 @@ mod test { inputs: ~[], output: ast::P(ast::Ty {id: 0, node: ast::ty_nil, - span: codemap::dummy_sp()}), + span: codemap::DUMMY_SP}), cf: ast::return_val, variadic: false }; @@ -2436,7 +2436,7 @@ mod test { fn test_variant_to_str() { let ident = token::str_to_ident("principal_skinner"); - let var = codemap::respan(codemap::dummy_sp(), ast::variant_ { + let var = codemap::respan(codemap::DUMMY_SP, ast::variant_ { name: ident, attrs: ~[], // making this up as I go.... ? |
