diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index eb92b23c9d7..f3a74302400 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -339,7 +339,7 @@ pub fn get_exprs_from_tts(cx: ext_ctxt, tts: ~[ast::token_tree]) cx.cfg(), tts); let mut es = ~[]; - while p.token != token::EOF { + while *p.token != token::EOF { if es.len() != 0 { p.eat(token::COMMA); } diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index a2f881fc19f..66feb7cc753 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -25,7 +25,7 @@ pub trait proto_parser { pub impl proto_parser for parser::Parser { fn parse_proto(&self, id: ~str) -> protocol { - let proto = protocol(id, self.span); + let proto = protocol(id, *self.span); self.parse_seq_to_before_end(token::EOF, SeqSep { sep: None, @@ -40,7 +40,7 @@ pub impl proto_parser for parser::Parser { let name = *self.interner.get(id); self.expect(token::COLON); - let dir = match copy self.token { + let dir = match *self.token { token::IDENT(n, _) => self.interner.get(n), _ => fail!() }; @@ -51,10 +51,11 @@ pub impl proto_parser for parser::Parser { _ => fail!() }; - let typarms = if self.token == token::LT { + let typarms = if *self.token == token::LT { self.parse_ty_params() - } - else { ~[] }; + } else { + ~[] + }; let state = proto.add_state_poly(name, id, dir, typarms); @@ -69,7 +70,7 @@ pub impl proto_parser for parser::Parser { fn parse_message(&self, state: state) { let mname = *self.interner.get(self.parse_ident()); - let args = if self.token == token::LPAREN { + let args = if *self.token == token::LPAREN { self.parse_unspanned_seq(token::LPAREN, token::RPAREN, SeqSep { sep: Some(token::COMMA), @@ -80,10 +81,10 @@ pub impl proto_parser for parser::Parser { self.expect(token::RARROW); - let next = match copy self.token { + let next = match *self.token { token::IDENT(_, _) => { let name = *self.interner.get(self.parse_ident()); - let ntys = if self.token == token::LT { + let ntys = if *self.token == token::LT { self.parse_unspanned_seq(token::LT, token::GT, SeqSep { sep: Some(token::COMMA), @@ -101,7 +102,7 @@ pub impl proto_parser for parser::Parser { _ => self.fatal(~"invalid next state") }; - state.add_message(mname, copy self.span, args, next); + state.add_message(mname, *self.span, args, next); } } diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 25760aa01b6..444b09d9ae4 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -49,6 +49,9 @@ pub trait gen_init { pub impl gen_send for message { fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item { debug!("pipec: gen_send"); + let name = self.name(); + let params = self.get_params(); + match *self { message(ref _id, span, ref tys, this, Some(ref next_state)) => { debug!("pipec: next state exists"); @@ -67,7 +70,7 @@ pub impl gen_send for message { args_ast); let mut body = ~"{\n"; - body += fmt!("use super::%s;\n", self.name()); + body += fmt!("use super::%s;\n", name); if this.proto.is_bounded() { let (sp, rp) = match (this.dir, next.dir) { @@ -96,7 +99,7 @@ pub impl gen_send for message { body += fmt!("let %s = ::core::pipes::entangle();\n", pat); } body += fmt!("let message = %s(%s);\n", - self.name(), + name, str::connect(vec::append_one( arg_names.map(|x| cx.str_of(*x)), ~"s"), ~", ")); @@ -121,13 +124,12 @@ pub impl gen_send for message { rty = cx.ty_option(rty); } - let name = cx.ident_of(if try { ~"try_" + self.name() - } else { self.name() } ); + let name = cx.ident_of(if try { ~"try_" + name } else { name } ); cx.item_fn_poly(name, args_ast, rty, - self.get_params(), + params, cx.expr_block(body)) } @@ -156,10 +158,8 @@ pub impl gen_send for message { }; let mut body = ~"{ "; - body += fmt!("use super::%s;\n", self.name()); - body += fmt!("let message = %s%s;\n", - self.name(), - message_args); + body += fmt!("use super::%s;\n", name); + body += fmt!("let message = %s%s;\n", name, message_args); if !try { body += fmt!("::core::pipes::send(pipe, message);\n"); @@ -175,10 +175,7 @@ pub impl gen_send for message { let body = cx.parse_expr(body); - let name = if try { - ~"try_" + self.name() - } - else { self.name() }; + let name = if try { ~"try_" + name } else { name }; cx.item_fn_poly(cx.ident_of(name), args_ast, @@ -187,7 +184,7 @@ pub impl gen_send for message { } else { cx.ty_nil_ast_builder() }, - self.get_params(), + params, cx.expr_block(body)) } } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index ffa6101d58f..d529ee0c01b 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -515,7 +515,7 @@ fn expand_tts(cx: ext_ctxt, // try removing it when enough of them are gone. let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts); - p.quote_depth += 1u; + *p.quote_depth += 1u; let tts = p.parse_all_token_trees(); p.abort_if_errors(); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 1a04da95801..890420edf6d 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -421,16 +421,16 @@ pub fn parse_nt(p: 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 copy 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(p.reader.interner(), copy p.token)) + + token::to_str(p.reader.interner(), *p.token)) }, ~"path" => token::nt_path(p.parse_path_with_tps(false)), ~"tt" => { - p.quote_depth += 1u; //but in theory, non-quoted tts might be useful + *p.quote_depth += 1u; //but in theory, non-quoted tts might be useful let res = token::nt_tt(@p.parse_token_tree()); - p.quote_depth -= 1u; + *p.quote_depth -= 1u; res } ~"matchers" => token::nt_matchers(p.parse_matchers()), diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 4f64d7bed31..c0c97a0b9eb 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -37,7 +37,7 @@ impl parser_attr for Parser { fn parse_outer_attributes() -> ~[ast::attribute] { let mut attrs: ~[ast::attribute] = ~[]; loop { - match copy self.token { + match *self.token { token::POUND => { if self.look_ahead(1u) != token::LBRACKET { break; @@ -90,14 +90,14 @@ impl parser_attr for Parser { let mut inner_attrs: ~[ast::attribute] = ~[]; let mut next_outer_attrs: ~[ast::attribute] = ~[]; loop { - match copy self.token { + match *self.token { token::POUND => { if self.look_ahead(1u) != token::LBRACKET { // This is an extension break; } let attr = self.parse_attribute(ast::attr_inner); - if self.token == token::SEMI { + if *self.token == token::SEMI { self.bump(); inner_attrs += ~[attr]; } else { @@ -131,7 +131,7 @@ impl parser_attr for Parser { fn parse_meta_item() -> @ast::meta_item { let lo = self.span.lo; let name = self.id_to_str(self.parse_ident()); - match self.token { + match *self.token { token::EQ => { self.bump(); let lit = self.parse_lit(); @@ -157,7 +157,7 @@ impl parser_attr for Parser { } fn parse_optional_meta() -> ~[@ast::meta_item] { - match self.token { + match *self.token { token::LPAREN => return self.parse_meta_seq(), _ => return ~[] } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 22004be87ad..57d62d628dc 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -53,25 +53,25 @@ pub fn token_to_str(reader: reader, ++token: token::Token) -> ~str { pub impl Parser { fn unexpected_last(t: token::Token) -> ! { self.span_fatal( - copy self.last_span, + *self.last_span, ~"unexpected token: `" + token_to_str(self.reader, t) + ~"`"); } fn unexpected() -> ! { self.fatal(~"unexpected token: `" - + token_to_str(self.reader, self.token) + ~"`"); + + token_to_str(self.reader, *self.token) + ~"`"); } // expect and consume the token t. Signal an error if // the next token is not t. fn expect(t: token::Token) { - if self.token == t { + if *self.token == t { self.bump(); } else { let mut s: ~str = ~"expected `"; s += token_to_str(self.reader, t); s += ~"` but found `"; - s += token_to_str(self.reader, self.token); + s += token_to_str(self.reader, *self.token); self.fatal(s + ~"`"); } } @@ -79,12 +79,12 @@ pub impl Parser { fn parse_ident() -> ast::ident { self.check_strict_keywords(); self.check_reserved_keywords(); - match copy self.token { + match *self.token { token::IDENT(i, _) => { self.bump(); return i; } token::INTERPOLATED(token::nt_ident(*)) => { self.bug( ~"ident interpolation not converted to real token"); } _ => { self.fatal(~"expected ident, found `" - + token_to_str(self.reader, self.token) + + token_to_str(self.reader, *self.token) + ~"`"); } } } @@ -104,7 +104,7 @@ pub impl Parser { // consume token 'tok' if it exists. Returns true if the given // token was present, false otherwise. fn eat(tok: token::Token) -> bool { - return if self.token == tok { self.bump(); true } else { false }; + return if *self.token == tok { self.bump(); true } else { false }; } // Storing keywords as interned idents instead of strings would be nifty. @@ -129,7 +129,7 @@ pub impl Parser { } fn is_keyword(word: ~str) -> bool { - self.token_is_keyword(word, self.token) + self.token_is_keyword(word, *self.token) } fn is_any_keyword(tok: token::Token) -> bool { @@ -143,7 +143,7 @@ pub impl Parser { fn eat_keyword(word: ~str) -> bool { self.require_keyword(word); - let is_kw = match self.token { + let is_kw = match *self.token { token::IDENT(sid, false) => (word == *self.id_to_str(sid)), _ => false }; @@ -155,7 +155,7 @@ pub impl Parser { self.require_keyword(word); if !self.eat_keyword(word) { self.fatal(~"expected `" + word + ~"`, found `" + - token_to_str(self.reader, self.token) + + token_to_str(self.reader, *self.token) + ~"`"); } } @@ -165,9 +165,9 @@ pub impl Parser { } fn check_strict_keywords() { - match self.token { + match *self.token { token::IDENT(_, false) => { - let w = token_to_str(self.reader, self.token); + let w = token_to_str(self.reader, *self.token); self.check_strict_keywords_(w); } _ => () @@ -185,9 +185,9 @@ pub impl Parser { } fn check_reserved_keywords() { - match self.token { + match *self.token { token::IDENT(_, false) => { - let w = token_to_str(self.reader, self.token); + let w = token_to_str(self.reader, *self.token); self.check_reserved_keywords_(w); } _ => () @@ -203,9 +203,9 @@ pub impl Parser { // expect and consume a GT. if a >> is seen, replace it // with a single > and continue. fn expect_gt() { - if self.token == token::GT { + if *self.token == token::GT { self.bump(); - } else if self.token == token::BINOP(token::SHR) { + } else if *self.token == token::BINOP(token::SHR) { self.replace_token(token::GT, self.span.lo + BytePos(1u), self.span.hi); @@ -213,7 +213,7 @@ pub impl Parser { let mut s: ~str = ~"expected `"; s += token_to_str(self.reader, token::GT); s += ~"`, found `"; - s += token_to_str(self.reader, self.token); + s += token_to_str(self.reader, *self.token); s += ~"`"; self.fatal(s); } @@ -225,8 +225,8 @@ pub impl Parser { f: fn(Parser) -> T) -> ~[T] { let mut first = true; let mut v = ~[]; - while self.token != token::GT - && self.token != token::BINOP(token::SHR) { + while *self.token != token::GT + && *self.token != token::BINOP(token::SHR) { match sep { Some(ref t) => { if first { first = false; } @@ -276,7 +276,7 @@ pub impl Parser { f: fn(Parser) -> T) -> ~[T] { let mut first: bool = true; let mut v: ~[T] = ~[]; - while self.token != ket { + while *self.token != ket { match sep.sep { Some(ref t) => { if first { first = false; } @@ -284,7 +284,7 @@ pub impl Parser { } _ => () } - if sep.trailing_sep_allowed && self.token == ket { break; } + if sep.trailing_sep_allowed && *self.token == ket { break; } v.push(f(self)); } return v; @@ -293,8 +293,8 @@ pub impl Parser { // parse a sequence, including the closing delimiter. The function // f must consume tokens until reaching the next separator or // closing bracket. - fn parse_unspanned_seq(bra: token::Token, - ket: token::Token, + fn parse_unspanned_seq(+bra: token::Token, + +ket: token::Token, sep: SeqSep, f: fn(Parser) -> T) -> ~[T] { self.expect(bra); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4f330ea86b0..5fa61159385 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -141,7 +141,7 @@ pub fn parse_tts_from_source_str(name: ~str, sess: @mut ParseSess) -> ~[ast::token_tree] { let p = new_parser_from_source_str(sess, cfg, name, codemap::FssNone, source); - p.quote_depth += 1u; + *p.quote_depth += 1u; let r = p.parse_all_token_trees(); p.abort_if_errors(); return r; diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index f5ee5bd8029..1ae8786e09b 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -158,7 +158,7 @@ pub impl Parser { } fn is_obsolete_ident(ident: &str) -> bool { - self.token_is_obsolete_ident(ident, copy self.token) + self.token_is_obsolete_ident(ident, *self.token) } fn eat_obsolete_ident(ident: &str) -> bool { @@ -172,7 +172,7 @@ pub impl Parser { fn try_parse_obsolete_struct_ctor() -> bool { if self.eat_obsolete_ident("new") { - self.obsolete(copy self.last_span, ObsoleteStructCtor); + self.obsolete(*self.last_span, ObsoleteStructCtor); self.parse_fn_decl(|p| p.parse_arg()); self.parse_block(); true @@ -182,13 +182,13 @@ pub impl Parser { } fn try_parse_obsolete_with() -> bool { - if self.token == token::COMMA + if *self.token == token::COMMA && self.token_is_obsolete_ident("with", self.look_ahead(1u)) { self.bump(); } if self.eat_obsolete_ident("with") { - self.obsolete(copy self.last_span, ObsoleteWith); + self.obsolete(*self.last_span, ObsoleteWith); self.parse_expr(); true } else { @@ -198,10 +198,10 @@ pub impl Parser { fn try_parse_obsolete_priv_section() -> bool { if self.is_keyword(~"priv") && self.look_ahead(1) == token::LBRACE { - self.obsolete(copy self.span, ObsoletePrivSection); + self.obsolete(*self.span, ObsoletePrivSection); self.eat_keyword(~"priv"); self.bump(); - while self.token != token::RBRACE { + while *self.token != token::RBRACE { self.parse_single_class_item(ast::private); } self.bump(); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c7c8836126b..9bac163dab6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -127,7 +127,7 @@ enum view_item_parse_mode { The important thing is to make sure that lookahead doesn't balk at INTERPOLATED tokens */ macro_rules! maybe_whole_expr ( - ($p:expr) => ( match copy $p.token { + ($p:expr) => ( match *$p.token { INTERPOLATED(token::nt_expr(e)) => { $p.bump(); return e; @@ -142,28 +142,28 @@ macro_rules! maybe_whole_expr ( ) macro_rules! maybe_whole ( - ($p:expr, $constructor:ident) => ( match copy $p.token { - INTERPOLATED(token::$constructor(ref x)) => { $p.bump(); return (*x); } + ($p:expr, $constructor:ident) => ( match *$p.token { + INTERPOLATED(token::$constructor(x)) => { $p.bump(); return x; } _ => () }) ; - (deref $p:expr, $constructor:ident) => ( match copy $p.token { + (deref $p:expr, $constructor:ident) => ( match *$p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return *x; } _ => () }) ; - (Some $p:expr, $constructor:ident) => ( match copy $p.token { + (Some $p:expr, $constructor:ident) => ( match *$p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return Some(x); } _ => () }) ; - (iovi $p:expr, $constructor:ident) => ( match copy $p.token { + (iovi $p:expr, $constructor:ident) => ( match *$p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return iovi_item(x); } _ => () }) ; - (pair_empty $p:expr, $constructor:ident) => ( match copy $p.token { - INTERPOLATED(token::$constructor(ref x)) => { - $p.bump(); return (~[], (*x)); + (pair_empty $p:expr, $constructor:ident) => ( match *$p.token { + INTERPOLATED(token::$constructor(x)) => { + $p.bump(); return (~[], x); } _ => () }) @@ -202,35 +202,35 @@ pub fn Parser(sess: @mut ParseSess, interner: interner, sess: sess, cfg: cfg, - token: tok0.tok, - span: span0, - last_span: span0, - mut buffer: [TokenAndSpan {tok: tok0.tok, sp: span0}, ..4], - buffer_start: 0, - buffer_end: 0, - tokens_consumed: 0u, - restriction: UNRESTRICTED, - quote_depth: 0u, + token: @mut tok0.tok, + span: @mut span0, + last_span: @mut span0, + buffer: @mut [TokenAndSpan {tok: tok0.tok, sp: span0}, ..4], + buffer_start: @mut 0, + buffer_end: @mut 0, + tokens_consumed: @mut 0u, + restriction: @mut UNRESTRICTED, + quote_depth: @mut 0u, keywords: token::keyword_table(), strict_keywords: token::strict_keyword_table(), reserved_keywords: token::reserved_keyword_table(), obsolete_set: HashMap(), - mod_path_stack: ~[], + mod_path_stack: @mut ~[], } } pub struct Parser { sess: @mut ParseSess, cfg: crate_cfg, - mut token: token::Token, - mut span: span, - mut last_span: span, - mut buffer: [TokenAndSpan * 4], - mut buffer_start: int, - mut buffer_end: int, - mut tokens_consumed: uint, - mut restriction: restriction, - mut quote_depth: uint, // not (yet) related to the quasiquoter + token: @mut token::Token, + span: @mut span, + last_span: @mut span, + buffer: @mut [TokenAndSpan * 4], + buffer_start: @mut int, + buffer_end: @mut int, + tokens_consumed: @mut uint, + restriction: @mut restriction, + quote_depth: @mut uint, // not (yet) related to the quasiquoter reader: reader, interner: @token::ident_interner, keywords: HashMap<~str, ()>, @@ -240,7 +240,7 @@ pub struct Parser { /// extra detail when the same error is seen twice obsolete_set: HashMap, /// Used to determine the path to externally loaded source files - mut mod_path_stack: ~[~str], + mod_path_stack: @mut ~[~str], drop {} /* do not copy the parser; its state is tied to outside state */ } @@ -248,39 +248,39 @@ pub struct Parser { pub impl Parser { // advance the parser by one token fn bump() { - self.last_span = self.span; - let next = if self.buffer_start == self.buffer_end { + *self.last_span = *self.span; + let next = if *self.buffer_start == *self.buffer_end { self.reader.next_token() } else { - let next = self.buffer[self.buffer_start]; - self.buffer_start = (self.buffer_start + 1) & 3; + let next = self.buffer[*self.buffer_start]; + *self.buffer_start = (*self.buffer_start + 1) & 3; next }; - self.token = next.tok; - self.span = next.sp; - self.tokens_consumed += 1u; + *self.token = next.tok; + *self.span = next.sp; + *self.tokens_consumed += 1u; } // EFFECT: replace the current token and span with the given one fn replace_token(next: token::Token, +lo: BytePos, +hi: BytePos) { - self.token = next; - self.span = mk_sp(lo, hi); + *self.token = next; + *self.span = mk_sp(lo, hi); } fn buffer_length() -> int { - if self.buffer_start <= self.buffer_end { - return self.buffer_end - self.buffer_start; + if *self.buffer_start <= *self.buffer_end { + return *self.buffer_end - *self.buffer_start; } - return (4 - self.buffer_start) + self.buffer_end; + return (4 - *self.buffer_start) + *self.buffer_end; } fn look_ahead(distance: uint) -> token::Token { let dist = distance as int; while self.buffer_length() < dist { - self.buffer[self.buffer_end] = self.reader.next_token(); - self.buffer_end = (self.buffer_end + 1) & 3; + self.buffer[*self.buffer_end] = self.reader.next_token(); + *self.buffer_end = (*self.buffer_end + 1) & 3; } - return copy self.buffer[(self.buffer_start + dist - 1) & 3].tok; + return copy self.buffer[(*self.buffer_start + dist - 1) & 3].tok; } fn fatal(m: ~str) -> ! { - self.sess.span_diagnostic.span_fatal(copy self.span, m) + self.sess.span_diagnostic.span_fatal(*copy self.span, m) } fn span_fatal(sp: span, m: ~str) -> ! { self.sess.span_diagnostic.span_fatal(sp, m) @@ -289,10 +289,10 @@ pub impl Parser { self.sess.span_diagnostic.span_note(sp, m) } fn bug(m: ~str) -> ! { - self.sess.span_diagnostic.span_bug(copy self.span, m) + self.sess.span_diagnostic.span_bug(*copy self.span, m) } fn warn(m: ~str) { - self.sess.span_diagnostic.span_warn(copy self.span, m) + self.sess.span_diagnostic.span_warn(*copy self.span, m) } fn span_err(sp: span, m: ~str) { self.sess.span_diagnostic.span_err(sp, m) @@ -451,8 +451,8 @@ pub impl Parser { let hi = p.last_span.hi; debug!("parse_trait_methods(): trait method signature ends in \ `%s`", - token_to_str(p.reader, p.token)); - match p.token { + token_to_str(p.reader, *p.token)); + match *p.token { token::SEMI => { p.bump(); debug!("parse_trait_methods(): parsing required method"); @@ -490,7 +490,7 @@ pub impl Parser { } _ => { p.fatal(~"expected `;` or `}` but found `" + - token_to_str(p.reader, p.token) + ~"`"); + token_to_str(p.reader, *p.token) + ~"`"); } } } @@ -562,7 +562,7 @@ pub impl Parser { fn parse_region() -> @region { self.expect(token::BINOP(token::AND)); - match copy self.token { + match *self.token { token::IDENT(sid, _) => { self.bump(); self.region_from_name(Some(sid)) @@ -578,9 +578,9 @@ pub impl Parser { let lo = self.span.lo; - let t = if self.token == token::LPAREN { + let t = if *self.token == token::LPAREN { self.bump(); - if self.token == token::RPAREN { + if *self.token == token::RPAREN { self.bump(); ty_nil } else { @@ -589,9 +589,9 @@ pub impl Parser { // of type t let mut ts = ~[self.parse_ty(false)]; let mut one_tuple = false; - while self.token == token::COMMA { + while *self.token == token::COMMA { self.bump(); - if self.token != token::RPAREN { + if *self.token != token::RPAREN { ts.push(self.parse_ty(false)); } else { @@ -603,16 +603,16 @@ pub impl Parser { self.expect(token::RPAREN); t } - } else if self.token == token::AT { + } else if *self.token == token::AT { self.bump(); self.parse_box_or_uniq_pointee(ManagedSigil, ty_box) - } else if self.token == token::TILDE { + } else if *self.token == token::TILDE { self.bump(); self.parse_box_or_uniq_pointee(OwnedSigil, ty_uniq) - } else if self.token == token::BINOP(token::STAR) { + } else if *self.token == token::BINOP(token::STAR) { self.bump(); ty_ptr(self.parse_mt()) - } else if self.token == token::LBRACE { + } else if *self.token == token::LBRACE { let elems = self.parse_unspanned_seq( token::LBRACE, token::RBRACE, seq_sep_trailing_allowed(token::COMMA), @@ -621,7 +621,7 @@ pub impl Parser { self.unexpected_last(token::RBRACE); } ty_rec(elems) - } else if self.token == token::LBRACKET { + } else if *self.token == token::LBRACKET { self.expect(token::LBRACKET); let mt = self.parse_mt(); @@ -632,15 +632,15 @@ pub impl Parser { }; self.expect(token::RBRACKET); t - } else if self.token == token::BINOP(token::AND) { + } else if *self.token == token::BINOP(token::AND) { self.bump(); self.parse_borrowed_pointee() } else if self.eat_keyword(~"extern") { self.parse_ty_bare_fn() - } else if self.token_is_closure_keyword(self.token) { + } else if self.token_is_closure_keyword(*self.token) { self.parse_ty_closure(None, None) - } else if self.token == token::MOD_SEP - || is_ident_or_path(self.token) { + } else if *self.token == token::MOD_SEP + || is_ident_or_path(*self.token) { let path = self.parse_path_with_tps(colons_before_params); ty_path(path, self.get_id()) } else { self.fatal(~"expected type"); }; @@ -654,7 +654,7 @@ pub impl Parser { ctor: &fn(+v: mt) -> ty_) -> ty_ { // @'foo fn() or @foo/fn() or @fn() are parsed directly as fn types: - match copy self.token { + match *self.token { token::LIFETIME(rname) => { self.bump(); return self.parse_ty_closure(Some(sigil), Some(rname)); @@ -662,11 +662,10 @@ pub impl Parser { token::IDENT(rname, _) => { if self.look_ahead(1u) == token::BINOP(token::SLASH) && - self.token_is_closure_keyword(self.look_ahead(2u)) - { + self.token_is_closure_keyword(self.look_ahead(2u)) { self.bump(); self.bump(); return self.parse_ty_closure(Some(sigil), Some(rname)); - } else if self.token_is_closure_keyword(self.token) { + } else if self.token_is_closure_keyword(*self.token) { return self.parse_ty_closure(Some(sigil), None); } } @@ -683,7 +682,7 @@ pub impl Parser { fn parse_borrowed_pointee() -> ty_ { // look for `&'lt` or `&foo/` and interpret `foo` as the region name: - let rname = match self.token { + let rname = match *self.token { token::LIFETIME(sid) => { self.bump(); Some(sid) @@ -701,7 +700,7 @@ pub impl Parser { _ => { None } }; - if self.token_is_closure_keyword(self.token) { + if self.token_is_closure_keyword(*self.token) { return self.parse_ty_closure(Some(BorrowedSigil), rname); } @@ -727,13 +726,13 @@ pub impl Parser { } fn is_named_argument() -> bool { - let offset = if self.token == token::BINOP(token::AND) { + let offset = if *self.token == token::BINOP(token::AND) { 1 - } else if self.token == token::BINOP(token::MINUS) { + } else if *self.token == token::BINOP(token::MINUS) { 1 - } else if self.token == token::ANDAND { + } else if *self.token == token::ANDAND { 1 - } else if self.token == token::BINOP(token::PLUS) { + } else if *self.token == token::BINOP(token::PLUS) { if self.look_ahead(1) == token::BINOP(token::PLUS) { 2 } else { @@ -741,7 +740,7 @@ pub impl Parser { } } else { 0 }; if offset == 0 { - is_plain_ident(self.token) + is_plain_ident(*self.token) && self.look_ahead(1) == token::COLON } else { is_plain_ident(self.look_ahead(offset)) @@ -775,7 +774,7 @@ pub impl Parser { } else { m = infer(self.get_id()); ast_util::ident_to_pat(self.get_id(), - copy self.last_span, + *self.last_span, special_idents::invalid) }; @@ -819,7 +818,7 @@ pub impl Parser { fn maybe_parse_fixed_vstore_with_star() -> Option { if self.eat(token::BINOP(token::STAR)) { - match copy self.token { + match *self.token { token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 => { self.bump(); Some(i as uint) @@ -828,7 +827,7 @@ pub impl Parser { self.fatal( fmt!("expected integral vector length \ but found `%s`", - token_to_str(self.reader, self.token))); + token_to_str(self.reader, *self.token))); } } } else { @@ -857,7 +856,8 @@ pub impl Parser { } else if self.eat_keyword(~"false") { lit_bool(false) } else { - let tok = self.token; + // XXX: This is a really bad copy! + let tok = *self.token; self.bump(); self.lit_from_token(tok) }; @@ -920,9 +920,8 @@ pub impl Parser { // vstores is... um... the same. I guess that's my fault. This // is still not ideal as for &str we end up parsing more than we // ought to and have to sort it out later. - if self.token == token::BINOP(token::SLASH) + if *self.token == token::BINOP(token::SLASH) && self.look_ahead(1u) == token::BINOP(token::AND) { - self.expect(token::BINOP(token::SLASH)); Some(self.parse_region()) } else { @@ -958,7 +957,7 @@ pub impl Parser { * Parses 0 or 1 lifetime. */ - match self.token { + match *self.token { token::LIFETIME(_) => { Some(self.parse_lifetime()) } @@ -974,12 +973,12 @@ pub impl Parser { * Parses a single lifetime. */ - match self.token { + match *self.token { token::LIFETIME(i) => { self.bump(); return ast::Lifetime { id: self.get_id(), - span: self.span, + span: *self.span, ident: i }; } @@ -1000,7 +999,7 @@ pub impl Parser { let mut res = ~[]; loop { - match self.token { + match *self.token { token::LIFETIME(_) => { res.push(self.parse_lifetime()); } @@ -1009,7 +1008,7 @@ pub impl Parser { } } - match self.token { + match *self.token { token::COMMA => { self.bump();} token::GT => { return res; } _ => { @@ -1058,14 +1057,16 @@ pub impl Parser { fn mk_lit_u32(i: u32) -> @expr { let span = self.span; - let lv_lit = @codemap::spanned { node: lit_uint(i as u64, ty_u32), - span: span }; + let lv_lit = @codemap::spanned { + node: lit_uint(i as u64, ty_u32), + span: *span + }; @expr { id: self.get_id(), callee_id: self.get_id(), node: expr_lit(lv_lit), - span: span, + span: *span, } } @@ -1076,21 +1077,21 @@ pub impl Parser { let mut ex: expr_; - if self.token == token::LPAREN { + if *self.token == token::LPAREN { self.bump(); // (e) is parenthesized e // (e,) is a tuple with only one field, e let mut one_tuple = false; - if self.token == token::RPAREN { + if *self.token == token::RPAREN { hi = self.span.hi; self.bump(); let lit = @spanned(lo, hi, lit_nil); return self.mk_expr(lo, hi, expr_lit(lit)); } let mut es = ~[self.parse_expr()]; - while self.token == token::COMMA { + while *self.token == token::COMMA { self.bump(); - if self.token != token::RPAREN { + if *self.token != token::RPAREN { es.push(self.parse_expr()); } else { @@ -1106,7 +1107,7 @@ pub impl Parser { else { self.mk_expr(lo, hi, expr_tup(es)) } - } else if self.token == token::LBRACE { + } else if *self.token == token::LBRACE { if self.looking_at_record_literal() { ex = self.parse_record_literal(); hi = self.span.hi; @@ -1116,7 +1117,7 @@ pub impl Parser { return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); } - } else if token::is_bar(self.token) { + } else if token::is_bar(*self.token) { return self.parse_lambda_expr(); } else if self.eat_keyword(~"if") { return self.parse_if_expr(); @@ -1143,17 +1144,17 @@ pub impl Parser { return self.parse_fn_expr(sigil); } else if self.eat_keyword(~"unsafe") { return self.parse_block_expr(lo, unsafe_blk); - } else if self.token == token::LBRACKET { + } else if *self.token == token::LBRACKET { self.bump(); let mutbl = self.parse_mutability(); - if self.token == token::RBRACKET { + if *self.token == token::RBRACKET { // Empty vector. self.bump(); ex = expr_vec(~[], mutbl); } else { // Nonempty vector. let first_expr = self.parse_expr(); - if self.token == token::COMMA && + if *self.token == token::COMMA && self.look_ahead(1) == token::DOTDOT { // Repeating vector syntax: [ 0, ..512 ] self.bump(); @@ -1161,7 +1162,7 @@ pub impl Parser { let count = self.parse_expr(); self.expect(token::RBRACKET); ex = expr_repeat(first_expr, count, mutbl); - } else if self.token == token::COMMA { + } else if *self.token == token::COMMA { // Vector with two or more elements. self.bump(); let remaining_exprs = @@ -1189,13 +1190,13 @@ pub impl Parser { ex = expr_assert(e); hi = e.span.hi; } else if self.eat_keyword(~"return") { - if can_begin_expr(self.token) { + if can_begin_expr(*self.token) { let e = self.parse_expr(); hi = e.span.hi; ex = expr_ret(Some(e)); } else { ex = expr_ret(None); } } else if self.eat_keyword(~"break") { - if is_ident(self.token) { + if is_ident(*self.token) { ex = expr_break(Some(self.parse_ident())); } else { ex = expr_break(None); @@ -1205,28 +1206,28 @@ pub impl Parser { let e = self.parse_expr(); ex = expr_copy(e); hi = e.span.hi; - } else if self.token == token::MOD_SEP || - is_ident(self.token) && !self.is_keyword(~"true") && - !self.is_keyword(~"false") { + } else if *self.token == token::MOD_SEP || + is_ident(*self.token) && !self.is_keyword(~"true") && + !self.is_keyword(~"false") { let pth = self.parse_path_with_tps(true); /* `!`, as an operator, is prefix, so we know this isn't that */ - if self.token == token::NOT { + if *self.token == token::NOT { self.bump(); - let tts = match self.token { - token::LPAREN | token::LBRACE => { - let ket = token::flip_delimiter(copy self.token); - self.parse_unspanned_seq(copy self.token, ket, - seq_sep_none(), - |p| p.parse_token_tree()) - } + match *self.token { + token::LPAREN | token::LBRACE => {} _ => self.fatal(~"expected open delimiter") }; + + let ket = token::flip_delimiter(*self.token); + let tts = self.parse_unspanned_seq(*self.token, + ket, + seq_sep_none(), + |p| p.parse_token_tree()); let hi = self.span.hi; - return self.mk_mac_expr( - lo, hi, mac_invoc_tt(pth, tts)); - } else if self.token == token::LBRACE { + return self.mk_mac_expr(lo, hi, mac_invoc_tt(pth, tts)); + } else if *self.token == token::LBRACE { // This might be a struct literal. if self.looking_at_record_literal() { // It's a struct literal. @@ -1234,8 +1235,7 @@ pub impl Parser { let mut fields = ~[]; let mut base = None; fields.push(self.parse_field(token::COLON)); - while self.token != token::RBRACE { - + while *self.token != token::RBRACE { if self.try_parse_obsolete_with() { break; } @@ -1247,7 +1247,7 @@ pub impl Parser { break; } - if self.token == token::RBRACE { + if *self.token == token::RBRACE { // Accept an optional trailing comma. break; } @@ -1284,7 +1284,7 @@ pub impl Parser { } fn permits_call() -> bool { - return self.restriction != RESTRICT_NO_CALL_EXPRS; + return *self.restriction != RESTRICT_NO_CALL_EXPRS; } fn parse_dot_or_call_expr_with(e0: @expr) -> @expr { @@ -1294,7 +1294,7 @@ pub impl Parser { loop { // expr.f if self.eat(token::DOT) { - match copy self.token { + match *self.token { token::IDENT(i, _) => { hi = self.span.hi; self.bump(); @@ -1307,7 +1307,7 @@ pub impl Parser { }; // expr.f() method call - match copy self.token { + match *self.token { token::LPAREN if self.permits_call() => { let es = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, @@ -1328,7 +1328,7 @@ pub impl Parser { loop; } if self.expr_is_complete(e) { break; } - match copy self.token { + match *self.token { // expr(...) token::LPAREN if self.permits_call() => { let es = self.parse_unspanned_seq( @@ -1359,17 +1359,17 @@ pub impl Parser { // parse an optional separator followed by a kleene-style // repetition token (+ or *). fn parse_sep_and_zerok() -> (Option, bool) { - if self.token == token::BINOP(token::STAR) - || self.token == token::BINOP(token::PLUS) { - let zerok = self.token == token::BINOP(token::STAR); + if *self.token == token::BINOP(token::STAR) + || *self.token == token::BINOP(token::PLUS) { + let zerok = *self.token == token::BINOP(token::STAR); self.bump(); return (None, zerok); } else { - let sep = self.token; + let sep = *self.token; self.bump(); - if self.token == token::BINOP(token::STAR) - || self.token == token::BINOP(token::PLUS) { - let zerok = self.token == token::BINOP(token::STAR); + if *self.token == token::BINOP(token::STAR) + || *self.token == token::BINOP(token::PLUS) { + let zerok = *self.token == token::BINOP(token::STAR); self.bump(); return (Some(sep), zerok); } else { @@ -1384,18 +1384,18 @@ pub impl Parser { fn parse_non_delim_tt_tok(p: Parser) -> token_tree { maybe_whole!(deref p, nt_tt); - match p.token { + match *p.token { token::RPAREN | token::RBRACE | token::RBRACKET => { p.fatal(~"incorrect close delimiter: `" - + token_to_str(p.reader, p.token) + ~"`"); + + token_to_str(p.reader, *p.token) + ~"`"); } /* we ought to allow different depths of unquotation */ - token::DOLLAR if p.quote_depth > 0u => { + token::DOLLAR if *p.quote_depth > 0u => { p.bump(); - let sp = p.span; + let sp = *p.span; - if p.token == token::LPAREN { + if *p.token == token::LPAREN { let seq = p.parse_seq(token::LPAREN, token::RPAREN, seq_sep_none(), |p| p.parse_token_tree()); @@ -1413,18 +1413,18 @@ pub impl Parser { // turn the next token into a tt_tok: fn parse_any_tt_tok(p: Parser) -> token_tree{ - let res = tt_tok(p.span, p.token); + let res = tt_tok(*p.span, *p.token); p.bump(); res } - match self.token { + match *self.token { token::EOF => { self.fatal(~"file ended in the middle of a macro invocation"); } token::LPAREN | token::LBRACE | token::LBRACKET => { // tjc: ?????? - let ket = token::flip_delimiter(copy self.token); + let ket = token::flip_delimiter(*self.token); tt_delim(vec::append( // the open delimiter: ~[parse_any_tt_tok(self)], @@ -1441,7 +1441,7 @@ pub impl Parser { fn parse_all_token_trees() -> ~[token_tree] { let mut tts = ~[]; - while self.token != token::EOF { + while *self.token != token::EOF { tts.push(self.parse_token_tree()); } tts @@ -1452,11 +1452,11 @@ pub impl Parser { // the interpolation of matchers maybe_whole!(self, nt_matchers); let name_idx = @mut 0u; - return match self.token { + return match *self.token { token::LBRACE | token::LPAREN | token::LBRACKET => { - self.parse_matcher_subseq(name_idx, copy self.token, + self.parse_matcher_subseq(name_idx, *self.token, // tjc: not sure why we need a copy - token::flip_delimiter(copy self.token)) + token::flip_delimiter(*self.token)) } _ => self.fatal(~"expected open delimiter") } @@ -1473,9 +1473,9 @@ pub impl Parser { self.expect(bra); - while self.token != ket || lparens > 0u { - if self.token == token::LPAREN { lparens += 1u; } - if self.token == token::RPAREN { lparens -= 1u; } + while *self.token != ket || lparens > 0u { + if *self.token == token::LPAREN { lparens += 1u; } + if *self.token == token::RPAREN { lparens -= 1u; } ret_val.push(self.parse_matcher(name_idx)); } @@ -1487,11 +1487,12 @@ pub impl Parser { fn parse_matcher(name_idx: @mut uint) -> matcher { let lo = self.span.lo; - let m = if self.token == token::DOLLAR { + let m = if *self.token == token::DOLLAR { self.bump(); - if self.token == token::LPAREN { + if *self.token == token::LPAREN { let name_idx_lo = *name_idx; - let ms = self.parse_matcher_subseq(name_idx, token::LPAREN, + let ms = self.parse_matcher_subseq(name_idx, + token::LPAREN, token::RPAREN); if ms.len() == 0u { self.fatal(~"repetition body must be nonempty"); @@ -1507,7 +1508,7 @@ pub impl Parser { m } } else { - let m = match_tok(self.token); + let m = match_tok(*self.token); self.bump(); m }; @@ -1521,7 +1522,7 @@ pub impl Parser { let mut hi; let mut ex; - match copy self.token { + match *self.token { token::NOT => { self.bump(); let e = self.parse_prefix_expr(); @@ -1610,13 +1611,13 @@ pub impl Parser { fn parse_more_binops(lhs: @expr, min_prec: uint) -> @expr { if self.expr_is_complete(lhs) { return lhs; } - let peeked = self.token; + let peeked = *self.token; if peeked == token::BINOP(token::OR) && - (self.restriction == RESTRICT_NO_BAR_OP || - self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP) { + (*self.restriction == RESTRICT_NO_BAR_OP || + *self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP) { lhs } else if peeked == token::OROR && - self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP { + *self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP { lhs } else { let cur_opt = token_to_binop(peeked); @@ -1656,7 +1657,7 @@ pub impl Parser { fn parse_assign_expr() -> @expr { let lo = self.span.lo; let lhs = self.parse_binops(); - match copy self.token { + match *self.token { token::EQ => { self.bump(); let rhs = self.parse_expr(); @@ -1683,7 +1684,7 @@ pub impl Parser { expr_assign_op(aop, lhs, rhs)) } token::LARROW => { - self.obsolete(copy self.span, ObsoleteBinaryMove); + self.obsolete(*self.span, ObsoleteBinaryMove); // Bogus value (but it's an error) self.bump(); // <- self.bump(); // rhs @@ -1733,7 +1734,7 @@ pub impl Parser { fn parse_lambda_block_expr() -> @expr { self.parse_lambda_expr_( || { - match self.token { + match *self.token { token::BINOP(token::OR) | token::OROR => { self.parse_fn_block_decl() } @@ -1744,7 +1745,7 @@ pub impl Parser { output: @Ty { id: self.get_id(), node: ty_infer, - span: self.span + span: *self.span }, cf: return_val } @@ -1841,8 +1842,8 @@ pub impl Parser { // but they aren't represented by tests debug!("sugary call on %?", e.node); self.span_fatal( - lo, fmt!("`%s` must be followed by a block call", - keyword)); + *lo, + fmt!("`%s` must be followed by a block call", keyword)); } } } @@ -1858,13 +1859,13 @@ pub impl Parser { fn parse_loop_expr() -> @expr { // loop headers look like 'loop {' or 'loop unsafe {' let is_loop_header = - self.token == token::LBRACE - || (is_ident(copy self.token) + *self.token == token::LBRACE + || (is_ident(*self.token) && self.look_ahead(1) == token::LBRACE); // labeled loop headers look like 'loop foo: {' let is_labeled_loop_header = - is_ident(self.token) - && !self.is_any_keyword(copy self.token) + is_ident(*self.token) + && !self.is_any_keyword(*self.token) && self.look_ahead(1) == token::COLON; if is_loop_header || is_labeled_loop_header { @@ -1884,7 +1885,7 @@ pub impl Parser { } else { // This is a 'continue' expression let lo = self.span.lo; - let ex = if is_ident(self.token) { + let ex = if is_ident(*self.token) { expr_again(Some(self.parse_ident())) } else { expr_again(None) @@ -1897,7 +1898,7 @@ pub impl Parser { // For distingishing between record literals and blocks fn looking_at_record_literal() -> bool { let lookahead = self.look_ahead(1); - self.token == token::LBRACE && + *self.token == token::LBRACE && (self.token_is_keyword(~"mut", lookahead) || (is_plain_ident(lookahead) && self.look_ahead(2) == token::COLON)) @@ -1907,8 +1908,8 @@ pub impl Parser { self.expect(token::LBRACE); let mut fields = ~[self.parse_field(token::COLON)]; let mut base = None; - while self.token != token::RBRACE { - if self.token == token::COMMA + while *self.token != token::RBRACE { + if *self.token == token::COMMA && self.look_ahead(1) == token::DOTDOT { self.bump(); self.bump(); @@ -1920,7 +1921,7 @@ pub impl Parser { } self.expect(token::COMMA); - if self.token == token::RBRACE { + if *self.token == token::RBRACE { // record ends by an optional trailing comma break; } @@ -1936,7 +1937,7 @@ pub impl Parser { let discriminant = self.parse_expr(); self.expect(token::LBRACE); let mut arms: ~[arm] = ~[]; - while self.token != token::RBRACE { + while *self.token != token::RBRACE { let pats = self.parse_pats(); let mut guard = None; if self.eat_keyword(~"if") { guard = Some(self.parse_expr()); } @@ -1945,7 +1946,7 @@ pub impl Parser { let require_comma = !classify::expr_is_simple_block(expr) - && self.token != token::RBRACE; + && *self.token != token::RBRACE; if require_comma { self.expect(token::COMMA); @@ -1978,21 +1979,21 @@ pub impl Parser { // parse an expression, subject to the given restriction fn parse_expr_res(r: restriction) -> @expr { - let old = self.restriction; - self.restriction = r; + let old = *self.restriction; + *self.restriction = r; let e = self.parse_assign_expr(); - self.restriction = old; + *self.restriction = old; return e; } fn parse_initializer() -> Option<@expr> { - match self.token { + match *self.token { token::EQ => { self.bump(); return Some(self.parse_expr()); } token::LARROW => { - self.obsolete(copy self.span, ObsoleteMoveInit); + self.obsolete(*self.span, ObsoleteMoveInit); self.bump(); self.bump(); return None; @@ -2007,7 +2008,7 @@ pub impl Parser { let mut pats = ~[]; loop { pats.push(self.parse_pat(true)); - if self.token == token::BINOP(token::OR) { self.bump(); } + if *self.token == token::BINOP(token::OR) { self.bump(); } else { return pats; } }; } @@ -2017,12 +2018,12 @@ pub impl Parser { let mut tail = None; let mut first = true; - while self.token != token::RBRACKET { + while *self.token != token::RBRACKET { if first { first = false; } else { self.expect(token::COMMA); } let mut is_tail = false; - if self.token == token::DOTDOT { + if *self.token == token::DOTDOT { self.bump(); is_tail = true; } @@ -2049,15 +2050,15 @@ pub impl Parser { let mut fields = ~[]; let mut etc = false; let mut first = true; - while self.token != token::RBRACE { + while *self.token != token::RBRACE { if first { first = false; } else { self.expect(token::COMMA); } - if self.token == token::UNDERSCORE { + if *self.token == token::UNDERSCORE { self.bump(); - if self.token != token::RBRACE { + if *self.token != token::RBRACE { self.fatal(~"expected `}`, found `" + - token_to_str(self.reader, self.token) + + token_to_str(self.reader, *self.token) + ~"`"); } etc = true; @@ -2074,14 +2075,14 @@ pub impl Parser { let fieldpath = ast_util::ident_to_path(mk_sp(lo1, hi1), fieldname); let mut subpat; - if self.token == token::COLON { + if *self.token == token::COLON { self.bump(); subpat = self.parse_pat(refutable); } else { subpat = @ast::pat { id: self.get_id(), node: pat_ident(bind_infer, fieldpath, None), - span: self.last_span + span: *self.last_span }; } fields.push(ast::field_pat { ident: fieldname, pat: subpat }); @@ -2095,7 +2096,7 @@ pub impl Parser { let lo = self.span.lo; let mut hi = self.span.hi; let mut pat; - match self.token { + match *self.token { token::UNDERSCORE => { self.bump(); pat = pat_wild; } token::AT => { self.bump(); @@ -2173,7 +2174,7 @@ pub impl Parser { } token::LPAREN => { self.bump(); - if self.token == token::RPAREN { + if *self.token == token::RPAREN { hi = self.span.hi; self.bump(); let lit = @codemap::spanned { @@ -2184,7 +2185,7 @@ pub impl Parser { } else { let mut fields = ~[self.parse_pat(refutable)]; if self.look_ahead(1) != token::RPAREN { - while self.token == token::COMMA { + while *self.token == token::COMMA { self.bump(); fields.push(self.parse_pat(refutable)); } @@ -2233,7 +2234,7 @@ pub impl Parser { cannot_be_enum_or_struct = true } - if is_plain_ident(self.token) && cannot_be_enum_or_struct { + if is_plain_ident(*self.token) && cannot_be_enum_or_struct { let name = self.parse_value_path(); let sub; if self.eat(token::AT) { @@ -2244,7 +2245,7 @@ pub impl Parser { pat = pat_ident(binding_mode, name, sub); } else { let enum_path = self.parse_path_with_tps(true); - match self.token { + match *self.token { token::LBRACE => { self.bump(); let (fields, etc) = @@ -2255,7 +2256,7 @@ pub impl Parser { _ => { let mut args: ~[@pat] = ~[]; let mut star_pat = false; - match self.token { + match *self.token { token::LPAREN => match self.look_ahead(1u) { token::BINOP(token::STAR) => { // This is a "top constructor only" pat @@ -2299,9 +2300,9 @@ pub impl Parser { fn parse_pat_ident(refutable: bool, binding_mode: ast::binding_mode) -> ast::pat_ { - if !is_plain_ident(self.token) { + if !is_plain_ident(*self.token) { self.span_fatal( - copy self.last_span, + *self.last_span, ~"expected identifier, found path"); } let name = self.parse_value_path(); @@ -2315,9 +2316,9 @@ pub impl Parser { // leads to a parse error. Note that if there is no explicit // binding mode then we do not end up here, because the lookahead // will direct us over to parse_enum_variant() - if self.token == token::LPAREN { + if *self.token == token::LPAREN { self.span_fatal( - copy self.last_span, + *self.last_span, ~"expected identifier, found enum pattern"); } @@ -2365,7 +2366,7 @@ pub impl Parser { if self.eat_keyword(~"mut") { is_mutbl = struct_mutable; } - if !is_plain_ident(self.token) { + if !is_plain_ident(*self.token) { self.fatal(~"expected ident"); } let name = self.parse_ident(); @@ -2394,8 +2395,8 @@ pub impl Parser { self.expect_keyword(~"let"); let decl = self.parse_let(); return @spanned(lo, decl.span.hi, stmt_decl(decl, self.get_id())); - } else if is_ident(self.token) - && !self.is_any_keyword(copy self.token) + } else if is_ident(*self.token) + && !self.is_any_keyword(*self.token) && self.look_ahead(1) == token::NOT { check_expected_item(self, first_item_attrs); @@ -2405,7 +2406,7 @@ pub impl Parser { let pth = self.parse_value_path(); self.bump(); - let id = if self.token == token::LPAREN { + let id = if *self.token == token::LPAREN { token::special_idents::invalid // no special identifier } else { self.parse_ident() @@ -2460,7 +2461,7 @@ pub impl Parser { } fn expr_is_complete(e: @expr) -> bool { - return self.restriction == RESTRICT_STMT_EXPR && + return *self.restriction == RESTRICT_STMT_EXPR && !classify::expr_requires_semi_to_be_stmt(e); } @@ -2486,7 +2487,7 @@ pub impl Parser { let lo = self.span.lo; if self.eat_keyword(~"unsafe") { - self.obsolete(copy self.span, ObsoleteUnsafeBlock); + self.obsolete(*self.span, ObsoleteUnsafeBlock); } self.expect(token::LBRACE); let (inner, next) = @@ -2530,12 +2531,12 @@ pub impl Parser { let mut initial_attrs = attrs_remaining; - if self.token == token::RBRACE && !vec::is_empty(initial_attrs) { + if *self.token == token::RBRACE && !vec::is_empty(initial_attrs) { self.fatal(~"expected item"); } - while self.token != token::RBRACE { - match self.token { + while *self.token != token::RBRACE { + match *self.token { token::SEMI => { self.bump(); // empty } @@ -2545,7 +2546,7 @@ pub impl Parser { match stmt.node { stmt_expr(e, stmt_id) => { // Expression without semicolon - match self.token { + match *self.token { token::SEMI => { self.bump(); stmts.push(@codemap::spanned { @@ -2570,7 +2571,7 @@ pub impl Parser { stmt_mac(ref m, _) => { // Statement macro; might be an expr - match self.token { + match *self.token { token::SEMI => { self.bump(); stmts.push(@codemap::spanned { @@ -2616,9 +2617,9 @@ pub impl Parser { @Ty { id: self.get_id(), node: ty_path( - ident_to_path(copy self.last_span, i), + ident_to_path(*self.last_span, i), self.get_id()), - span: self.last_span, + span: *self.last_span, } } @@ -2644,12 +2645,12 @@ pub impl Parser { if self.eat_keyword(~"static") { bounds.push(RegionTyParamBound); } else { - self.span_err(copy self.span, + self.span_err(*self.span, ~"`&static` is the only permissible \ region bound here"); } - } else if is_ident(self.token) { - let maybe_bound = match self.token { + } else if is_ident(*self.token) { + let maybe_bound = match *self.token { token::IDENT(copy sid, _) => { match *self.id_to_str(sid) { @@ -2657,7 +2658,7 @@ pub impl Parser { | ~"copy" | ~"const" | ~"owned" => { - self.obsolete(copy self.span, + self.obsolete(*self.span, ObsoleteLowerCaseKindBounds); // Bogus value, but doesn't matter, since // is an error @@ -2689,8 +2690,8 @@ pub impl Parser { loop; } - if is_ident_or_path(self.token) { - self.obsolete(copy self.span, + if is_ident_or_path(*self.token) { + self.obsolete(*self.span, ObsoleteTraitBoundSeparator); } } @@ -2732,7 +2733,7 @@ pub impl Parser { } fn is_self_ident() -> bool { - match self.token { + match *self.token { token::IDENT(id, false) if id == special_idents::self_ => true, _ => false @@ -2742,7 +2743,7 @@ pub impl Parser { fn expect_self_ident() { if !self.is_self_ident() { self.fatal(fmt!("expected `self` but found `%s`", - token_to_str(self.reader, self.token))); + token_to_str(self.reader, *self.token))); } self.bump(); } @@ -2773,7 +2774,7 @@ pub impl Parser { // A bit of complexity and lookahead is needed here in order to to be // backwards compatible. let lo = self.span.lo; - let self_ty = match copy self.token { + let self_ty = match *self.token { token::BINOP(token::AND) => { maybe_parse_self_ty(sty_region, self) } @@ -2795,7 +2796,7 @@ pub impl Parser { // If we parsed a self type, expect a comma before the argument list. let args_or_capture_items; if self_ty != sty_by_ref { - match copy self.token { + match *self.token { token::COMMA => { self.bump(); let sep = seq_sep_trailing_disallowed(token::COMMA); @@ -2809,7 +2810,8 @@ pub impl Parser { } _ => { self.fatal(~"expected `,` or `)`, found `" + - token_to_str(self.reader, self.token) + ~"`"); + token_to_str(self.reader, *self.token) + + ~"`"); } } } else { @@ -2850,7 +2852,7 @@ pub impl Parser { let output = if self.eat(token::RARROW) { self.parse_ty(false) } else { - @Ty { id: self.get_id(), node: ty_infer, span: self.span } + @Ty { id: self.get_id(), node: ty_infer, span: *self.span } }; ast::fn_decl { @@ -2929,7 +2931,7 @@ pub impl Parser { // Parse traits, if necessary. let traits; - if self.token == token::COLON { + if *self.token == token::COLON { self.bump(); traits = self.parse_trait_ref_list(token::LBRACE); } else { @@ -2954,7 +2956,7 @@ pub impl Parser { // First, parse type parameters if necessary. let mut tps; - if self.token == token::LT { + if *self.token == token::LT { tps = self.parse_ty_params(); } else { tps = ~[]; @@ -2978,7 +2980,7 @@ pub impl Parser { }) } _ => { - self.span_err(copy self.span, ~"not a trait"); + self.span_err(*self.span, ~"not a trait"); None } }; @@ -2986,7 +2988,7 @@ pub impl Parser { ty = self.parse_ty(false); opt_trait_ref } else if self.eat(token::COLON) { - self.obsolete(copy self.span, ObsoleteImplSyntax); + self.obsolete(*self.span, ObsoleteImplSyntax); Some(self.parse_trait_ref()) } else { None @@ -3008,7 +3010,7 @@ pub impl Parser { // the return type of the ctor function. fn ident_to_path_tys(i: ident, typarams: ~[ty_param]) -> @path { - let s = self.last_span; + let s = *self.last_span; @ast::path { span: s, @@ -3026,7 +3028,7 @@ pub impl Parser { } fn ident_to_path(i: ident) -> @path { - @ast::path { span: self.last_span, + @ast::path { span: *self.last_span, global: false, idents: ~[i], rp: None, @@ -3051,7 +3053,7 @@ pub impl Parser { self.parse_region_param(); let ty_params = self.parse_ty_params(); if self.eat(token::COLON) { - self.obsolete(copy self.span, ObsoleteClassTraits); + self.obsolete(*self.span, ObsoleteClassTraits); let _ = self.parse_trait_ref_list(token::LBRACE); } @@ -3063,7 +3065,7 @@ pub impl Parser { // It's a record-like struct. is_tuple_like = false; fields = ~[]; - while self.token != token::RBRACE { + while *self.token != token::RBRACE { match self.parse_class_item() { dtor_decl(ref blk, ref attrs, s) => { match the_dtor { @@ -3087,7 +3089,7 @@ pub impl Parser { } } self.bump(); - } else if self.token == token::LPAREN { + } else if *self.token == token::LPAREN { // It's a tuple-like struct. is_tuple_like = true; fields = do self.parse_unspanned_seq(token::LPAREN, token::RPAREN, @@ -3109,7 +3111,7 @@ pub impl Parser { } else { self.fatal(fmt!("expected `{`, `(`, or `;` after struct name \ but found `%s`", - token_to_str(self.reader, self.token))); + token_to_str(self.reader, *self.token))); } let actual_dtor = do the_dtor.map |dtor| { @@ -3139,13 +3141,13 @@ pub impl Parser { fn parse_single_class_item(vis: visibility) -> @struct_field { if self.eat_obsolete_ident("let") { - self.obsolete(copy self.last_span, ObsoleteLet); + self.obsolete(*self.last_span, ObsoleteLet); } let a_var = self.parse_instance_var(vis); - match self.token { + match *self.token { token::SEMI => { - self.obsolete(copy self.span, ObsoleteFieldTerminator); + self.obsolete(*self.span, ObsoleteFieldTerminator); self.bump(); } token::COMMA => { @@ -3153,11 +3155,11 @@ pub impl Parser { } token::RBRACE => {} _ => { - self.span_fatal(copy self.span, + self.span_fatal(*self.span, fmt!("expected `;`, `,`, or '}' but \ found `%s`", token_to_str(self.reader, - self.token))); + *self.token))); } } a_var @@ -3226,7 +3228,7 @@ pub impl Parser { // outer attributes can't occur on view items (or macros // invocations?) let mut first = true; - while self.token != term { + while *self.token != term { let mut attrs = self.parse_outer_attributes(); if first { attrs = vec::append(attrs_remaining, attrs); @@ -3243,7 +3245,7 @@ pub impl Parser { } _ => { self.fatal(~"expected item but found `" + - token_to_str(self.reader, self.token) + ~"`"); + token_to_str(self.reader, *self.token) + ~"`"); } } debug!("parse_mod_items: attrs=%?", attrs); @@ -3268,9 +3270,9 @@ pub impl Parser { } fn parse_item_mod(outer_attrs: ~[ast::attribute]) -> item_info { - let id_span = self.span; + let id_span = *self.span; let id = self.parse_ident(); - let info_ = if self.token == token::SEMI { + let info_ = if *self.token == token::SEMI { self.bump(); // This mod is in an external file. Let's go get it! let (m, attrs) = self.eval_src_mod(id, outer_attrs, id_span); @@ -3292,7 +3294,7 @@ pub impl Parser { match ::attr::first_attr_value_str_by_name(outer_attrs, ~"merge") { Some(path) => { let prefix = Path( - self.sess.cm.span_to_filename(copy self.span)); + self.sess.cm.span_to_filename(*self.span)); let prefix = prefix.dir_path(); let path = Path(copy *path); let (new_mod_item, new_attrs) = self.eval_src_mod_from_path( @@ -3337,9 +3339,9 @@ pub impl Parser { outer_attrs: ~[ast::attribute], id_sp: span) -> (ast::item_, ~[ast::attribute]) { - let prefix = Path(self.sess.cm.span_to_filename(copy self.span)); + let prefix = Path(self.sess.cm.span_to_filename(*self.span)); let prefix = prefix.dir_path(); - let mod_path = Path(".").push_many(self.mod_path_stack); + let mod_path = Path(".").push_many(*self.mod_path_stack); let default_path = self.sess.interner.get(id) + ~".rs"; let file_path = match ::attr::first_attr_value_str_by_name( outer_attrs, ~"path") { @@ -3456,7 +3458,7 @@ pub impl Parser { let mut items: ~[@foreign_item] = foreign_items; let mut initial_attrs = attrs_remaining; - while self.token != token::RBRACE { + while *self.token != token::RBRACE { let attrs = vec::append(initial_attrs, self.parse_outer_attributes()); initial_attrs = ~[]; @@ -3478,7 +3480,7 @@ pub impl Parser { // Parse the ABI. let abi_opt; - match self.token { + match *self.token { token::LIT_STR(copy found_abi) => { self.bump(); abi_opt = Some(found_abi); @@ -3492,21 +3494,21 @@ pub impl Parser { if self.is_keyword(~"mod") { must_be_named_mod = true; self.expect_keyword(~"mod"); - } else if self.token != token::LBRACE { - self.span_fatal(copy self.span, + } else if *self.token != token::LBRACE { + self.span_fatal(*self.span, fmt!("expected `{` or `mod` but found %s", - token_to_str(self.reader, self.token))); + token_to_str(self.reader, *self.token))); } - let (sort, ident) = match self.token { + let (sort, ident) = match *self.token { token::IDENT(*) => (ast::named, self.parse_ident()), _ => { if must_be_named_mod { - self.span_fatal(copy self.span, + self.span_fatal(*self.span, fmt!("expected foreign module name but \ found %s", token_to_str(self.reader, - self.token))); + *self.token))); } (ast::anonymous, @@ -3534,7 +3536,7 @@ pub impl Parser { match abi_opt { None => {} // OK. Some(_) => { - self.span_err(copy self.span, ~"an ABI may not be specified \ + self.span_err(*self.span, ~"an ABI may not be specified \ here"); } } @@ -3575,7 +3577,7 @@ pub impl Parser { fn parse_struct_def() -> @struct_def { let mut the_dtor: Option<(blk, ~[attribute], codemap::span)> = None; let mut fields: ~[@struct_field] = ~[]; - while self.token != token::RBRACE { + while *self.token != token::RBRACE { match self.parse_class_item() { dtor_decl(ref blk, ref attrs, s) => { match the_dtor { @@ -3621,7 +3623,7 @@ pub impl Parser { let mut all_nullary = true, have_disr = false; let mut common_fields = None; - while self.token != token::RBRACE { + while *self.token != token::RBRACE { let variant_attrs = self.parse_outer_attributes(); let vlo = self.span.lo; @@ -3652,7 +3654,7 @@ pub impl Parser { // Parse a struct variant. all_nullary = false; kind = struct_variant_kind(self.parse_struct_def()); - } else if self.token == token::LPAREN { + } else if *self.token == token::LPAREN { all_nullary = false; let arg_tys = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, @@ -3701,7 +3703,7 @@ pub impl Parser { self.parse_region_param(); let ty_params = self.parse_ty_params(); // Newtype syntax - if self.token == token::EQ { + if *self.token == token::EQ { self.bump(); let ty = self.parse_ty(false); self.expect(token::SEMI); @@ -3733,7 +3735,7 @@ pub impl Parser { } fn parse_fn_ty_sigil() -> Option { - match self.token { + match *self.token { token::AT => { self.bump(); Some(ManagedSigil) @@ -3879,7 +3881,7 @@ pub impl Parser { vis: visibility, span: mk_sp(lo, self.last_span.hi) }); - } else if macros_allowed && !self.is_any_keyword(copy self.token) + } else if macros_allowed && !self.is_any_keyword(*self.token) && self.look_ahead(1) == token::NOT && (is_plain_ident(self.look_ahead(2)) || self.look_ahead(2) == token::LPAREN @@ -3896,16 +3898,16 @@ pub impl Parser { // a 'special' identifier (like what `macro_rules!` uses) // is optional. We should eventually unify invoc syntax // and remove this. - let id = if is_plain_ident(self.token) { + let id = if is_plain_ident(*self.token) { self.parse_ident() } else { token::special_idents::invalid // no special identifier }; // eat a matched-delimiter token tree: - let tts = match self.token { + let tts = match *self.token { token::LPAREN | token::LBRACE => { - let ket = token::flip_delimiter(copy self.token); - self.parse_unspanned_seq(copy self.token, ket, + let ket = token::flip_delimiter(*self.token); + self.parse_unspanned_seq(*self.token, ket, seq_sep_none(), |p| p.parse_token_tree()) } @@ -3925,7 +3927,7 @@ pub impl Parser { let mut s = ~"unmatched visibility `"; s += if visibility == public { ~"pub" } else { ~"priv" }; s += ~"`"; - self.span_fatal(copy self.last_span, s); + self.span_fatal(*self.last_span, s); } return iovi_none; }; @@ -3961,12 +3963,12 @@ pub impl Parser { let first_ident = self.parse_ident(); let mut path = ~[first_ident]; debug!("parsed view_path: %s", *self.id_to_str(first_ident)); - match self.token { + match *self.token { token::EQ => { // x = foo::bar self.bump(); path = ~[self.parse_ident()]; - while self.token == token::MOD_SEP { + while *self.token == token::MOD_SEP { self.bump(); let id = self.parse_ident(); path.push(id); @@ -3983,11 +3985,10 @@ pub impl Parser { token::MOD_SEP => { // foo::bar or foo::{a,b,c} or foo::* - while self.token == token::MOD_SEP { + while *self.token == token::MOD_SEP { self.bump(); - match copy self.token { - + match *self.token { token::IDENT(i, _) => { self.bump(); path.push(i); @@ -4038,7 +4039,7 @@ pub impl Parser { fn parse_view_paths() -> ~[@view_path] { let mut vp = ~[self.parse_view_path()]; - while self.token == token::COMMA { + while *self.token == token::COMMA { self.bump(); vp.push(self.parse_view_path()); } @@ -4048,7 +4049,7 @@ pub impl Parser { fn is_view_item() -> bool { let tok, next_tok; if !self.is_keyword(~"pub") && !self.is_keyword(~"priv") { - tok = self.token; + tok = *self.token; next_tok = self.look_ahead(1); } else { tok = self.look_ahead(1); @@ -4159,7 +4160,7 @@ pub impl Parser { } fn parse_str() -> @~str { - match copy self.token { + match *self.token { token::LIT_STR(s) => { self.bump(); self.id_to_str(s) } _ => self.fatal(~"expected string literal") }