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/parse | |
| parent | cd79e1d1b20a2c289dd15bc2766f97c789d975aa (diff) | |
| download | rust-67a8e7128aea292445b763b47b04bc5f4fd43cb2.tar.gz rust-67a8e7128aea292445b763b47b04bc5f4fd43cb2.zip | |
Demode vec::push (and convert to method)
Diffstat (limited to 'src/libsyntax/parse')
| -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 |
4 files changed, 80 insertions, 80 deletions
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; |
