diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-12-30 15:09:41 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-01-02 14:16:07 -0800 |
| commit | 758d854436a2174c85717a64b8a90ed4041962d8 (patch) | |
| tree | 9da32c878ac86a17fe537d1402076fe6f1a9da72 /src/libsyntax/ext | |
| parent | 425a140485dc3ba70c4e30e10cd8d5fd92a458c5 (diff) | |
| download | rust-758d854436a2174c85717a64b8a90ed4041962d8.tar.gz rust-758d854436a2174c85717a64b8a90ed4041962d8.zip | |
libsyntax: De-`@mut` `token` in the parser
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/asm.rs | 32 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/cfg.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 4 |
6 files changed, 30 insertions, 28 deletions
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index d7d8360f1e8..c4a2f6d48bf 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -66,9 +66,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) asm_str_style = Some(style); } Outputs => { - while *p.token != token::EOF && - *p.token != token::COLON && - *p.token != token::MOD_SEP { + while p.token != token::EOF && + p.token != token::COLON && + p.token != token::MOD_SEP { if outputs.len() != 0 { p.eat(&token::COMMA); @@ -91,9 +91,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) } } Inputs => { - while *p.token != token::EOF && - *p.token != token::COLON && - *p.token != token::MOD_SEP { + while p.token != token::EOF && + p.token != token::COLON && + p.token != token::MOD_SEP { if inputs.len() != 0 { p.eat(&token::COMMA); @@ -116,9 +116,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) } Clobbers => { let mut clobs = ~[]; - while *p.token != token::EOF && - *p.token != token::COLON && - *p.token != token::MOD_SEP { + while p.token != token::EOF && + p.token != token::COLON && + p.token != token::MOD_SEP { if clobs.len() != 0 { p.eat(&token::COMMA); @@ -142,16 +142,16 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) dialect = ast::asm_intel; } - if *p.token == token::COMMA { + if p.token == token::COMMA { p.eat(&token::COMMA); } } } - while *p.token == token::COLON || - *p.token == token::MOD_SEP || - *p.token == token::EOF { - state = if *p.token == token::COLON { + while p.token == token::COLON || + p.token == token::MOD_SEP || + p.token == token::EOF { + state = if p.token == token::COLON { p.bump(); match next_state(state) { Some(x) => x, @@ -160,7 +160,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) break } } - } else if *p.token == token::MOD_SEP { + } else if p.token == token::MOD_SEP { p.bump(); let s = match next_state(state) { Some(x) => x, @@ -176,7 +176,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) break } } - } else if *p.token == token::EOF { + } else if p.token == token::EOF { continue_ = false; break; } else { diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index a4f447874ff..a7a4e6416f9 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -446,7 +446,7 @@ pub fn get_exprs_from_tts(cx: &ExtCtxt, cx.cfg(), tts.to_owned()); let mut es = ~[]; - while *p.token != token::EOF { + while p.token != token::EOF { if es.len() != 0 && !p.eat(&token::COMMA) { cx.span_fatal(sp, "expected token: `,`"); } diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs index f58b5eb3a92..f3f44f4fa3f 100644 --- a/src/libsyntax/ext/cfg.rs +++ b/src/libsyntax/ext/cfg.rs @@ -32,7 +32,7 @@ pub fn expand_cfg(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base:: let mut cfgs = ~[]; // parse `cfg!(meta_item, meta_item(x,y), meta_item="foo", ...)` - while *p.token != token::EOF { + while p.token != token::EOF { cfgs.push(p.parse_meta_item()); if p.eat(&token::EOF) { break } // trailing comma is optional,. p.expect(&token::COMMA); diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 2d4bdd3da23..82f9e138074 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -65,22 +65,22 @@ impl<'a> Context<'a> { return (extra, None); } - if *p.token == token::EOF { + if p.token == token::EOF { self.ecx.span_err(sp, "requires at least a format string argument"); return (extra, None); } let fmtstr = p.parse_expr(); let mut named = false; - while *p.token != token::EOF { + while p.token != token::EOF { if !p.eat(&token::COMMA) { self.ecx.span_err(sp, "expected token: `,`"); return (extra, None); } - if *p.token == token::EOF { break } // accept trailing commas - if named || (token::is_ident(p.token) && + if p.token == token::EOF { break } // accept trailing commas + if named || (token::is_ident(&p.token) && p.look_ahead(1, |t| *t == token::EQ)) { named = true; - let ident = match *p.token { + let ident = match p.token { token::IDENT(i, _) => { p.bump(); i diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index a14d25305fd..4d2923f391e 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -438,10 +438,12 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> nonterminal { "expr" => token::nt_expr(p.parse_expr()), "ty" => token::nt_ty(p.parse_ty(false /* no need to disambiguate*/)), // this could be handled like a token, since it is one - "ident" => match *p.token { + "ident" => match p.token { token::IDENT(sn,b) => { p.bump(); token::nt_ident(~sn,b) } - _ => p.fatal(~"expected ident, found " - + token::to_str(get_ident_interner(), p.token)) + _ => { + let token_str = token::to_str(get_ident_interner(), &p.token); + p.fatal(~"expected ident, found " + token_str) + } }, "path" => { token::nt_path(~p.parse_path(LifetimeAndTypesWithoutColons).path) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 365c48c7c86..e5910678a8e 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -40,10 +40,10 @@ impl ParserAnyMacro { /// allowed to be there. fn ensure_complete_parse(&self, allow_semi: bool) { let mut parser = self.parser.borrow_mut(); - if allow_semi && *parser.get().token == SEMI { + if allow_semi && parser.get().token == SEMI { parser.get().bump() } - if *parser.get().token != EOF { + if parser.get().token != EOF { let token_str = parser.get().this_token_to_str(); let msg = format!("macro expansion ignores token `{}` and any \ following", |
