diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-09-26 17:33:34 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-09-26 18:02:07 -0700 |
| commit | 67a8e7128aea292445b763b47b04bc5f4fd43cb2 (patch) | |
| tree | 9ddde322dbc8fd5af39e903419cae508d9df05f6 /src/libsyntax | |
| parent | cd79e1d1b20a2c289dd15bc2766f97c789d975aa (diff) | |
| download | rust-67a8e7128aea292445b763b47b04bc5f4fd43cb2.tar.gz rust-67a8e7128aea292445b763b47b04bc5f4fd43cb2.zip | |
Demode vec::push (and convert to method)
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/auto_serialize2.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/liveness.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 86 | ||||
| -rw-r--r-- | src/libsyntax/ext/simplext.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 24 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/parse/common.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/eval.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 136 |
18 files changed, 159 insertions, 164 deletions
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 09922ade073..b6d4c2d0fe3 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -273,9 +273,9 @@ fn map_item(i: @item, cx: ctx, v: vt) { } match i.node { item_mod(_) | item_foreign_mod(_) => { - vec::push(cx.path, path_mod(i.ident)); + cx.path.push(path_mod(i.ident)); } - _ => vec::push(cx.path, path_name(i.ident)) + _ => cx.path.push(path_name(i.ident)) } visit::visit_item(i, cx, v); vec::pop(cx.path); diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 98a471bd54c..329c9f362a4 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -313,8 +313,8 @@ fn split_trait_methods(trait_methods: ~[trait_method]) let mut reqd = ~[], provd = ~[]; for trait_methods.each |trt_method| { match *trt_method { - required(tm) => vec::push(reqd, tm), - provided(m) => vec::push(provd, m) + required(tm) => reqd.push(tm), + provided(m) => provd.push(m) } }; (reqd, provd) diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index eb4ffb26fb1..7ef34d8eb0b 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -91,7 +91,7 @@ fn attr_meta(attr: ast::attribute) -> @ast::meta_item { @attr.node.value } // Get the meta_items from inside a vector of attributes fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { let mut mitems = ~[]; - for attrs.each |a| { vec::push(mitems, attr_meta(*a)); } + for attrs.each |a| { mitems.push(attr_meta(*a)); } return mitems; } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index ae49e19c862..e07985119ec 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -84,7 +84,7 @@ fn mk_substr_filename(cm: codemap, sp: span) -> ~str } fn next_line(file: filemap, chpos: uint, byte_pos: uint) { - vec::push(file.lines, {ch: chpos, byte: byte_pos + file.start_pos.byte}); + file.lines.push({ch: chpos, byte: byte_pos + file.start_pos.byte}); } type lookup_fn = pure fn(file_pos) -> uint; @@ -204,7 +204,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { let hi = lookup_char_pos(cm, sp.hi); let mut lines = ~[]; for uint::range(lo.line - 1u, hi.line as uint) |i| { - vec::push(lines, i); + lines.push(i); }; return @{file: lo.file, lines: lines}; } diff --git a/src/libsyntax/ext/auto_serialize2.rs b/src/libsyntax/ext/auto_serialize2.rs index 264711584fc..b51184eefd8 100644 --- a/src/libsyntax/ext/auto_serialize2.rs +++ b/src/libsyntax/ext/auto_serialize2.rs @@ -750,7 +750,7 @@ fn mk_enum_deser_body( body: cx.expr_blk(cx.expr(span, ast::expr_fail(None))), }; - vec::push(arms, impossible_case); + arms.push(impossible_case); // ast for `|i| { match i { $(arms) } }` let expr_lambda = cx.expr( diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 1cbcd0f6ddb..566cdc4fa21 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -160,7 +160,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, fn cfg() -> ast::crate_cfg { self.cfg } fn print_backtrace() { } fn backtrace() -> expn_info { self.backtrace } - fn mod_push(i: ast::ident) { vec::push(self.mod_path, i); } + fn mod_push(i: ast::ident) { self.mod_path.push(i); } fn mod_pop() { vec::pop(self.mod_path); } fn mod_path() -> ~[ast::ident] { return self.mod_path; } fn bt_push(ei: codemap::expn_info_) { diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 8574c0c9082..8ce426f0357 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -96,7 +96,7 @@ fn mk_rec_e(cx: ext_ctxt, sp: span, let val = field.ex; let astfield = {node: {mutbl: ast::m_imm, ident: ident, expr: val}, span: sp}; - vec::push(astfields, astfield); + astfields.push(astfield); } let recexpr = ast::expr_rec(astfields, option::None::<@ast::expr>); mk_expr(cx, sp, recexpr) diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 3ea0493239f..e4f197801c2 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -245,7 +245,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, for pieces.each |pc| { match *pc { PieceString(s) => { - vec::push(piece_exprs, mk_uniq_str(cx, fmt_sp, s)) + piece_exprs.push(mk_uniq_str(cx, fmt_sp, s)) } PieceConv(conv) => { n += 1u; @@ -258,7 +258,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, log_conv(conv); let arg_expr = args[n]; let c_expr = make_new_conv(cx, fmt_sp, conv, arg_expr); - vec::push(piece_exprs, c_expr); + piece_exprs.push(c_expr); } } } diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index 8b17ffc1104..a9bfd87ab0e 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -65,7 +65,7 @@ fn analyze(proto: protocol, _cx: ext_ctxt) { let mut self_live = ~[]; for colive.eachi |i, bv| { if bv.get(i) { - vec::push(self_live, proto.get_state_by_id(i)) + self_live.push(proto.get_state_by_id(i)) } } diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 11250cfbf38..f93fa830f92 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -226,7 +226,7 @@ impl state: to_type_decls { let v = cx.variant(cx.ident_of(name), span, tys); - vec::push(items_msg, v); + items_msg.push(v); } ~[cx.item_enum_poly(name, @@ -245,44 +245,44 @@ impl state: to_type_decls { let mut items = ~[]; for self.messages.each |m| { if dir == send { - vec::push(items, m.gen_send(cx, true)); - vec::push(items, m.gen_send(cx, false)); + items.push(m.gen_send(cx, true)); + items.push(m.gen_send(cx, false)); } } if !self.proto.is_bounded() { - vec::push(items, - cx.item_ty_poly( - self.data_name(), - self.span, - cx.ty_path_ast_builder( - path(~[cx.ident_of(~"pipes"), - cx.ident_of(dir.to_str() + ~"Packet")], - empty_span()) - .add_ty(cx.ty_path_ast_builder( - path(~[cx.ident_of(self.proto.name), - self.data_name()], - empty_span()) - .add_tys(cx.ty_vars(self.ty_params))))), - self.ty_params)); + items.push( + cx.item_ty_poly( + self.data_name(), + self.span, + cx.ty_path_ast_builder( + path(~[cx.ident_of(~"pipes"), + cx.ident_of(dir.to_str() + ~"Packet")], + empty_span()) + .add_ty(cx.ty_path_ast_builder( + path(~[cx.ident_of(self.proto.name), + self.data_name()], + empty_span()) + .add_tys(cx.ty_vars(self.ty_params))))), + self.ty_params)); } else { - vec::push(items, - cx.item_ty_poly( - self.data_name(), - self.span, - cx.ty_path_ast_builder( - path(~[cx.ident_of(~"pipes"), - cx.ident_of(dir.to_str() - + ~"PacketBuffered")], - empty_span()) - .add_tys(~[cx.ty_path_ast_builder( - path(~[cx.ident_of(self.proto.name), - self.data_name()], - empty_span()) - .add_tys(cx.ty_vars(self.ty_params))), - self.proto.buffer_ty_path(cx)])), - self.ty_params)); + items.push( + cx.item_ty_poly( + self.data_name(), + self.span, + cx.ty_path_ast_builder( + path(~[cx.ident_of(~"pipes"), + cx.ident_of(dir.to_str() + + ~"PacketBuffered")], + empty_span()) + .add_tys(~[cx.ty_path_ast_builder( + path(~[cx.ident_of(self.proto.name), + self.data_name()], + empty_span()) + .add_tys(cx.ty_vars(self.ty_params))), + self.proto.buffer_ty_path(cx)])), + self.ty_params)); }; items } @@ -367,7 +367,7 @@ impl protocol: gen_init { for (copy self.states).each |s| { for s.ty_params.each |tp| { match params.find(|tpp| tp.ident == tpp.ident) { - None => vec::push(params, *tp), + None => params.push(*tp), _ => () } } @@ -383,7 +383,7 @@ impl protocol: gen_init { let fields = do (copy self.states).map_to_vec |s| { for s.ty_params.each |tp| { match params.find(|tpp| tp.ident == tpp.ident) { - None => vec::push(params, *tp), + None => params.push(*tp), _ => () } } @@ -415,17 +415,15 @@ impl protocol: gen_init { } if self.is_bounded() { - vec::push(items, self.gen_buffer_type(cx)) + items.push(self.gen_buffer_type(cx)) } - vec::push(items, - cx.item_mod(cx.ident_of(~"client"), - self.span, - client_states)); - vec::push(items, - cx.item_mod(cx.ident_of(~"server"), - self.span, - server_states)); + items.push(cx.item_mod(cx.ident_of(~"client"), + self.span, + client_states)); + items.push(cx.item_mod(cx.ident_of(~"server"), + self.span, + server_states)); cx.item_mod(cx.ident_of(self.name), self.span, items) } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 4729e7da39c..51239754635 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -94,7 +94,7 @@ fn option_flatten_map<T: Copy, U: Copy>(f: fn@(T) -> Option<U>, v: ~[T]) -> for v.each |elem| { match f(*elem) { None => return None, - Some(fv) => vec::push(res, fv) + Some(fv) => res.push(fv) } } return Some(res); @@ -305,8 +305,8 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], /* Whew, we now know how how many times to repeat */ let mut idx: uint = 0u; while idx < rc { - vec::push(*idx_path, idx); - vec::push(res, recur(repeat_me)); // whew! + idx_path.push(idx); + res.push(recur(repeat_me)); // whew! vec::pop(*idx_path); idx += 1u; } @@ -567,7 +567,7 @@ fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector, let mut elts = ~[]; let mut idx = offset; while idx < vec::len(arg_elts) { - vec::push(elts, leaf(match_expr(arg_elts[idx]))); + elts.push(leaf(match_expr(arg_elts[idx]))); idx += 1u; } @@ -672,9 +672,8 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, None => cx.span_fatal(mac.span, ~"macro must have arguments") }; - vec::push(clauses, - @{params: pattern_to_selectors(cx, arg), - body: elts[1u]}); + clauses.push(@{params: pattern_to_selectors(cx, arg), + body: elts[1u]}); // FIXME (#2251): check duplicates (or just simplify // the macro arg situation) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index a7a45942822..737694337e3 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -208,7 +208,7 @@ fn parse_or_else(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) -> parse_result { let mut cur_eis = ~[]; - vec::push(cur_eis, initial_matcher_pos(ms, None, rdr.peek().sp.lo)); + cur_eis.push(initial_matcher_pos(ms, None, rdr.peek().sp.lo)); loop { let mut bb_eis = ~[]; // black-box parsed by parser.rs @@ -256,7 +256,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } new_pos.idx += 1; - vec::push(cur_eis, move new_pos); + cur_eis.push(move new_pos); } // can we go around again? @@ -267,17 +267,17 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) if tok == t { //pass the separator let ei_t <- ei; ei_t.idx += 1; - vec::push(next_eis, move ei_t); + next_eis.push(move ei_t); } } _ => { // we don't need a separator let ei_t <- ei; ei_t.idx = 0; - vec::push(cur_eis, move ei_t); + cur_eis.push(move ei_t); } } } else { - vec::push(eof_eis, move ei); + eof_eis.push(move ei); } } else { match copy ei.elts[idx].node { @@ -292,13 +292,13 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) new_ei.matches[idx].push(@matched_seq(~[], sp)); } - vec::push(cur_eis, move new_ei); + cur_eis.push(move new_ei); } let matches = vec::map(ei.matches, // fresh, same size: |_m| DVec::<@named_match>()); let ei_t <- ei; - vec::push(cur_eis, ~{ + cur_eis.push(~{ elts: matchers, sep: sep, mut idx: 0u, mut up: matcher_pos_up(Some(move ei_t)), matches: move matches, @@ -306,12 +306,12 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) sp_lo: sp.lo }); } - match_nonterminal(_,_,_) => { vec::push(bb_eis, move ei) } + match_nonterminal(_,_,_) => { bb_eis.push(move ei) } match_tok(t) => { let ei_t <- ei; if t == tok { ei_t.idx += 1; - vec::push(next_eis, move ei_t); + next_eis.push(move ei_t); } } } @@ -323,7 +323,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) if eof_eis.len() == 1u { return success( nameize(sess, ms, - vec::map(eof_eis[0u].matches, |dv| dv.pop()))); + eof_eis[0u].matches.map(|dv| dv.pop()))); } else if eof_eis.len() > 1u { return error(sp, ~"Ambiguity: multiple successful parses"); } else { @@ -350,7 +350,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } else if (next_eis.len() > 0u) { /* Now process the next token */ while(next_eis.len() > 0u) { - vec::push(cur_eis, vec::pop(next_eis)); + cur_eis.push(vec::pop(next_eis)); } rdr.next_token(); } else /* bb_eis.len() == 1 */ { @@ -365,7 +365,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } _ => fail } - vec::push(cur_eis, move ei); + cur_eis.push(move ei); /* this would fail if zero-length tokens existed */ while rdr.peek().sp.lo < rust_parser.span.lo { diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index b208e4f8c6f..558593579bf 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -205,8 +205,8 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { r.cur.idx += 1u; return tt_next_token(r); } else { - vec::push(r.repeat_len, len); - vec::push(r.repeat_idx, 0u); + r.repeat_len.push(len); + r.repeat_idx.push(0u); r.cur = @{readme: tts, mut idx: 0u, dotdotdoted: true, sep: sep, up: tt_frame_up(option::Some(r.cur))}; } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index f8f481c8f66..12c8dc2f7bb 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -367,9 +367,8 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { pat_rec(fields, etc) => { let mut fs = ~[]; for fields.each |f| { - vec::push(fs, - {ident: /* FIXME (#2543) */ copy f.ident, - pat: fld.fold_pat(f.pat)}); + fs.push({ident: /* FIXME (#2543) */ copy f.ident, + pat: fld.fold_pat(f.pat)}); } pat_rec(fs, etc) } @@ -377,9 +376,8 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { let pth_ = fld.fold_path(pth); let mut fs = ~[]; for fields.each |f| { - vec::push(fs, - {ident: /* FIXME (#2543) */ copy f.ident, - pat: fld.fold_pat(f.pat)}); + fs.push({ident: /* FIXME (#2543) */ copy f.ident, + pat: fld.fold_pat(f.pat)}); } pat_struct(pth_, fs, etc) } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index ddc70a1f13e..cb8416501b3 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -130,7 +130,7 @@ fn consume_non_eol_whitespace(rdr: string_reader) { fn push_blank_line_comment(rdr: string_reader, &comments: ~[cmnt]) { debug!(">>> blank-line comment"); let v: ~[~str] = ~[]; - vec::push(comments, {style: blank_line, lines: v, pos: rdr.chpos}); + comments.push({style: blank_line, lines: v, pos: rdr.chpos}); } fn consume_whitespace_counting_blank_lines(rdr: string_reader, @@ -149,7 +149,7 @@ fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool, debug!(">>> shebang comment"); let p = rdr.chpos; debug!("<<< shebang comment"); - vec::push(comments, { + comments.push({ style: if code_to_the_left { trailing } else { isolated }, lines: ~[read_one_line_comment(rdr)], pos: p @@ -167,12 +167,12 @@ fn read_line_comments(rdr: string_reader, code_to_the_left: bool, if is_doc_comment(line) { // doc-comments are not put in comments break; } - vec::push(lines, line); + lines.push(line); consume_non_eol_whitespace(rdr); } debug!("<<< line comments"); if !lines.is_empty() { - vec::push(comments, { + comments.push({ style: if code_to_the_left { trailing } else { isolated }, lines: lines, pos: p @@ -198,7 +198,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str], } else { s1 = ~""; } } else { s1 = s; } log(debug, ~"pushing line: " + s1); - vec::push(lines, s1); + lines.push(s1); } fn read_block_comment(rdr: string_reader, code_to_the_left: bool, @@ -257,7 +257,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool, style = mixed; } debug!("<<< block comment"); - vec::push(comments, {style: style, lines: lines, pos: p}); + comments.push({style: style, lines: lines, pos: p}); } fn peeking_at_comment(rdr: string_reader) -> bool { @@ -315,7 +315,7 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler, let {tok: tok, sp: sp} = rdr.peek(); if token::is_lit(tok) { let s = get_str_from(rdr, bstart); - vec::push(literals, {lit: s, pos: sp.lo}); + literals.push({lit: s, pos: sp.lo}); log(debug, ~"tok lit: " + s); } else { log(debug, ~"tok: " + token::to_str(rdr.interner, tok)); diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 4b8bfcda848..c8c30ee7fa9 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -229,7 +229,7 @@ impl parser: parser_common { } _ => () } - vec::push(v, f(self)); + v.push(f(self)); } return v; @@ -274,7 +274,7 @@ impl parser: parser_common { _ => () } if sep.trailing_sep_allowed && self.token == ket { break; } - vec::push(v, f(self)); + v.push(f(self)); } return v; } diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 7127e2747eb..14dc490346e 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -107,7 +107,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path, // Thread defids, chpos and byte_pos through the parsers cx.sess.chpos = r0.chpos; cx.sess.byte_pos = cx.sess.byte_pos + r0.pos; - vec::push(items, i); + items.push(i); } ast::cdir_dir_mod(vis, id, cdirs, attrs) => { let path = Path(cdir_path_opt(*cx.sess.interner.get(id), attrs)); @@ -126,9 +126,9 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path, vis: vis, span: cdir.span}; cx.sess.next_id += 1; - vec::push(items, i); + items.push(i); } - ast::cdir_view_item(vi) => vec::push(view_items, vi), + ast::cdir_view_item(vi) => view_items.push(vi), ast::cdir_syntax(*) => () } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9d970e23f68..10981c5c708 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -496,7 +496,7 @@ impl parser { let mut ts = ~[self.parse_ty(false)]; while self.token == token::COMMA { self.bump(); - vec::push(ts, self.parse_ty(false)); + ts.push(self.parse_ty(false)); } let t = if vec::len(ts) == 1u { ts[0].node } else { ty_tup(ts) }; @@ -771,10 +771,10 @@ impl parser { && self.look_ahead(1u) == token::MOD_SEP; if is_not_last { - vec::push(ids, parse_ident(self)); + ids.push(parse_ident(self)); self.expect(token::MOD_SEP); } else { - vec::push(ids, parse_last_ident(self)); + ids.push(parse_last_ident(self)); break; } } @@ -903,7 +903,7 @@ impl parser { } let mut es = ~[self.parse_expr()]; while self.token == token::COMMA { - self.bump(); vec::push(es, self.parse_expr()); + self.bump(); es.push(self.parse_expr()); } hi = self.span.hi; self.expect(token::RPAREN); @@ -1049,7 +1049,7 @@ impl parser { self.bump(); let mut fields = ~[]; let mut base = None; - vec::push(fields, self.parse_field(token::COLON)); + fields.push(self.parse_field(token::COLON)); while self.token != token::RBRACE { if self.try_parse_obsolete_with() { @@ -1067,7 +1067,7 @@ impl parser { // Accept an optional trailing comma. break; } - vec::push(fields, self.parse_field(token::COLON)); + fields.push(self.parse_field(token::COLON)); } hi = pth.span.hi; @@ -1316,7 +1316,7 @@ impl parser { while self.token != ket || lparens > 0u { if self.token == token::LPAREN { lparens += 1u; } if self.token == token::RPAREN { lparens -= 1u; } - vec::push(ret_val, self.parse_matcher(name_idx)); + ret_val.push(self.parse_matcher(name_idx)); } self.bump(); @@ -1722,7 +1722,7 @@ impl parser { // record ends by an optional trailing comma break; } - vec::push(fields, self.parse_field(token::COLON)); + fields.push(self.parse_field(token::COLON)); } self.expect(token::RBRACE); return expr_rec(fields, base); @@ -1757,7 +1757,7 @@ impl parser { rules: default_blk}, span: expr.span}; - vec::push(arms, {pats: pats, guard: guard, body: blk}); + arms.push({pats: pats, guard: guard, body: blk}); } let mut hi = self.span.hi; self.bump(); @@ -1802,7 +1802,7 @@ impl parser { fn parse_pats() -> ~[@pat] { let mut pats = ~[]; loop { - vec::push(pats, self.parse_pat(true)); + pats.push(self.parse_pat(true)); if self.token == token::BINOP(token::OR) { self.bump(); } else { return pats; } }; @@ -1849,7 +1849,7 @@ impl parser { span: self.last_span }; } - vec::push(fields, {ident: fieldname, pat: subpat}); + fields.push({ident: fieldname, pat: subpat}); } return (fields, etc); } @@ -1937,7 +1937,7 @@ impl parser { let mut fields = ~[self.parse_pat(refutable)]; while self.token == token::COMMA { self.bump(); - vec::push(fields, self.parse_pat(refutable)); + fields.push(self.parse_pat(refutable)); } if vec::len(fields) == 1u { self.expect(token::COMMA); } hi = self.span.hi; @@ -2126,7 +2126,7 @@ impl parser { let lo = self.span.lo; let mut locals = ~[self.parse_local(is_mutbl, true)]; while self.eat(token::COMMA) { - vec::push(locals, self.parse_local(is_mutbl, true)); + locals.push(self.parse_local(is_mutbl, true)); } return @spanned(lo, self.last_span.hi, decl_local(locals)); } @@ -2266,8 +2266,8 @@ impl parser { for items.each |item| { let decl = @spanned(item.span.lo, item.span.hi, decl_item(*item)); - push(stmts, @spanned(item.span.lo, item.span.hi, - stmt_decl(decl, self.get_id()))); + stmts.push(@spanned(item.span.lo, item.span.hi, + stmt_decl(decl, self.get_id()))); } let mut initial_attrs = attrs_remaining; @@ -2278,43 +2278,43 @@ impl parser { while self.token != token::RBRACE { match self.token { - token::SEMI => { - self.bump(); // empty - } - _ => { - let stmt = self.parse_stmt(initial_attrs); - initial_attrs = ~[]; - match stmt.node { - stmt_expr(e, stmt_id) => { // Expression without semicolon: - match self.token { - token::SEMI => { - self.bump(); - push(stmts, - @{node: stmt_semi(e, stmt_id),.. *stmt}); - } - token::RBRACE => { - expr = Some(e); - } - t => { - if classify::stmt_ends_with_semi(*stmt) { - self.fatal(~"expected `;` or `}` after \ - expression but found `" - + token_to_str(self.reader, t) + ~"`"); + token::SEMI => { + self.bump(); // empty + } + _ => { + let stmt = self.parse_stmt(initial_attrs); + initial_attrs = ~[]; + match stmt.node { + stmt_expr(e, stmt_id) => { // Expression without semicolon: + match self.token { + token::SEMI => { + self.bump(); + stmts.push(@{node: stmt_semi(e, stmt_id), + ..*stmt}); + } + token::RBRACE => { + expr = Some(e); + } + t => { + if classify::stmt_ends_with_semi(*stmt) { + self.fatal(~"expected `;` or `}` after \ + expression but found `" + + token_to_str(self.reader, t) + ~"`"); + } + stmts.push(stmt); + } + } } - vec::push(stmts, stmt); - } - } - } - _ => { // All other kinds of statements: - vec::push(stmts, stmt); + _ => { // All other kinds of statements: + stmts.push(stmt); - if classify::stmt_ends_with_semi(*stmt) { - self.expect(token::SEMI); + if classify::stmt_ends_with_semi(*stmt) { + self.expect(token::SEMI); + } + } } - } } - } } } let mut hi = self.span.hi; @@ -2356,16 +2356,16 @@ impl parser { }; match maybe_bound { - Some(bound) => { - self.bump(); - push(bounds, bound); - } - None => { - push(bounds, bound_trait(self.parse_ty(false))); - } + Some(bound) => { + self.bump(); + bounds.push(bound); + } + None => { + bounds.push(bound_trait(self.parse_ty(false))); + } } } else { - push(bounds, bound_trait(self.parse_ty(false))); + bounds.push(bound_trait(self.parse_ty(false))); } } } @@ -2636,7 +2636,7 @@ impl parser { self.expect(token::LBRACE); while !self.eat(token::RBRACE) { let vis = self.parse_visibility(); - vec::push(meths, self.parse_method(vis)); + meths.push(self.parse_method(vis)); } (ident, item_impl(tps, opt_trait, ty, meths), None) } @@ -2722,9 +2722,9 @@ impl parser { for mms.each |mm| { match *mm { @field_member(struct_field) => - vec::push(fields, struct_field), + fields.push(struct_field), @method_member(the_method_member) => - vec::push(methods, the_method_member) + methods.push(the_method_member) } } } @@ -2896,7 +2896,7 @@ impl parser { debug!("parse_mod_items: parse_item_or_view_item(attrs=%?)", attrs); match self.parse_item_or_view_item(attrs, true) { - iovi_item(item) => vec::push(items, item), + iovi_item(item) => items.push(item), iovi_view_item(view_item) => { self.span_fatal(view_item.span, ~"view items must be \ declared at the top of the \ @@ -3000,7 +3000,7 @@ impl parser { let attrs = vec::append(initial_attrs, self.parse_outer_attributes()); initial_attrs = ~[]; - vec::push(items, self.parse_foreign_item(attrs)); + items.push(self.parse_foreign_item(attrs)); } return {sort: sort, view_items: view_items, items: items}; @@ -3113,9 +3113,9 @@ impl parser { for mms.each |mm| { match *mm { @field_member(struct_field) => - vec::push(fields, struct_field), + fields.push(struct_field), @method_member(the_method_member) => - vec::push(methods, the_method_member) + methods.push(the_method_member) } } } @@ -3184,7 +3184,7 @@ impl parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_ty(false)); for arg_tys.each |ty| { - vec::push(args, {ty: *ty, id: self.get_id()}); + args.push({ty: *ty, id: self.get_id()}); } kind = tuple_variant_kind(args); } else if self.eat(token::EQ) { @@ -3200,7 +3200,7 @@ impl parser { let vr = {name: ident, attrs: variant_attrs, kind: kind, id: self.get_id(), disr_expr: disr_expr, vis: vis}; - vec::push(variants, spanned(vlo, self.last_span.hi, vr)); + variants.push(spanned(vlo, self.last_span.hi, vr)); if needs_comma && !self.eat(token::COMMA) { break; } } @@ -3427,7 +3427,7 @@ impl parser { while self.token == token::MOD_SEP { self.bump(); let id = self.parse_ident(); - vec::push(path, id); + path.push(id); } let path = @{span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: None, types: ~[]}; @@ -3445,7 +3445,7 @@ impl parser { token::IDENT(i, _) => { self.bump(); - vec::push(path, i); + path.push(i); } // foo::bar::{a,b,c} @@ -3488,7 +3488,7 @@ impl parser { let mut vp = ~[self.parse_view_path()]; while self.token == token::COMMA { self.bump(); - vec::push(vp, self.parse_view_path()); + vp.push(self.parse_view_path()); } return vp; } @@ -3662,7 +3662,7 @@ impl parser { let mut first_outer_attr = first_outer_attr; while self.token != term { let cdir = @self.parse_crate_directive(first_outer_attr); - vec::push(cdirs, cdir); + cdirs.push(cdir); first_outer_attr = ~[]; } return cdirs; |
