From ef23d77633484e4e85f8b37431e3b08ede3e4802 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 26 Sep 2012 10:47:21 +0200 Subject: fix issue #3535 and add colon between mode and type when dumping funcion prototype --- src/libsyntax/parse/parser.rs | 45 +++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 681d6296d4e..bc232f1259e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -584,6 +584,29 @@ impl parser { } else { infer(self.get_id()) } } + fn is_named_argument() -> bool { + let offset = if self.token == token::BINOP(token::AND) { + 1 + } else if self.token == token::BINOP(token::MINUS) { + 1 + } else if self.token == token::ANDAND { + 1 + } else if self.token == token::BINOP(token::PLUS) { + if self.look_ahead(1) == token::BINOP(token::PLUS) { + 2 + } else { + 1 + } + } else { 0 }; + if offset == 0 { + is_plain_ident(self.token) + && self.look_ahead(1) == token::COLON + } else { + is_plain_ident(self.look_ahead(offset)) + && self.look_ahead(offset + 1) == token::COLON + } + } + fn parse_capture_item_or(parse_arg_fn: fn(parser) -> arg_or_capture_item) -> arg_or_capture_item { @@ -605,29 +628,17 @@ impl parser { // This version of parse arg doesn't necessarily require // identifier names. fn parse_arg_general(require_name: bool) -> arg { - let m = self.parse_arg_mode(); - let i = if require_name { + let mut m; + let i = if require_name || self.is_named_argument() { + m = self.parse_arg_mode(); let name = self.parse_value_ident(); self.expect(token::COLON); name } else { - if is_plain_ident(self.token) - && self.look_ahead(1u) == token::COLON { - let name = self.parse_value_ident(); - self.bump(); - name - } else { special_idents::invalid } + m = infer(self.get_id()); + special_idents::invalid }; - match m { - expl(_) => { - if i == special_idents::invalid { - self.obsolete(copy self.span, ObsoleteModeInFnType); - } - } - _ => {} - } - let t = self.parse_ty(false); {mode: m, ty: t, ident: i, id: self.get_id()} -- cgit 1.4.1-3-g733a5 From 135ebca8aa1bb546984c1915eac4e5c9bfdcf4d6 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Tue, 25 Sep 2012 13:16:43 -0400 Subject: Refactoring ReaderUtil trait, combining it with the traitless impl on Reader. --- src/libcore/io.rs | 17 +++++++++++++---- src/libstd/json.rs | 2 +- src/libstd/time.rs | 2 +- src/libsyntax/parse/comments.rs | 1 + src/rustc/driver/rustc.rs | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 021aa624e06..97039800fb6 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -48,6 +48,17 @@ trait Reader { trait ReaderUtil { fn read_bytes(len: uint) -> ~[u8]; fn read_line() -> ~str; + + fn read_chars(n: uint) -> ~[char]; + fn read_char() -> char; + fn read_c_str() -> ~str; + fn read_le_uint(size: uint) -> uint; + fn read_le_int(size: uint) -> int; + fn read_be_uint(size: uint) -> uint; + fn read_whole_stream() -> ~[u8]; + fn each_byte(it: fn(int) -> bool); + fn each_char(it: fn(char) -> bool); + fn each_line(it: fn((&str)) -> bool); } impl T : ReaderUtil { @@ -69,12 +80,10 @@ impl T : ReaderUtil { } str::from_bytes(buf) } -} -impl Reader { fn read_chars(n: uint) -> ~[char] { // returns the (consumed offset, n_req), appends characters to &chars - fn chars_from_bytes(buf: &~[u8], chars: &mut ~[char]) + fn chars_from_bytes(buf: &~[u8], chars: &mut ~[char]) -> (uint, uint) { let mut i = 0; let buf_len = buf.len(); @@ -120,7 +129,7 @@ impl Reader { break; } vec::push_all(buf, data); - let (offset, nbreq) = chars_from_bytes(&buf, &mut chars); + let (offset, nbreq) = chars_from_bytes::(&buf, &mut chars); let ncreq = n - chars.len(); // again we either know we need a certain number of bytes // to complete a character, or we make sure we don't diff --git a/src/libstd/json.rs b/src/libstd/json.rs index db22b9ff30b..00e09f6604d 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -8,7 +8,7 @@ use core::cmp::{Eq, Ord}; use result::{Result, Ok, Err}; -use io::WriterUtil; +use io::{WriterUtil, ReaderUtil}; use map::HashMap; use map::Map; use sort::Sort; diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 64f65d15a93..890a7a0b468 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -3,7 +3,7 @@ use core::cmp::Eq; use libc::{c_char, c_int, c_long, size_t, time_t}; -use io::Reader; +use io::{Reader, ReaderUtil}; use result::{Result, Ok, Err}; export diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 9c705cff7bb..ddc70a1f13e 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -1,4 +1,5 @@ use io::println;//XXXXXXXXxxx +use io::ReaderUtil; use util::interner; use lexer::{string_reader, bump, is_eof, nextch, is_whitespace, get_str_from, reader}; diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 0306d0dbb18..6ea5bb28023 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -12,6 +12,7 @@ use core::*; // -*- rust -*- use result::{Ok, Err}; +use io::ReaderUtil; use std::getopts; use std::map::HashMap; use getopts::{opt_present}; -- cgit 1.4.1-3-g733a5 From b96af7315951dcc69567c2f3432a46ff71ecddf3 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 19 Sep 2012 18:50:24 -0700 Subject: turn ast::ident into a struct This will help with the auto_serialize2 migration. We have to change ident from a type alias to uint into a unique type. We need to use a struct instead of a "enum ident = token::str_num" because structs support constants, but newtypes do not. --- src/fuzzer/fuzzer.rs | 2 +- src/libsyntax/ast.rs | 15 ++++- src/libsyntax/ast_map.rs | 8 +-- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/ext/tt/transcribe.rs | 4 +- src/libsyntax/parse.rs | 2 +- src/libsyntax/parse/lexer.rs | 12 ++-- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/parse/token.rs | 118 ++++++++++++++++++++---------------- src/libsyntax/print/pprust.rs | 34 +++++------ src/rustc/back/link.rs | 2 +- src/rustc/driver/session.rs | 2 +- src/rustc/metadata/creader.rs | 4 +- src/rustc/metadata/cstore.rs | 4 +- src/rustc/metadata/decoder.rs | 42 ++++++------- src/rustc/metadata/loader.rs | 6 +- src/rustc/middle/resolve.rs | 6 +- src/rustc/middle/trans/common.rs | 9 +-- src/rustc/middle/trans/debuginfo.rs | 2 +- src/rustdoc/extract.rs | 2 +- 20 files changed, 154 insertions(+), 124 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 65adbb9e09e..9f1cc419d15 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -243,7 +243,7 @@ fn check_variants_T( filename: &Path, thing_label: ~str, things: ~[T], - stringifier: fn@(@T, syntax::parse::token::ident_interner) -> ~str, + stringifier: fn@(@T, @syntax::parse::token::ident_interner) -> ~str, replacer: fn@(ast::crate, uint, T, test_mode) -> ast::crate, cx: context ) { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 75a2081bc14..24dc3660faf 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -38,6 +38,10 @@ macro_rules! interner_key ( (-3 as uint, 0u))) ) +// FIXME(#3534): Replace with the struct-based newtype when it's been +// implemented. +struct ident { repr: uint } + fn serialize_ident(s: S, i: ident) { let intr = match unsafe{ task::local_data::local_data_get(interner_key!()) @@ -59,7 +63,16 @@ fn deserialize_ident(d: D) -> ident { (*intr).intern(@d.read_str()) } -type ident = token::str_num; +impl ident: cmp::Eq { + pure fn eq(other: &ident) -> bool { self.repr == other.repr } + pure fn ne(other: &ident) -> bool { !self.eq(other) } +} + +impl ident: to_bytes::IterBytes { + pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + self.repr.iter_bytes(lsb0, f) + } +} // Functions may or may not have names. #[auto_serialize] diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 9a3e94b737f..09922ade073 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -34,7 +34,7 @@ impl path_elt : cmp::Eq { type path = ~[path_elt]; /* FIXMEs that say "bad" are as per #2543 */ -fn path_to_str_with_sep(p: path, sep: ~str, itr: ident_interner) -> ~str { +fn path_to_str_with_sep(p: path, sep: ~str, itr: @ident_interner) -> ~str { let strs = do vec::map(p) |e| { match *e { path_mod(s) => *itr.get(s), @@ -44,7 +44,7 @@ fn path_to_str_with_sep(p: path, sep: ~str, itr: ident_interner) -> ~str { str::connect(strs, sep) } -fn path_ident_to_str(p: path, i: ident, itr: ident_interner) -> ~str { +fn path_ident_to_str(p: path, i: ident, itr: @ident_interner) -> ~str { if vec::is_empty(p) { //FIXME /* FIXME (#2543) */ copy *i *itr.get(i) @@ -53,7 +53,7 @@ fn path_ident_to_str(p: path, i: ident, itr: ident_interner) -> ~str { } } -fn path_to_str(p: path, itr: ident_interner) -> ~str { +fn path_to_str(p: path, itr: @ident_interner) -> ~str { path_to_str_with_sep(p, ~"::", itr) } @@ -326,7 +326,7 @@ fn map_stmt(stmt: @stmt, cx: ctx, v: vt) { visit::visit_stmt(stmt, cx, v); } -fn node_id_to_str(map: map, id: node_id, itr: ident_interner) -> ~str { +fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str { match map.find(id) { None => { fmt!("unknown node (id=%d)", id) diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index b0df0ea1c8d..98a471bd54c 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -23,7 +23,7 @@ pure fn dummy_sp() -> span { return mk_sp(0u, 0u); } -pure fn path_name_i(idents: ~[ident], intr: token::ident_interner) -> ~str { +pure fn path_name_i(idents: ~[ident], intr: @token::ident_interner) -> ~str { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") str::connect(idents.map(|i| *intr.get(*i)), ~"::") } diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index c42811762e4..b208e4f8c6f 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -25,7 +25,7 @@ type tt_frame = @{ type tt_reader = @{ sp_diag: span_handler, - interner: ident_interner, + interner: @ident_interner, mut cur: tt_frame, /* for MBE-style macro transcription */ interpolations: std::map::HashMap, @@ -39,7 +39,7 @@ type tt_reader = @{ /** This can do Macro-By-Example transcription. On the other hand, if * `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and * should) be none. */ -fn new_tt_reader(sp_diag: span_handler, itr: ident_interner, +fn new_tt_reader(sp_diag: span_handler, itr: @ident_interner, interp: Option>, src: ~[ast::token_tree]) -> tt_reader { diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 312c78085ac..751b3ce62b9 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -25,7 +25,7 @@ type parse_sess = @{ cm: codemap::codemap, mut next_id: node_id, span_diagnostic: span_handler, - interner: ident_interner, + interner: @ident_interner, // these two must be kept up to date mut chpos: uint, mut byte_pos: uint diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index c9b10c7b754..06fcc1cf958 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -13,7 +13,7 @@ trait reader { fn next_token() -> {tok: token::token, sp: span}; fn fatal(~str) -> !; fn span_diag() -> span_handler; - pure fn interner() -> token::ident_interner; + pure fn interner() -> @token::ident_interner; fn peek() -> {tok: token::token, sp: span}; fn dup() -> reader; } @@ -26,7 +26,7 @@ type string_reader = @{ mut curr: char, mut chpos: uint, filemap: codemap::filemap, - interner: token::ident_interner, + interner: @token::ident_interner, /* cached: */ mut peek_tok: token::token, mut peek_span: span @@ -34,7 +34,7 @@ type string_reader = @{ fn new_string_reader(span_diagnostic: span_handler, filemap: codemap::filemap, - itr: token::ident_interner) -> string_reader { + itr: @token::ident_interner) -> string_reader { let r = new_low_level_string_reader(span_diagnostic, filemap, itr); string_advance_token(r); /* fill in peek_* */ return r; @@ -43,7 +43,7 @@ fn new_string_reader(span_diagnostic: span_handler, /* For comments.rs, which hackily pokes into 'pos' and 'curr' */ fn new_low_level_string_reader(span_diagnostic: span_handler, filemap: codemap::filemap, - itr: token::ident_interner) + itr: @token::ident_interner) -> string_reader { let r = @{span_diagnostic: span_diagnostic, src: filemap.src, mut col: 0u, mut pos: 0u, mut curr: -1 as char, @@ -78,7 +78,7 @@ impl string_reader: reader { self.span_diagnostic.span_fatal(copy self.peek_span, m) } fn span_diag() -> span_handler { self.span_diagnostic } - pure fn interner() -> token::ident_interner { self.interner } + pure fn interner() -> @token::ident_interner { self.interner } fn peek() -> {tok: token::token, sp: span} { {tok: self.peek_tok, sp: self.peek_span} } @@ -100,7 +100,7 @@ impl tt_reader: reader { self.sp_diag.span_fatal(copy self.cur_span, m); } fn span_diag() -> span_handler { self.sp_diag } - pure fn interner() -> token::ident_interner { self.interner } + pure fn interner() -> @token::ident_interner { self.interner } fn peek() -> {tok: token::token, sp: span} { { tok: self.cur_tok, sp: self.cur_span } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bc232f1259e..9d970e23f68 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -237,7 +237,7 @@ struct parser { mut restriction: restriction, mut quote_depth: uint, // not (yet) related to the quasiquoter reader: reader, - interner: interner<@~str>, + interner: @token::ident_interner, keywords: HashMap<~str, ()>, strict_keywords: HashMap<~str, ()>, reserved_keywords: HashMap<~str, ()>, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 0f9041a2fcd..a328ff1bdf6 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -12,9 +12,6 @@ use std::serialization::{Serializer, serialize_bool, deserialize_bool}; -#[auto_serialize] -type str_num = uint; - #[auto_serialize] enum binop { PLUS, @@ -72,17 +69,17 @@ enum token { LIT_INT(i64, ast::int_ty), LIT_UINT(u64, ast::uint_ty), LIT_INT_UNSUFFIXED(i64), - LIT_FLOAT(str_num, ast::float_ty), - LIT_STR(str_num), + LIT_FLOAT(ast::ident, ast::float_ty), + LIT_STR(ast::ident), /* Name components */ - IDENT(str_num, bool), + IDENT(ast::ident, bool), UNDERSCORE, /* For interpolation */ INTERPOLATED(nonterminal), - DOC_COMMENT(str_num), + DOC_COMMENT(ast::ident), EOF, } @@ -95,7 +92,7 @@ enum nonterminal { nt_pat( @ast::pat), nt_expr(@ast::expr), nt_ty( @ast::ty), - nt_ident(str_num, bool), + nt_ident(ast::ident, bool), nt_path(@ast::path), nt_tt( @ast::token_tree), //needs @ed to break a circularity nt_matchers(~[ast::matcher]) @@ -116,7 +113,7 @@ fn binop_to_str(o: binop) -> ~str { } } -fn to_str(in: interner<@~str>, t: token) -> ~str { +fn to_str(in: @ident_interner, t: token) -> ~str { match t { EQ => ~"=", LT => ~"<", @@ -174,7 +171,7 @@ fn to_str(in: interner<@~str>, t: token) -> ~str { } body + ast_util::float_ty_to_str(t) } - LIT_STR(s) => { ~"\"" + str::escape_default( *in.get(s)) + ~"\"" } + LIT_STR(s) => { ~"\"" + str::escape_default(*in.get(s)) + ~"\"" } /* Name components */ IDENT(s, _) => *in.get(s), @@ -281,49 +278,66 @@ pure fn is_bar(t: token) -> bool { mod special_idents { #[legacy_exports]; use ast::ident; - const underscore : ident = 0u; - const anon : ident = 1u; - const dtor : ident = 2u; // 'drop', but that's reserved - const invalid : ident = 3u; // '' - const unary : ident = 4u; - const not_fn : ident = 5u; - const idx_fn : ident = 6u; - const unary_minus_fn : ident = 7u; - const clownshoes_extensions : ident = 8u; - - const self_ : ident = 9u; // 'self' + const underscore : ident = ident { repr: 0u }; + const anon : ident = ident { repr: 1u }; + const dtor : ident = ident { repr: 2u }; // 'drop', but that's reserved + const invalid : ident = ident { repr: 3u }; // '' + const unary : ident = ident { repr: 4u }; + const not_fn : ident = ident { repr: 5u }; + const idx_fn : ident = ident { repr: 6u }; + const unary_minus_fn : ident = ident { repr: 7u }; + const clownshoes_extensions : ident = ident { repr: 8u }; + + const self_ : ident = ident { repr: 9u }; // 'self' /* for matcher NTs */ - const item : ident = 10u; - const block : ident = 11u; - const stmt : ident = 12u; - const pat : ident = 13u; - const expr : ident = 14u; - const ty : ident = 15u; - const ident : ident = 16u; - const path : ident = 17u; - const tt : ident = 18u; - const matchers : ident = 19u; - - const str : ident = 20u; // for the type + const item : ident = ident { repr: 10u }; + const block : ident = ident { repr: 11u }; + const stmt : ident = ident { repr: 12u }; + const pat : ident = ident { repr: 13u }; + const expr : ident = ident { repr: 14u }; + const ty : ident = ident { repr: 15u }; + const ident : ident = ident { repr: 16u }; + const path : ident = ident { repr: 17u }; + const tt : ident = ident { repr: 18u }; + const matchers : ident = ident { repr: 19u }; + + const str : ident = ident { repr: 20u }; // for the type /* outside of libsyntax */ - const ty_visitor : ident = 21u; - const arg : ident = 22u; - const descrim : ident = 23u; - const clownshoe_abi : ident = 24u; - const clownshoe_stack_shim : ident = 25u; - const tydesc : ident = 26u; - const literally_dtor : ident = 27u; - const main : ident = 28u; - const opaque : ident = 29u; - const blk : ident = 30u; - const static : ident = 31u; - const intrinsic : ident = 32u; - const clownshoes_foreign_mod: ident = 33; + const ty_visitor : ident = ident { repr: 21u }; + const arg : ident = ident { repr: 22u }; + const descrim : ident = ident { repr: 23u }; + const clownshoe_abi : ident = ident { repr: 24u }; + const clownshoe_stack_shim : ident = ident { repr: 25u }; + const tydesc : ident = ident { repr: 26u }; + const literally_dtor : ident = ident { repr: 27u }; + const main : ident = ident { repr: 28u }; + const opaque : ident = ident { repr: 29u }; + const blk : ident = ident { repr: 30u }; + const static : ident = ident { repr: 31u }; + const intrinsic : ident = ident { repr: 32u }; + const clownshoes_foreign_mod: ident = ident { repr: 33 }; } -type ident_interner = util::interner::interner<@~str>; +struct ident_interner { + priv interner: util::interner::interner<@~str>, +} + +impl ident_interner { + fn intern(val: @~str) -> ast::ident { + ast::ident { repr: self.interner.intern(val) } + } + fn gensym(val: @~str) -> ast::ident { + ast::ident { repr: self.interner.gensym(val) } + } + pure fn get(idx: ast::ident) -> @~str { + self.interner.get(idx.repr) + } + fn len() -> uint { + self.interner.len() + } +} /** Key for thread-local data for sneaking interner information to the * serializer/deserializer. It sounds like a hack because it is one. @@ -335,7 +349,7 @@ macro_rules! interner_key ( (-3 as uint, 0u))) ) -fn mk_ident_interner() -> ident_interner { +fn mk_ident_interner() -> @ident_interner { /* the indices here must correspond to the numbers in special_idents */ let init_vec = ~[@~"_", @~"anon", @~"drop", @~"", @~"unary", @~"!", @~"[]", @~"unary-", @~"__extensions__", @~"self", @@ -346,7 +360,9 @@ fn mk_ident_interner() -> ident_interner { @~"dtor", @~"main", @~"", @~"blk", @~"static", @~"intrinsic", @~"__foreign_mod__"]; - let rv = interner::mk_prefill::<@~str>(init_vec); + let rv = @ident_interner { + interner: interner::mk_prefill::<@~str>(init_vec) + }; /* having multiple interners will just confuse the serializer */ unsafe { @@ -360,8 +376,8 @@ fn mk_ident_interner() -> ident_interner { /* for when we don't care about the contents; doesn't interact with TLD or serialization */ -fn mk_fake_ident_interner() -> ident_interner { - interner::mk::<@~str>() +fn mk_fake_ident_interner() -> @ident_interner { + @ident_interner { interner: interner::mk::<@~str>() } } /** diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 3630ba8c5c6..00652346e10 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -25,7 +25,7 @@ fn no_ann() -> pp_ann { type ps = @{s: pp::printer, cm: Option, - intr: token::ident_interner, + intr: @token::ident_interner, comments: Option<~[comments::cmnt]>, literals: Option<~[comments::lit]>, mut cur_cmnt: uint, @@ -43,7 +43,7 @@ fn end(s: ps) { pp::end(s.s); } -fn rust_printer(writer: io::Writer, intr: ident_interner) -> ps { +fn rust_printer(writer: io::Writer, intr: @ident_interner) -> ps { return @{s: pp::mk_printer(writer, default_columns), cm: None::, intr: intr, @@ -63,7 +63,7 @@ const default_columns: uint = 78u; // Requires you to pass an input filename and reader so that // it can scan the input text for comments and literals to // copy forward. -fn print_crate(cm: codemap, intr: ident_interner, +fn print_crate(cm: codemap, intr: @ident_interner, span_diagnostic: diagnostic::span_handler, crate: @ast::crate, filename: ~str, in: io::Reader, out: io::Writer, ann: pp_ann, is_expanded: bool) { @@ -91,40 +91,40 @@ fn print_crate_(s: ps, &&crate: @ast::crate) { eof(s.s); } -fn ty_to_str(ty: @ast::ty, intr: ident_interner) -> ~str { +fn ty_to_str(ty: @ast::ty, intr: @ident_interner) -> ~str { to_str(ty, print_type, intr) } -fn pat_to_str(pat: @ast::pat, intr: ident_interner) -> ~str { +fn pat_to_str(pat: @ast::pat, intr: @ident_interner) -> ~str { to_str(pat, print_pat, intr) } -fn expr_to_str(e: @ast::expr, intr: ident_interner) -> ~str { +fn expr_to_str(e: @ast::expr, intr: @ident_interner) -> ~str { to_str(e, print_expr, intr) } -fn tt_to_str(tt: ast::token_tree, intr: ident_interner) -> ~str { +fn tt_to_str(tt: ast::token_tree, intr: @ident_interner) -> ~str { to_str(tt, print_tt, intr) } -fn stmt_to_str(s: ast::stmt, intr: ident_interner) -> ~str { +fn stmt_to_str(s: ast::stmt, intr: @ident_interner) -> ~str { to_str(s, print_stmt, intr) } -fn item_to_str(i: @ast::item, intr: ident_interner) -> ~str { +fn item_to_str(i: @ast::item, intr: @ident_interner) -> ~str { to_str(i, print_item, intr) } -fn typarams_to_str(tps: ~[ast::ty_param], intr: ident_interner) -> ~str { +fn typarams_to_str(tps: ~[ast::ty_param], intr: @ident_interner) -> ~str { to_str(tps, print_type_params, intr) } -fn path_to_str(&&p: @ast::path, intr: ident_interner) -> ~str { +fn path_to_str(&&p: @ast::path, intr: @ident_interner) -> ~str { to_str(p, |a,b| print_path(a, b, false), intr) } fn fun_to_str(decl: ast::fn_decl, name: ast::ident, - params: ~[ast::ty_param], intr: ident_interner) -> ~str { + params: ~[ast::ty_param], intr: @ident_interner) -> ~str { do io::with_str_writer |wr| { let s = rust_printer(wr, intr); print_fn(s, decl, None, name, params, None, ast::inherited); @@ -147,7 +147,7 @@ fn test_fun_to_str() { assert fun_to_str(decl, "a", ~[]) == "fn a()"; } -fn block_to_str(blk: ast::blk, intr: ident_interner) -> ~str { +fn block_to_str(blk: ast::blk, intr: @ident_interner) -> ~str { do io::with_str_writer |wr| { let s = rust_printer(wr, intr); // containing cbox, will be closed by print-block at } @@ -159,15 +159,15 @@ fn block_to_str(blk: ast::blk, intr: ident_interner) -> ~str { } } -fn meta_item_to_str(mi: @ast::meta_item, intr: ident_interner) -> ~str { +fn meta_item_to_str(mi: @ast::meta_item, intr: @ident_interner) -> ~str { to_str(mi, print_meta_item, intr) } -fn attribute_to_str(attr: ast::attribute, intr: ident_interner) -> ~str { +fn attribute_to_str(attr: ast::attribute, intr: @ident_interner) -> ~str { to_str(attr, print_attribute, intr) } -fn variant_to_str(var: ast::variant, intr: ident_interner) -> ~str { +fn variant_to_str(var: ast::variant, intr: @ident_interner) -> ~str { to_str(var, print_variant, intr) } @@ -2059,7 +2059,7 @@ fn print_string(s: ps, st: ~str) { word(s.s, ~"\""); } -fn to_str(t: T, f: fn@(ps, T), intr: ident_interner) -> ~str { +fn to_str(t: T, f: fn@(ps, T), intr: @ident_interner) -> ~str { do io::with_str_writer |wr| { let s = rust_printer(wr, intr); f(s, t); diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index fb3d749673c..c8f5871333f 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -607,7 +607,7 @@ fn mangle_internal_name_by_path(ccx: @crate_ctxt, path: path) -> ~str { } fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: ~str) -> ~str { - return fmt!("%s_%u", flav, ccx.names(flav)); + return fmt!("%s_%u", flav, ccx.names(flav).repr); } // If the user wants an exe generated we need to invoke diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 335e1004078..c6c0ff2826a 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -243,7 +243,7 @@ impl session { fn ident_of(st: ~str) -> ast::ident { self.parse_sess.interner.intern(@st) } - fn intr() -> syntax::parse::token::ident_interner { + fn intr() -> @syntax::parse::token::ident_interner { self.parse_sess.interner } } diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 0cd0b64a061..0d19fe796e1 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -18,7 +18,7 @@ export read_crates; // libraries necessary for later resolving, typechecking, linking, etc. fn read_crates(diag: span_handler, crate: ast::crate, cstore: cstore::cstore, filesearch: filesearch, - os: loader::os, static: bool, intr: ident_interner) { + os: loader::os, static: bool, intr: @ident_interner) { let e = @{diag: diag, filesearch: filesearch, cstore: cstore, @@ -94,7 +94,7 @@ type env = @{diag: span_handler, static: bool, crate_cache: DVec, mut next_crate_num: ast::crate_num, - intr: ident_interner}; + intr: @ident_interner}; fn visit_view_item(e: env, i: @ast::view_item) { match i.node { diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index 7151702f25e..8a982eaf497 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -58,7 +58,7 @@ type cstore_private = mut used_crate_files: ~[Path], mut used_libraries: ~[~str], mut used_link_args: ~[~str], - intr: ident_interner}; + intr: @ident_interner}; // Map from node_id's of local use statements to crate numbers type use_crate_map = map::HashMap; @@ -68,7 +68,7 @@ pure fn p(cstore: cstore) -> cstore_private { match cstore { private(p) => p } } -fn mk_cstore(intr: ident_interner) -> cstore { +fn mk_cstore(intr: @ident_interner) -> cstore { let meta_cache = map::HashMap(); let crate_map = map::HashMap(); let mod_path_map = HashMap(); diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 928bba5205a..4a72867eb85 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -268,7 +268,7 @@ fn enum_variant_ids(item: ebml::Doc, cdata: cmd) -> ~[ast::def_id] { return ids; } -fn item_path(intr: ident_interner, item_doc: ebml::Doc) -> ast_map::path { +fn item_path(intr: @ident_interner, item_doc: ebml::Doc) -> ast_map::path { let path_doc = ebml::get_doc(item_doc, tag_path); let len_doc = ebml::get_doc(path_doc, tag_path_len); @@ -290,7 +290,7 @@ fn item_path(intr: ident_interner, item_doc: ebml::Doc) -> ast_map::path { return result; } -fn item_name(intr: ident_interner, item: ebml::Doc) -> ast::ident { +fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::ident { let name = ebml::get_doc(item, tag_paths_data_name); intr.intern(@str::from_bytes(ebml::doc_data(name))) } @@ -365,7 +365,7 @@ fn get_impl_traits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> ~[ty::t] { item_impl_traits(lookup_item(id, cdata.data), tcx, cdata) } -fn get_impl_method(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id, name: ast::ident) -> ast::def_id { let items = ebml::get_doc(ebml::Doc(cdata.data), tag_items); let mut found = None; @@ -378,7 +378,7 @@ fn get_impl_method(intr: ident_interner, cdata: cmd, id: ast::node_id, found.get() } -fn get_class_method(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_class_method(intr: @ident_interner, cdata: cmd, id: ast::node_id, name: ast::ident) -> ast::def_id { let items = ebml::get_doc(ebml::Doc(cdata.data), tag_items); let mut found = None; @@ -451,7 +451,7 @@ fn path_entry(path_string: ~str, def_like: def_like) -> path_entry { } /// Iterates over all the paths in the given crate. -fn each_path(intr: ident_interner, cdata: cmd, f: fn(path_entry) -> bool) { +fn each_path(intr: @ident_interner, cdata: cmd, f: fn(path_entry) -> bool) { let root = ebml::Doc(cdata.data); let items = ebml::get_doc(root, tag_items); let items_data = ebml::get_doc(items, tag_items_data); @@ -531,7 +531,7 @@ fn each_path(intr: ident_interner, cdata: cmd, f: fn(path_entry) -> bool) { } } -fn get_item_path(intr: ident_interner, cdata: cmd, id: ast::node_id) +fn get_item_path(intr: @ident_interner, cdata: cmd, id: ast::node_id) -> ast_map::path { item_path(intr, lookup_item(id, cdata.data)) } @@ -542,7 +542,7 @@ type decode_inlined_item = fn( path: ast_map::path, par_doc: ebml::Doc) -> Option; -fn maybe_get_item_ast(intr: ident_interner, cdata: cmd, tcx: ty::ctxt, +fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt, id: ast::node_id, decode_inlined_item: decode_inlined_item ) -> csearch::found_ast { @@ -568,7 +568,7 @@ fn maybe_get_item_ast(intr: ident_interner, cdata: cmd, tcx: ty::ctxt, } } -fn get_enum_variants(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> ~[ty::variant_info] { let data = cdata.data; let items = ebml::get_doc(ebml::Doc(data), tag_items); @@ -638,7 +638,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { } } -fn item_impl_methods(intr: ident_interner, cdata: cmd, item: ebml::Doc, +fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc, base_tps: uint) -> ~[@method_info] { let mut rslt = ~[]; for ebml::tagged_docs(item, tag_item_impl_method) |doc| { @@ -654,7 +654,7 @@ fn item_impl_methods(intr: ident_interner, cdata: cmd, item: ebml::Doc, rslt } -fn get_impls_for_mod(intr: ident_interner, cdata: cmd, +fn get_impls_for_mod(intr: @ident_interner, cdata: cmd, m_id: ast::node_id, name: Option, get_cdata: fn(ast::crate_num) -> cmd) -> @~[@_impl] { @@ -685,7 +685,7 @@ fn get_impls_for_mod(intr: ident_interner, cdata: cmd, } /* Works for both classes and traits */ -fn get_trait_methods(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_trait_methods(intr: @ident_interner, cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> @~[ty::method] { let data = cdata.data; let item = lookup_item(id, data); @@ -712,7 +712,7 @@ fn get_trait_methods(intr: ident_interner, cdata: cmd, id: ast::node_id, // If the item in question is a trait, returns its set of methods and // their self types. Otherwise, returns none. This overlaps in an // annoying way with get_trait_methods. -fn get_method_names_if_trait(intr: ident_interner, cdata: cmd, +fn get_method_names_if_trait(intr: @ident_interner, cdata: cmd, node_id: ast::node_id) -> Option<@DVec<(ast::ident, ast::self_ty_)>> { @@ -742,7 +742,7 @@ fn get_item_attrs(cdata: cmd, } // Helper function that gets either fields or methods -fn get_class_members(intr: ident_interner, cdata: cmd, id: ast::node_id, +fn get_class_members(intr: @ident_interner, cdata: cmd, id: ast::node_id, p: fn(Family) -> bool) -> ~[ty::field_ty] { let data = cdata.data; let item = lookup_item(id, data); @@ -769,7 +769,7 @@ pure fn family_to_visibility(family: Family) -> ast::visibility { } } -fn get_class_fields(intr: ident_interner, cdata: cmd, id: ast::node_id) +fn get_class_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id) -> ~[ty::field_ty] { get_class_members(intr, cdata, id, |f| f == PublicField || f == PrivateField || f == InheritedField) @@ -876,14 +876,14 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] { return attrs; } -fn list_meta_items(intr: ident_interner, +fn list_meta_items(intr: @ident_interner, meta_items: ebml::Doc, out: io::Writer) { for get_meta_items(meta_items).each |mi| { out.write_str(fmt!("%s\n", pprust::meta_item_to_str(*mi, intr))); } } -fn list_crate_attributes(intr: ident_interner, md: ebml::Doc, hash: ~str, +fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: ~str, out: io::Writer) { out.write_str(fmt!("=Crate Attributes (%s)=\n", hash)); @@ -901,7 +901,7 @@ fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] { type crate_dep = {cnum: ast::crate_num, name: ast::ident, vers: ~str, hash: ~str}; -fn get_crate_deps(intr: ident_interner, data: @~[u8]) -> ~[crate_dep] { +fn get_crate_deps(intr: @ident_interner, data: @~[u8]) -> ~[crate_dep] { let mut deps: ~[crate_dep] = ~[]; let cratedoc = ebml::Doc(data); let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps); @@ -919,7 +919,7 @@ fn get_crate_deps(intr: ident_interner, data: @~[u8]) -> ~[crate_dep] { return deps; } -fn list_crate_deps(intr: ident_interner, data: @~[u8], out: io::Writer) { +fn list_crate_deps(intr: @ident_interner, data: @~[u8], out: io::Writer) { out.write_str(~"=External Dependencies=\n"); for get_crate_deps(intr, data).each |dep| { @@ -946,7 +946,7 @@ fn get_crate_vers(data: @~[u8]) -> ~str { }; } -fn iter_crate_items(intr: ident_interner, +fn iter_crate_items(intr: @ident_interner, cdata: cmd, proc: fn(~str, ast::def_id)) { for each_path(intr, cdata) |path_entry| { match path_entry.def_like { @@ -958,7 +958,7 @@ fn iter_crate_items(intr: ident_interner, } } -fn get_crate_module_paths(intr: ident_interner, cdata: cmd) +fn get_crate_module_paths(intr: @ident_interner, cdata: cmd) -> ~[(ast::def_id, ~str)] { fn mod_of_path(p: ~str) -> ~str { str::connect(vec::init(str::split_str(p, ~"::")), ~"::") @@ -985,7 +985,7 @@ fn get_crate_module_paths(intr: ident_interner, cdata: cmd) } } -fn list_crate_metadata(intr: ident_interner, bytes: @~[u8], +fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8], out: io::Writer) { let hash = get_crate_hash(bytes); let md = ebml::Doc(bytes); diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index e11793a36d0..b2c28fafd4c 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -35,7 +35,7 @@ type ctxt = { hash: ~str, os: os, static: bool, - intr: ident_interner + intr: @ident_interner }; fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} { @@ -135,7 +135,7 @@ fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> ~str { } } -fn note_linkage_attrs(intr: ident_interner, diag: span_handler, +fn note_linkage_attrs(intr: @ident_interner, diag: span_handler, attrs: ~[ast::attribute]) { for attr::find_linkage_metas(attrs).each |mi| { diag.handler().note(fmt!("meta: %s", @@ -226,7 +226,7 @@ fn meta_section_name(os: os) -> ~str { } // A diagnostic function for dumping crate metadata to an output stream -fn list_file_metadata(intr: ident_interner, +fn list_file_metadata(intr: @ident_interner, os: os, path: &Path, out: io::Writer) { match get_metadata_section(os, path) { option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out), diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 07b5d3b4ce8..3e216c4eacc 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -652,14 +652,14 @@ struct PrimitiveTypeTable { } impl PrimitiveTypeTable { - fn intern(intr: ident_interner, string: @~str, + fn intern(intr: @ident_interner, string: @~str, primitive_type: prim_ty) { let atom = intr.intern(string); self.primitive_types.insert(atom, primitive_type); } } -fn PrimitiveTypeTable(intr: ident_interner) -> PrimitiveTypeTable { +fn PrimitiveTypeTable(intr: @ident_interner) -> PrimitiveTypeTable { let table = PrimitiveTypeTable { primitive_types: atom_hashmap() }; @@ -765,7 +765,7 @@ struct Resolver { lang_items: LanguageItems, crate: @crate, - intr: ident_interner, + intr: @ident_interner, graph_root: @NameBindings, diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index a1ca4287f0e..fc74e5e0e4d 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -25,9 +25,9 @@ use syntax::parse::token::ident_interner; use syntax::ast::ident; type namegen = fn@(~str) -> ident; -fn new_namegen(intr: ident_interner) -> namegen { +fn new_namegen(intr: @ident_interner) -> namegen { return fn@(prefix: ~str) -> ident { - return intr.gensym(@fmt!("%s_%u", prefix, intr.gensym(@prefix))) + return intr.gensym(@fmt!("%s_%u", prefix, intr.gensym(@prefix).repr)) }; } @@ -1024,7 +1024,7 @@ fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef { llvm::LLVMConstString(buf, str::len(s) as c_uint, False) }; let g = - str::as_c_str(fmt!("str%u", cx.names(~"str")), + str::as_c_str(fmt!("str%u", cx.names(~"str").repr), |buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf)); llvm::LLVMSetInitializer(g, sc); llvm::LLVMSetGlobalConstant(g, True); @@ -1086,7 +1086,8 @@ fn C_bytes_plus_null(bytes: ~[u8]) -> ValueRef unsafe { fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef { let llshape = C_bytes_plus_null(bytes); - let llglobal = str::as_c_str(fmt!("shape%u", ccx.names(~"shape")), |buf| { + let name = fmt!("shape%u", ccx.names(~"shape").repr); + let llglobal = str::as_c_str(name, |buf| { llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf) }); llvm::LLVMSetInitializer(llglobal, llshape); diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index 9944daefea4..26a83951c01 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -90,7 +90,7 @@ type debug_ctxt = { crate_file: ~str }; -fn mk_ctxt(crate: ~str, intr: ident_interner) -> debug_ctxt { +fn mk_ctxt(crate: ~str, intr: @ident_interner) -> debug_ctxt { {llmetadata: map::HashMap(), names: new_namegen(intr), crate_file: crate} diff --git a/src/rustdoc/extract.rs b/src/rustdoc/extract.rs index b8a13b712e5..448e699fc8d 100644 --- a/src/rustdoc/extract.rs +++ b/src/rustdoc/extract.rs @@ -21,7 +21,7 @@ fn to_str(id: ast::ident) -> ~str { return *(*intr.get()).get(id); } -fn interner() -> syntax::parse::token::ident_interner { +fn interner() -> @syntax::parse::token::ident_interner { return *(unsafe{ local_data_get(interner_key!()) }).get(); } -- cgit 1.4.1-3-g733a5 From 67a8e7128aea292445b763b47b04bc5f4fd43cb2 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 26 Sep 2012 17:33:34 -0700 Subject: Demode vec::push (and convert to method) --- doc/rust.md | 2 +- doc/tutorial.md | 2 +- src/cargo/cargo.rs | 4 +- src/compiletest/compiletest.rs | 2 +- src/compiletest/header.rs | 6 +- src/compiletest/procsrv.rs | 2 +- src/compiletest/runtest.rs | 2 +- src/fuzzer/cycles.rs | 4 +- src/fuzzer/fuzzer.rs | 4 +- src/fuzzer/ivec_fuzz.rs | 8 +- src/fuzzer/rand_util.rs | 2 +- src/libcore/core.rs | 2 + src/libcore/dvec.rs | 8 +- src/libcore/either.rs | 28 +-- src/libcore/extfmt.rs | 4 +- src/libcore/flate.rs | 4 +- src/libcore/float.rs | 2 +- src/libcore/io.rs | 18 +- src/libcore/os.rs | 2 +- src/libcore/path.rs | 10 +- src/libcore/pipes.rs | 2 +- src/libcore/private.rs | 2 +- src/libcore/rand.rs | 2 +- src/libcore/result.rs | 4 +- src/libcore/run.rs | 12 +- src/libcore/send_map.rs | 15 +- src/libcore/str.rs | 23 ++- src/libcore/vec.rs | 189 ++++++++++++--------- src/libstd/arc.rs | 4 +- src/libstd/base64.rs | 12 +- src/libstd/deque.rs | 4 +- src/libstd/ebml.rs | 2 +- src/libstd/ebml2.rs | 2 +- src/libstd/getopts.rs | 21 ++- src/libstd/json.rs | 29 ++-- src/libstd/md4.rs | 4 +- src/libstd/net_ip.rs | 2 +- src/libstd/net_tcp.rs | 4 +- src/libstd/net_url.rs | 2 +- src/libstd/par.rs | 2 +- src/libstd/rope.rs | 2 +- src/libstd/sort.rs | 4 +- src/libstd/sync.rs | 8 +- src/libstd/test.rs | 4 +- src/libsyntax/ast_map.rs | 4 +- src/libsyntax/ast_util.rs | 4 +- src/libsyntax/attr.rs | 2 +- src/libsyntax/codemap.rs | 4 +- src/libsyntax/ext/auto_serialize2.rs | 2 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/ext/fmt.rs | 4 +- src/libsyntax/ext/pipes/liveness.rs | 2 +- src/libsyntax/ext/pipes/pipec.rs | 86 +++++----- src/libsyntax/ext/simplext.rs | 13 +- src/libsyntax/ext/tt/macro_parser.rs | 24 +-- src/libsyntax/ext/tt/transcribe.rs | 4 +- src/libsyntax/fold.rs | 10 +- src/libsyntax/parse/comments.rs | 14 +- src/libsyntax/parse/common.rs | 4 +- src/libsyntax/parse/eval.rs | 6 +- src/libsyntax/parse/parser.rs | 136 +++++++-------- src/rustc/back/link.rs | 42 ++--- src/rustc/back/rpath.rs | 10 +- src/rustc/back/upcall.rs | 2 +- src/rustc/driver/driver.rs | 4 +- src/rustc/front/test.rs | 4 +- src/rustc/metadata/cstore.rs | 8 +- src/rustc/metadata/decoder.rs | 40 ++--- src/rustc/metadata/encoder.rs | 55 +++--- src/rustc/metadata/filesearch.rs | 10 +- src/rustc/metadata/loader.rs | 2 +- src/rustc/metadata/tydecode.rs | 16 +- src/rustc/middle/capture.rs | 2 +- src/rustc/middle/check_alt.rs | 4 +- src/rustc/middle/freevars.rs | 2 +- src/rustc/middle/kind.rs | 8 +- src/rustc/middle/lint.rs | 2 +- src/rustc/middle/liveness.rs | 6 +- src/rustc/middle/pat_util.rs | 2 +- src/rustc/middle/region.rs | 2 +- src/rustc/middle/resolve.rs | 6 +- src/rustc/middle/trans/alt.rs | 12 +- src/rustc/middle/trans/base.rs | 16 +- src/rustc/middle/trans/build.rs | 2 +- src/rustc/middle/trans/callee.rs | 10 +- src/rustc/middle/trans/closure.rs | 20 +-- src/rustc/middle/trans/common.rs | 24 +-- src/rustc/middle/trans/debuginfo.rs | 4 +- src/rustc/middle/trans/expr.rs | 4 +- src/rustc/middle/trans/foreign.rs | 22 +-- src/rustc/middle/trans/monomorphize.rs | 2 +- src/rustc/middle/trans/tvec.rs | 4 +- src/rustc/middle/trans/type_of.rs | 10 +- src/rustc/middle/ty.rs | 46 ++--- src/rustc/middle/typeck/check.rs | 11 +- src/rustc/middle/typeck/check/regionmanip.rs | 4 +- src/rustc/middle/typeck/check/vtable.rs | 10 +- src/rustc/middle/typeck/check/writeback.rs | 2 +- src/rustc/middle/typeck/coherence.rs | 9 +- .../middle/typeck/infer/region_var_bindings.rs | 8 +- src/rustc/middle/typeck/infer/resolve.rs | 2 +- src/rustc/middle/typeck/infer/unify.rs | 2 +- src/rustc/util/common.rs | 2 +- src/rustc/util/ppaux.rs | 6 +- src/rustdoc/extract.rs | 2 +- src/rustdoc/path_pass.rs | 4 +- src/test/bench/core-std.rs | 6 +- src/test/bench/core-vec-append.rs | 2 +- src/test/bench/graph500-bfs.rs | 2 +- src/test/bench/msgsend-pipes-shared.rs | 2 +- src/test/bench/msgsend-pipes.rs | 2 +- src/test/bench/msgsend-ring-mutex-arcs.rs | 4 +- src/test/bench/msgsend-ring-pipes.rs | 2 +- src/test/bench/msgsend-ring-rw-arcs.rs | 4 +- src/test/bench/msgsend-ring.rs | 2 +- src/test/bench/msgsend.rs | 2 +- src/test/bench/shootout-chameneos-redux.rs | 2 +- src/test/bench/shootout-k-nucleotide-pipes.rs | 4 +- src/test/bench/shootout-k-nucleotide.rs | 2 +- src/test/bench/shootout-mandelbrot.rs | 2 +- src/test/bench/shootout-pfib.rs | 2 +- src/test/bench/task-perf-one-million.rs | 2 +- src/test/bench/task-perf-word-count-generic.rs | 7 +- src/test/compile-fail/purity-infer-fail.rs | 2 +- src/test/run-fail/zip-different-lengths.rs | 4 +- src/test/run-pass/auto-ref-sliceable.rs | 2 +- src/test/run-pass/autoref-vec-push.rs | 17 -- src/test/run-pass/borrowck-mut-uniq.rs | 2 +- src/test/run-pass/issue-2904.rs | 7 +- src/test/run-pass/task-comm-3.rs | 2 +- src/test/run-pass/task-comm.rs | 4 +- src/test/run-pass/vec-push.rs | 2 +- src/test/run-pass/zip-same-length.rs | 4 +- 134 files changed, 684 insertions(+), 670 deletions(-) delete mode 100644 src/test/run-pass/autoref-vec-push.rs (limited to 'src/libsyntax/parse') diff --git a/doc/rust.md b/doc/rust.md index ccc5a532cdd..6f6a7bb86b6 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -1016,7 +1016,7 @@ fn iter(seq: ~[T], f: fn(T)) { } fn map(seq: ~[T], f: fn(T) -> U) -> ~[U] { let mut acc = ~[]; - for seq.each |elt| { vec::push(acc, f(elt)); } + for seq.each |elt| { acc.push(f(elt)); } acc } ~~~~ diff --git a/doc/tutorial.md b/doc/tutorial.md index 7244206b2eb..4b76152cdb0 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1651,7 +1651,7 @@ may be invoked on multiple types. fn map(vector: &[T], function: fn(v: &T) -> U) -> ~[U] { let mut accumulator = ~[]; for vec::each(vector) |element| { - vec::push(accumulator, function(element)); + accumulator.push(function(element)); } return accumulator; } diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index b5c9fc17416..853060ea571 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -345,7 +345,7 @@ fn load_crate(filename: &Path) -> Option { match *ps.interner.get(attr_name) { ~"std" | ~"core" => (), - _ => vec::push(e.deps, query) + _ => e.deps.push(query) } } _ => () @@ -801,7 +801,7 @@ fn install_source(c: &Cargo, path: &Path) { let mut cratefiles = ~[]; for os::walk_dir(&Path(".")) |p| { if p.filetype() == Some(~".rc") { - vec::push(cratefiles, *p); + cratefiles.push(*p); } } diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 5bee7fb255d..8d48669ab17 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -141,7 +141,7 @@ fn make_tests(config: config) -> ~[test::TestDesc] { let file = copy *file; debug!("inspecting file %s", file.to_str()); if is_test(config, file) { - vec::push(tests, make_test(config, file)) + tests.push(make_test(config, file)) } } return tests; diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 5cd54a115ff..19a3c621d27 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -28,7 +28,7 @@ fn load_props(testfile: &Path) -> test_props { let mut pp_exact = option::None; for iter_header(testfile) |ln| { match parse_error_pattern(ln) { - option::Some(ep) => vec::push(error_patterns, ep), + option::Some(ep) => error_patterns.push(ep), option::None => () }; @@ -41,11 +41,11 @@ fn load_props(testfile: &Path) -> test_props { } do parse_aux_build(ln).iter |ab| { - vec::push(aux_builds, ab); + aux_builds.push(ab); } do parse_exec_env(ln).iter |ee| { - vec::push(exec_env, ee); + exec_env.push(ee); } }; return { diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index d62f2fe5837..641425f2b8e 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -19,7 +19,7 @@ fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] { else { (k,v) } }; if str::ends_with(prog, ~"rustc.exe") { - vec::push(env, (~"RUST_THREADS", ~"1")); + env.push((~"RUST_THREADS", ~"1")); } return env; } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index fcb007eca8b..dae5105ce71 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -121,7 +121,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) { procres); } - vec::push(srcs, procres.stdout); + srcs.push(procres.stdout); round += 1; } diff --git a/src/fuzzer/cycles.rs b/src/fuzzer/cycles.rs index 17ed1c0fb96..ec263ead954 100644 --- a/src/fuzzer/cycles.rs +++ b/src/fuzzer/cycles.rs @@ -62,7 +62,7 @@ fn test_cycles(r : rand::rng, k: uint, n: uint) // Create a graph with no edges range(0u, vlen) {|_i| - vec::push(v, empty_pointy()); + v.push(empty_pointy()); } // Fill in the graph with random edges, with density k/n @@ -77,7 +77,7 @@ fn test_cycles(r : rand::rng, k: uint, n: uint) // https://github.com/mozilla/rust/issues/1899 if (likelihood(r, k, n)) { v[i].m = [p(choice(r, v))]; } - if (likelihood(r, k, n)) { vec::push(v[i].n, mut p(choice(r, v))); } + if (likelihood(r, k, n)) { v[i].n.push(mut p(choice(r, v))); } if (likelihood(r, k, n)) { v[i].o = {x: 0, y: p(choice(r, v))}; } } diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 9f1cc419d15..5329d3c14dc 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -30,7 +30,7 @@ fn contains(haystack: ~str, needle: ~str) -> bool { fn find_rust_files(files: &mut ~[Path], path: &Path) { if path.filetype() == Some(~".rs") && !contains(path.to_str(), ~"utf8") { // ignoring "utf8" tests because something is broken - vec::push(*files, *path); + files.push(*path); } else if os::path_is_dir(path) && !contains(path.to_str(), ~"compile-fail") && !contains(path.to_str(), ~"build") { @@ -124,7 +124,7 @@ fn stash_ty_if(c: fn@(@ast::ty, test_mode)->bool, e: @ast::ty, tm: test_mode) { if c(e, tm) { - vec::push(*es,*e); + es.push(e); } else {/* now my indices are wrong :( */ } } diff --git a/src/fuzzer/ivec_fuzz.rs b/src/fuzzer/ivec_fuzz.rs index 9351e23acf0..49d34e76992 100644 --- a/src/fuzzer/ivec_fuzz.rs +++ b/src/fuzzer/ivec_fuzz.rs @@ -55,11 +55,11 @@ fn vec_edits(v: ~[T], xs: ~[T]) -> ~[~[T]] { if Lv != 1u { // When Lv == 1u, this is redundant with omit. - vec::push(edits, ~[]); + edits.push(~[]); } if Lv >= 3u { // When Lv == 2u, this is redundant with swap. - vec::push(edits, vec::reversed(v)); + edits.push(vec::reversed(v)); } ix(0u, 1u, Lv) {|i| edits += ~[vec_omit(v, i)]; } ix(0u, 1u, Lv) {|i| edits += ~[vec_dup(v, i)]; } @@ -69,10 +69,10 @@ fn vec_edits(v: ~[T], xs: ~[T]) -> ~[~[T]] { ix(0u, 1u, len(xs)) {|j| ix(0u, 1u, Lv) {|i| - vec::push(edits, vec_poke(v, i, xs[j])); + edits.push(vec_poke(v, i, xs[j])); } ix(0u, 0u, Lv) {|i| - vec::push(edits, vec_insert(v, i, xs[j])); + edits.push(vec_insert(v, i, xs[j])); } } diff --git a/src/fuzzer/rand_util.rs b/src/fuzzer/rand_util.rs index 39301d17a45..6745805e2d8 100644 --- a/src/fuzzer/rand_util.rs +++ b/src/fuzzer/rand_util.rs @@ -61,7 +61,7 @@ fn weighted_vec(v : ~[weighted]) -> ~[T] { for {weight: weight, item: item} in v { let i = 0u; while i < weight { - vec::push(r, item); + r.push(item); i += 1u; } } diff --git a/src/libcore/core.rs b/src/libcore/core.rs index 8806131c9fb..dae77d66f25 100644 --- a/src/libcore/core.rs +++ b/src/libcore/core.rs @@ -17,6 +17,7 @@ use tuple::{TupleOps, ExtendedTupleOps}; use str::{StrSlice, UniqueStr}; use vec::{ConstVector, CopyableVector, ImmutableVector}; use vec::{ImmutableEqVector, ImmutableCopyableVector}; +use vec::{MutableVector, MutableCopyableVector}; use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; use iter::{CopyableOrderedIter, Times, TimesIx}; use num::Num; @@ -33,6 +34,7 @@ export Num, Times, TimesIx; export StrSlice, UniqueStr; export ConstVector, CopyableVector, ImmutableVector; export ImmutableEqVector, ImmutableCopyableVector, IterTraitExtensions; +export MutableVector, MutableCopyableVector; export BaseIter, CopyableIter, CopyableOrderedIter, ExtendedIter, EqIter; export TupleOps, ExtendedTupleOps; export Ptr; diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 9d3d2e97f9a..eb221926fc1 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -172,7 +172,7 @@ impl DVec { if data_ptr.is_null() { fail ~"Recursive use of dvec"; } log(error, ~"a"); self.data <- ~[move t]; - vec::push_all_move(self.data, move data); + self.data.push_all_move(move data); log(error, ~"b"); } } @@ -180,7 +180,7 @@ impl DVec { /// Append a single item to the end of the list fn push(+t: A) { self.check_not_borrowed(); - vec::push(self.data, move t); + self.data.push(move t); } /// Remove and return the first element @@ -240,7 +240,7 @@ impl DVec { vec::reserve(&mut v, new_len); let mut i = from_idx; while i < to_idx { - vec::push(v, ts[i]); + v.push(ts[i]); i += 1u; } move v @@ -266,7 +266,7 @@ impl DVec { } }; - for ts.each |t| { vec::push(v, *t) }; + for ts.each |t| { v.push(*t) }; v } } diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 55e22f7cfe9..d93074e4a40 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -32,27 +32,27 @@ fn either(f_left: fn((&T)) -> V, fn lefts(eithers: &[Either]) -> ~[T] { //! Extracts from a vector of either all the left values - let mut result: ~[T] = ~[]; - for vec::each(eithers) |elt| { - match *elt { - Left(l) => vec::push(result, l), - _ => { /* fallthrough */ } + do vec::build_sized(eithers.len()) |push| { + for vec::each(eithers) |elt| { + match *elt { + Left(ref l) => { push(*l); } + _ => { /* fallthrough */ } + } } } - move result } fn rights(eithers: &[Either]) -> ~[U] { //! Extracts from a vector of either all the right values - let mut result: ~[U] = ~[]; - for vec::each(eithers) |elt| { - match *elt { - Right(r) => vec::push(result, r), - _ => { /* fallthrough */ } + do vec::build_sized(eithers.len()) |push| { + for vec::each(eithers) |elt| { + match *elt { + Right(ref r) => { push(*r); } + _ => { /* fallthrough */ } + } } } - move result } fn partition(eithers: &[Either]) @@ -68,8 +68,8 @@ fn partition(eithers: &[Either]) let mut rights: ~[U] = ~[]; for vec::each(eithers) |elt| { match *elt { - Left(l) => vec::push(lefts, l), - Right(r) => vec::push(rights, r) + Left(l) => lefts.push(l), + Right(r) => rights.push(r) } } return {lefts: move lefts, rights: move rights}; diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 9a992143a11..fda3f50ca29 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -90,7 +90,7 @@ mod ct { fn flush_buf(+buf: ~str, &pieces: ~[Piece]) -> ~str { if str::len(buf) > 0 { let piece = PieceString(move buf); - vec::push(pieces, move piece); + pieces.push(move piece); } return ~""; } @@ -110,7 +110,7 @@ mod ct { } else { buf = flush_buf(move buf, pieces); let rs = parse_conversion(s, i, lim, error); - vec::push(pieces, copy rs.piece); + pieces.push(copy rs.piece); i = rs.next; } } else { buf += curr; i += size; } diff --git a/src/libcore/flate.rs b/src/libcore/flate.rs index b75894e0c1b..6b4c93949e5 100644 --- a/src/libcore/flate.rs +++ b/src/libcore/flate.rs @@ -71,12 +71,12 @@ fn test_flate_round_trip() { let r = rand::Rng(); let mut words = ~[]; for 20.times { - vec::push(words, r.gen_bytes(r.gen_uint_range(1, 10))); + words.push(r.gen_bytes(r.gen_uint_range(1, 10))); } for 20.times { let mut in = ~[]; for 2000.times { - vec::push_all(in, r.choose(words)); + in.push_all(r.choose(words)); } debug!("de/inflate of %u bytes of random word-sequences", in.len()); diff --git a/src/libcore/float.rs b/src/libcore/float.rs index eaa51814056..cf8a10b9c7b 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -143,7 +143,7 @@ fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { // store the next digit frac *= 10.0; let digit = frac as uint; - vec::push(fractionalParts, digit); + fractionalParts.push(digit); // calculate the next frac frac -= digit as float; diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 97039800fb6..385df30e824 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -76,7 +76,7 @@ impl T : ReaderUtil { loop { let ch = self.read_byte(); if ch == -1 || ch == 10 { break; } - vec::push(buf, ch as u8); + buf.push(ch as u8); } str::from_bytes(buf) } @@ -94,7 +94,7 @@ impl T : ReaderUtil { i += 1; assert (w > 0); if w == 1 { - vec::push(*chars, b0 as char); + chars.push(b0 as char); loop; } // can't satisfy this char with the existing data @@ -113,7 +113,7 @@ impl T : ReaderUtil { // See str::char_at val += ((b0 << ((w + 1) as u8)) as uint) << (w - 1) * 6 - w - 1u; - vec::push(*chars, val as char); + chars.push(val as char); } return (i, 0); } @@ -128,7 +128,7 @@ impl T : ReaderUtil { // we're split in a unicode char? break; } - vec::push_all(buf, data); + buf.push_all(data); let (offset, nbreq) = chars_from_bytes::(&buf, &mut chars); let ncreq = n - chars.len(); // again we either know we need a certain number of bytes @@ -155,7 +155,7 @@ impl T : ReaderUtil { let mut buf: ~[u8] = ~[]; loop { let ch = self.read_byte(); - if ch < 1 { break; } else { vec::push(buf, ch as u8); } + if ch < 1 { break; } else { buf.push(ch as u8); } } str::from_bytes(buf) } @@ -190,7 +190,7 @@ impl T : ReaderUtil { fn read_whole_stream() -> ~[u8] { let mut buf: ~[u8] = ~[]; - while !self.eof() { vec::push_all(buf, self.read_bytes(2048u)); } + while !self.eof() { buf.push_all(self.read_bytes(2048u)); } move buf } @@ -503,7 +503,7 @@ fn u64_to_le_bytes(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { let mut bytes: ~[u8] = ~[], i = size, n = n; while i > 0u { - vec::push(bytes, (n & 255_u64) as u8); + bytes.push((n & 255_u64) as u8); n >>= 8_u64; i -= 1u; } @@ -535,7 +535,7 @@ fn u64_to_be_bytes(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { let mut i = size; while i > 0u { let shift = ((i - 1u) * 8u) as u64; - vec::push(bytes, (n >> shift) as u8); + bytes.push((n >> shift) as u8); i -= 1u; } f(bytes) @@ -737,7 +737,7 @@ fn with_str_writer(f: fn(Writer)) -> ~str { let mut v = with_bytes_writer(f); // Make sure the vector has a trailing null and is proper utf8. - vec::push(v, 0); + v.push(0); assert str::is_utf8(v); unsafe { move ::cast::transmute(v) } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index b4c284cbd82..0a2f00e3f2b 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -219,7 +219,7 @@ mod global_env { for vec::each(rustrt::rust_env_pairs()) |p| { let vs = str::splitn_char(*p, '=', 1u); assert vec::len(vs) == 2u; - vec::push(pairs, (copy vs[0], copy vs[1])); + pairs.push((copy vs[0], copy vs[1])); } move pairs } diff --git a/src/libcore/path.rs b/src/libcore/path.rs index ab847702d68..505ecff2bcf 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -206,7 +206,7 @@ impl PosixPath : GenericPath { let mut ss = str::split_nonempty( *e, |c| windows::is_sep(c as u8)); - unsafe { vec::push_all_move(v, move ss); } + unsafe { v.push_all_move(move ss); } } PosixPath { components: move v, ..self } } @@ -214,7 +214,7 @@ impl PosixPath : GenericPath { pure fn push(s: &str) -> PosixPath { let mut v = copy self.components; let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8)); - unsafe { vec::push_all_move(v, move ss); } + unsafe { v.push_all_move(move ss); } PosixPath { components: move v, ..self } } @@ -400,7 +400,7 @@ impl WindowsPath : GenericPath { let mut ss = str::split_nonempty( *e, |c| windows::is_sep(c as u8)); - unsafe { vec::push_all_move(v, move ss); } + unsafe { v.push_all_move(move ss); } } return WindowsPath { components: move v, ..self } } @@ -408,7 +408,7 @@ impl WindowsPath : GenericPath { pure fn push(s: &str) -> WindowsPath { let mut v = copy self.components; let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8)); - unsafe { vec::push_all_move(v, move ss); } + unsafe { v.push_all_move(move ss); } return WindowsPath { components: move v, ..self } } @@ -440,7 +440,7 @@ pure fn normalize(components: &[~str]) -> ~[~str] { vec::pop(cs); loop; } - vec::push(cs, copy *c); + cs.push(copy *c); } } } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index bbabceafe8e..c4a7fa1437a 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -1059,7 +1059,7 @@ pub fn PortSet() -> PortSet{ impl PortSet : Recv { fn add(+port: pipes::Port) { - vec::push(self.ports, move port) + self.ports.push(move port) } fn chan() -> Chan { diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 4021ad5e88f..7eba81803b3 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -564,7 +564,7 @@ pub mod tests { for uint::range(0u, num_tasks) |_i| { let total = total.clone(); - vec::push(futures, future::spawn(|| { + futures.push(future::spawn(|| { for uint::range(0u, count) |_i| { do total.with |count| { **count += 1u; diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 02aa8530072..d68bd97ae5d 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -215,7 +215,7 @@ impl Rng { let mut r = ~[]; for v.each |item| { for uint::range(0u, item.weight) |_i| { - vec::push(r, item.item); + r.push(item.item); } } move r diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 7644175f93c..3968b0264d9 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -280,7 +280,7 @@ fn map_vec( let mut vs: ~[V] = vec::with_capacity(vec::len(ts)); for vec::each(ts) |t| { match op(t) { - Ok(v) => vec::push(vs, v), + Ok(v) => vs.push(v), Err(u) => return Err(u) } } @@ -317,7 +317,7 @@ fn map_vec2(ss: &[S], ts: &[T], let mut i = 0u; while i < n { match op(&ss[i],&ts[i]) { - Ok(v) => vec::push(vs, v), + Ok(v) => vs.push(v), Err(u) => return Err(u) } i += 1u; diff --git a/src/libcore/run.rs b/src/libcore/run.rs index e3e8491e15a..abeff1bd1d6 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -82,10 +82,10 @@ fn with_argv(prog: &str, args: &[~str], let mut tmps = ~[]; for vec::each(args) |arg| { let t = @copy *arg; - vec::push(tmps, t); - vec::push_all(argptrs, str::as_c_str(*t, |b| ~[b])); + tmps.push(t); + argptrs.push_all(str::as_c_str(*t, |b| ~[b])); } - vec::push(argptrs, ptr::null()); + argptrs.push(ptr::null()); vec::as_imm_buf(argptrs, |buf, _len| cb(buf)) } @@ -102,10 +102,10 @@ fn with_envp(env: &Option<~[(~str,~str)]>, for vec::each(es) |e| { let (k,v) = copy *e; let t = @(fmt!("%s=%s", k, v)); - vec::push(tmps, t); - vec::push_all(ptrs, str::as_c_str(*t, |b| ~[b])); + tmps.push(t); + ptrs.push_all(str::as_c_str(*t, |b| ~[b])); } - vec::push(ptrs, ptr::null()); + ptrs.push(ptr::null()); vec::as_imm_buf(ptrs, |p, _len| unsafe { cb(::cast::reinterpret_cast(&p)) } ) diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index ac9a012c373..7ed962b4a90 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -283,18 +283,9 @@ pub mod linear { FoundEntry(idx) => { match self.buckets[idx] { Some(ref bkt) => { - let ptr = unsafe { - // FIXME(#3148)--region inference - // fails to capture needed deps. - // Here, the bucket value is known to - // live as long as self, because self - // is immutable. But the region - // inference stupidly infers a - // lifetime for `ref bkt` that is - // shorter than it needs to be. - cast::copy_lifetime(self, &bkt.value) - }; - Some(ptr) + // FIXME(#3148)---should be inferred + let bkt: &self/Bucket = bkt; + Some(&bkt.value) } None => { fail ~"LinearMap::find: internal logic error" diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 13fb2260045..0993d1df63f 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -468,7 +468,7 @@ pure fn chars(s: &str) -> ~[char] { let len = len(s); while i < len { let {ch, next} = char_range_at(s, i); - unsafe { vec::push(buf, ch); } + unsafe { buf.push(ch); } i = next; } move buf @@ -537,8 +537,7 @@ pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool) while i < l && done < count { if s[i] == b { if allow_empty || start < i unsafe { - vec::push(result, - unsafe { raw::slice_bytes(s, start, i) }); + result.push(unsafe { raw::slice_bytes(s, start, i) }); } start = i + 1u; done += 1u; @@ -546,7 +545,7 @@ pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool) i += 1u; } if allow_empty || start < l { - unsafe { vec::push(result, raw::slice_bytes(s, start, l) ) }; + unsafe { result.push(raw::slice_bytes(s, start, l) ) }; } move result } else { @@ -581,7 +580,7 @@ pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint, let {ch, next} = char_range_at(s, i); if sepfn(ch) { if allow_empty || start < i unsafe { - vec::push(result, unsafe { raw::slice_bytes(s, start, i)}); + result.push(unsafe { raw::slice_bytes(s, start, i)}); } start = next; done += 1u; @@ -589,7 +588,7 @@ pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint, i = next; } if allow_empty || start < l unsafe { - vec::push(result, unsafe { raw::slice_bytes(s, start, l) }); + result.push(unsafe { raw::slice_bytes(s, start, l) }); } move result } @@ -643,7 +642,7 @@ pure fn iter_between_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { pure fn split_str(s: &a/str, sep: &b/str) -> ~[~str] { let mut result = ~[]; do iter_between_matches(s, sep) |from, to| { - unsafe { vec::push(result, raw::slice_bytes(s, from, to)); } + unsafe { result.push(raw::slice_bytes(s, from, to)); } } move result } @@ -652,7 +651,7 @@ pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] { let mut result = ~[]; do iter_between_matches(s, sep) |from, to| { if to > from { - unsafe { vec::push(result, raw::slice_bytes(s, from, to)); } + unsafe { result.push(raw::slice_bytes(s, from, to)); } } } move result @@ -1535,14 +1534,14 @@ pure fn to_utf16(s: &str) -> ~[u16] { if (ch & 0xFFFF_u32) == ch unsafe { // The BMP falls through (assuming non-surrogate, as it should) assert ch <= 0xD7FF_u32 || ch >= 0xE000_u32; - vec::push(u, ch as u16) + u.push(ch as u16) } else unsafe { // Supplementary planes break into surrogates. assert ch >= 0x1_0000_u32 && ch <= 0x10_FFFF_u32; ch -= 0x1_0000_u32; let w1 = 0xD800_u16 | ((ch >> 10) as u16); let w2 = 0xDC00_u16 | ((ch as u16) & 0x3FF_u16); - vec::push_all(u, ~[w1, w2]) + u.push_all(~[w1, w2]) } } move u @@ -2010,7 +2009,7 @@ mod raw { ptr::memcpy(vbuf, buf as *u8, len) }); vec::raw::set_len(v, len); - vec::push(v, 0u8); + v.push(0u8); assert is_utf8(v); return ::cast::transmute(move v); @@ -2067,7 +2066,7 @@ mod raw { ptr::memcpy(vbuf, src, end - begin); } vec::raw::set_len(v, end - begin); - vec::push(v, 0u8); + v.push(0u8); ::cast::transmute(move v) } } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 7c5f242e8ba..50011dbacec 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -92,6 +92,8 @@ export CopyableVector; export ImmutableVector; export ImmutableEqVector; export ImmutableCopyableVector; +export MutableVector; +export MutableCopyableVector; export IterTraitExtensions; export vec_concat; export traits; @@ -238,7 +240,7 @@ pure fn with_capacity(capacity: uint) -> ~[T] { pure fn build_sized(size: uint, builder: fn(push: pure fn(+v: A))) -> ~[A] { let mut vec = with_capacity(size); - builder(|+x| unsafe { push(vec, move x) }); + builder(|+x| unsafe { vec.push(move x) }); move vec } @@ -330,7 +332,7 @@ pure fn slice(v: &[const T], start: uint, end: uint) -> ~[T] { assert (end <= len(v)); let mut result = ~[]; unsafe { - for uint::range(start, end) |i| { vec::push(result, v[i]) } + for uint::range(start, end) |i| { result.push(v[i]) } } move result } @@ -383,14 +385,14 @@ fn split(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let mut result = ~[]; while start < ln { match position_between(v, start, ln, f) { - None => break, - Some(i) => { - push(result, slice(v, start, i)); - start = i + 1u; - } + None => break, + Some(i) => { + result.push(slice(v, start, i)); + start = i + 1u; + } } } - push(result, slice(v, start, ln)); + result.push(slice(v, start, ln)); move result } @@ -407,16 +409,16 @@ fn splitn(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let mut result = ~[]; while start < ln && count > 0u { match position_between(v, start, ln, f) { - None => break, - Some(i) => { - push(result, slice(v, start, i)); - // Make sure to skip the separator. - start = i + 1u; - count -= 1u; - } + None => break, + Some(i) => { + result.push(slice(v, start, i)); + // Make sure to skip the separator. + start = i + 1u; + count -= 1u; + } } } - push(result, slice(v, start, ln)); + result.push(slice(v, start, ln)); move result } @@ -432,14 +434,14 @@ fn rsplit(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let mut result = ~[]; while end > 0u { match rposition_between(v, 0u, end, f) { - None => break, - Some(i) => { - push(result, slice(v, i + 1u, end)); - end = i; - } + None => break, + Some(i) => { + result.push(slice(v, i + 1u, end)); + end = i; + } } } - push(result, slice(v, 0u, end)); + result.push(slice(v, 0u, end)); reverse(result); return move result; } @@ -457,16 +459,16 @@ fn rsplitn(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let mut result = ~[]; while end > 0u && count > 0u { match rposition_between(v, 0u, end, f) { - None => break, - Some(i) => { - push(result, slice(v, i + 1u, end)); - // Make sure to skip the separator. - end = i; - count -= 1u; - } + None => break, + Some(i) => { + result.push(slice(v, i + 1u, end)); + // Make sure to skip the separator. + end = i; + count -= 1u; + } } } - push(result, slice(v, 0u, end)); + result.push(slice(v, 0u, end)); reverse(result); move result } @@ -489,7 +491,7 @@ fn shift(&v: ~[T]) -> T { for uint::range(1, ln) |i| { let r <- *ptr::offset(vv, i); - push(v, move r); + v.push(move r); } } raw::set_len(vv, 0); @@ -503,7 +505,7 @@ fn unshift(&v: ~[T], +x: T) { let mut vv = ~[move x]; v <-> vv; while len(vv) > 0 { - push(v, shift(vv)); + v.push(shift(vv)); } } @@ -568,9 +570,9 @@ fn swap_remove(&v: ~[const T], index: uint) -> T { /// Append an element to a vector #[inline(always)] -fn push(&v: ~[T], +initval: T) { +fn push(v: &mut ~[T], +initval: T) { unsafe { - let repr: **raw::VecRepr = ::cast::reinterpret_cast(&addr_of(v)); + let repr: **raw::VecRepr = ::cast::transmute(copy v); let fill = (**repr).unboxed.fill; if (**repr).unboxed.alloc > fill { push_fast(v, move initval); @@ -583,8 +585,8 @@ fn push(&v: ~[T], +initval: T) { // This doesn't bother to make sure we have space. #[inline(always)] // really pretty please -unsafe fn push_fast(&v: ~[T], +initval: T) { - let repr: **raw::VecRepr = ::cast::reinterpret_cast(&addr_of(v)); +unsafe fn push_fast(+v: &mut ~[T], +initval: T) { + let repr: **raw::VecRepr = ::cast::transmute(v); let fill = (**repr).unboxed.fill; (**repr).unboxed.fill += sys::size_of::(); let p = ptr::addr_of((**repr).unboxed.data); @@ -593,14 +595,14 @@ unsafe fn push_fast(&v: ~[T], +initval: T) { } #[inline(never)] -fn push_slow(&v: ~[T], +initval: T) { - reserve_at_least(&mut v, v.len() + 1u); +fn push_slow(+v: &mut ~[T], +initval: T) { + reserve_at_least(v, v.len() + 1u); unsafe { push_fast(v, move initval) } } #[inline(always)] -fn push_all(&v: ~[T], rhs: &[const T]) { - reserve(&mut v, v.len() + rhs.len()); +fn push_all(+v: &mut ~[T], rhs: &[const T]) { + reserve(v, v.len() + rhs.len()); for uint::range(0u, rhs.len()) |i| { push(v, unsafe { raw::get(rhs, i) }) @@ -608,8 +610,8 @@ fn push_all(&v: ~[T], rhs: &[const T]) { } #[inline(always)] -fn push_all_move(&v: ~[T], -rhs: ~[const T]) { - reserve(&mut v, v.len() + rhs.len()); +fn push_all_move(v: &mut ~[T], -rhs: ~[const T]) { + reserve(v, v.len() + rhs.len()); unsafe { do as_imm_buf(rhs) |p, len| { for uint::range(0, len) |i| { @@ -675,7 +677,7 @@ fn dedup(&v: ~[const T]) unsafe { pure fn append(+lhs: ~[T], rhs: &[const T]) -> ~[T] { let mut v <- lhs; unsafe { - push_all(v, rhs); + v.push_all(rhs); } move v } @@ -683,7 +685,7 @@ pure fn append(+lhs: ~[T], rhs: &[const T]) -> ~[T] { #[inline(always)] pure fn append_one(+lhs: ~[T], +x: T) -> ~[T] { let mut v <- lhs; - unsafe { push(v, move x); } + unsafe { v.push(move x); } move v } @@ -705,7 +707,10 @@ fn grow(&v: ~[T], n: uint, initval: T) { reserve_at_least(&mut v, len(v) + n); let mut i: uint = 0u; - while i < n { push(v, initval); i += 1u; } + while i < n { + v.push(initval); + i += 1u; + } } /** @@ -724,7 +729,10 @@ fn grow(&v: ~[T], n: uint, initval: T) { fn grow_fn(&v: ~[T], n: uint, op: iter::InitOp) { reserve_at_least(&mut v, len(v) + n); let mut i: uint = 0u; - while i < n { push(v, op(i)); i += 1u; } + while i < n { + v.push(op(i)); + i += 1u; + } } /** @@ -745,14 +753,18 @@ fn grow_set(&v: ~[T], index: uint, initval: T, val: T) { /// Apply a function to each element of a vector and return the results pure fn map(v: &[T], f: fn(v: &T) -> U) -> ~[U] { let mut result = with_capacity(len(v)); - for each(v) |elem| { unsafe { push(result, f(elem)); } } + for each(v) |elem| { + unsafe { + result.push(f(elem)); + } + } move result } fn map_consume(+v: ~[T], f: fn(+v: T) -> U) -> ~[U] { let mut result = ~[]; do consume(move v) |_i, x| { - vec::push(result, f(move x)); + result.push(f(move x)); } move result } @@ -772,7 +784,7 @@ pure fn mapi(v: &[T], f: fn(uint, v: &T) -> U) -> ~[U] { */ pure fn flat_map(v: &[T], f: fn(T) -> ~[U]) -> ~[U] { let mut result = ~[]; - for each(v) |elem| { unsafe{ push_all_move(result, f(*elem)); } } + for each(v) |elem| { unsafe{ result.push_all_move(f(*elem)); } } move result } @@ -784,7 +796,7 @@ pure fn map2(v0: &[T], v1: &[U], let mut u: ~[V] = ~[]; let mut i = 0u; while i < v0_len { - unsafe { push(u, f(copy v0[i], copy v1[i])) }; + unsafe { u.push(f(copy v0[i], copy v1[i])) }; i += 1u; } move u @@ -802,7 +814,7 @@ pure fn filter_map(v: &[T], f: fn(T) -> Option) for each(v) |elem| { match f(*elem) { None => {/* no-op */ } - Some(result_elem) => unsafe { push(result, result_elem); } + Some(result_elem) => unsafe { result.push(result_elem); } } } move result @@ -818,7 +830,7 @@ pure fn filter_map(v: &[T], f: fn(T) -> Option) pure fn filter(v: &[T], f: fn(T) -> bool) -> ~[T] { let mut result = ~[]; for each(v) |elem| { - if f(*elem) { unsafe { push(result, *elem); } } + if f(*elem) { unsafe { result.push(*elem); } } } move result } @@ -830,7 +842,7 @@ pure fn filter(v: &[T], f: fn(T) -> bool) -> ~[T] { */ pure fn concat(v: &[~[T]]) -> ~[T] { let mut r = ~[]; - for each(v) |inner| { unsafe { push_all(r, *inner); } } + for each(v) |inner| { unsafe { r.push_all(*inner); } } move r } @@ -839,8 +851,8 @@ pure fn connect(v: &[~[T]], sep: T) -> ~[T] { let mut r: ~[T] = ~[]; let mut first = true; for each(v) |inner| { - if first { first = false; } else { unsafe { push(r, sep); } } - unsafe { push_all(r, *inner) }; + if first { first = false; } else { unsafe { r.push(sep); } } + unsafe { r.push_all(*inner) }; } move r } @@ -1059,15 +1071,15 @@ pure fn rposition_between(v: &[T], start: uint, end: uint, * Convert a vector of pairs into a pair of vectors, by reference. As unzip(). */ pure fn unzip_slice(v: &[(T, U)]) -> (~[T], ~[U]) { - let mut as_ = ~[], bs = ~[]; + let mut ts = ~[], us = ~[]; for each(v) |p| { - let (a, b) = *p; + let (t, u) = *p; unsafe { - vec::push(as_, a); - vec::push(bs, b); + ts.push(t); + us.push(u); } } - return (move as_, move bs); + return (move ts, move us); } /** @@ -1082,9 +1094,9 @@ pure fn unzip(+v: ~[(T, U)]) -> (~[T], ~[U]) { let mut ts = ~[], us = ~[]; unsafe { do consume(move v) |_i, p| { - let (a,b) = move p; - push(ts, move a); - push(us, move b); + let (t, u) = move p; + ts.push(move t); + us.push(move u); } } (move ts, move us) @@ -1099,7 +1111,7 @@ pure fn zip_slice(v: &[const T], u: &[const U]) let sz = len(v); let mut i = 0u; assert sz == len(u); - while i < sz unsafe { vec::push(zipped, (v[i], u[i])); i += 1u; } + while i < sz unsafe { zipped.push((v[i], u[i])); i += 1u; } move zipped } @@ -1114,7 +1126,7 @@ pure fn zip(+v: ~[const T], +u: ~[const U]) -> ~[(T, U)] { assert i == len(u); let mut w = with_capacity(i); while i > 0 { - unsafe { push(w, (pop(v),pop(u))); } + unsafe { w.push((pop(v),pop(u))); } i -= 1; } unsafe { reverse(w); } @@ -1147,8 +1159,8 @@ pure fn reversed(v: &[const T]) -> ~[T] { let mut i = len::(v); if i == 0 { return (move rs); } else { i -= 1; } unsafe { - while i != 0 { vec::push(rs, v[i]); i -= 1; } - vec::push(rs, v[0]); + while i != 0 { rs.push(v[i]); i -= 1; } + rs.push(v[0]); } move rs } @@ -1283,7 +1295,7 @@ pure fn permute(v: &[const T], put: fn(~[T])) { let elt = v[i]; let mut rest = slice(v, 0u, i); unsafe { - push_all(rest, const_view(v, i+1u, ln)); + rest.push_all(const_view(v, i+1u, ln)); permute(rest, |permutation| { put(append(~[elt], permutation)) }) @@ -1299,7 +1311,7 @@ pure fn windowed(nn: uint, xx: &[TT]) -> ~[~[TT]] { for vec::eachi (xx) |ii, _x| { let len = vec::len(xx); if ii+nn <= len unsafe { - vec::push(ww, vec::slice(xx, ii, ii+nn)); + ww.push(vec::slice(xx, ii, ii+nn)); } } move ww @@ -1551,7 +1563,7 @@ impl &[T]: ImmutableVector { let mut r = ~[]; let mut i = 0; while i < self.len() { - push(r, f(&self[i])); + r.push(f(&self[i])); i += 1; } move r @@ -1637,6 +1649,31 @@ impl &[T]: ImmutableCopyableVector { pure fn rfind(f: fn(T) -> bool) -> Option { rfind(self, f) } } +trait MutableVector { + fn push(&mut self, +t: T); + fn push_all_move(&mut self, -rhs: ~[const T]); +} + +trait MutableCopyableVector { + fn push_all(&mut self, rhs: &[const T]); +} + +impl ~[T]: MutableVector { + fn push(&mut self, +t: T) { + push(self, move t); + } + + fn push_all_move(&mut self, -rhs: ~[const T]) { + push_all_move(self, move rhs); + } +} + +impl ~[T]: MutableCopyableVector { + fn push_all(&mut self, rhs: &[const T]) { + push_all(self, rhs); + } +} + /// Unsafe operations mod raw { #[legacy_exports]; @@ -2109,12 +2146,12 @@ mod tests { fn test_push() { // Test on-stack push(). let mut v = ~[]; - push(v, 1); + v.push(1); assert (len(v) == 1u); assert (v[0] == 1); // Test on-heap push(). - push(v, 2); + v.push(2); assert (len(v) == 2u); assert (v[0] == 1); assert (v[1] == 2); @@ -2380,19 +2417,19 @@ mod tests { let mut results: ~[~[int]]; results = ~[]; - permute(~[], |v| vec::push(results, copy v)); + permute(~[], |v| results.push(copy v)); assert results == ~[~[]]; results = ~[]; - permute(~[7], |v| push(results, copy v)); + permute(~[7], |v| results.push(copy v)); assert results == ~[~[7]]; results = ~[]; - permute(~[1,1], |v| push(results, copy v)); + permute(~[1,1], |v| results.push(copy v)); assert results == ~[~[1,1],~[1,1]]; results = ~[]; - permute(~[5,2,0], |v| push(results, copy v)); + permute(~[5,2,0], |v| results.push(copy v)); assert results == ~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]; } diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 4ffe7245113..1f26822ed9f 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -648,7 +648,7 @@ mod tests { let mut children = ~[]; for 5.times { let arc3 = ~arc.clone(); - do task::task().future_result(|+r| vec::push(children, r)).spawn { + do task::task().future_result(|+r| children.push(r)).spawn { do arc3.read |num| { assert *num >= 0; } @@ -676,7 +676,7 @@ mod tests { let mut reader_convos = ~[]; for 10.times { let ((rc1,rp1),(rc2,rp2)) = (pipes::stream(),pipes::stream()); - vec::push(reader_convos, (rc1,rp2)); + reader_convos.push((rc1,rp2)); let arcn = ~arc.clone(); do task::spawn { rp1.recv(); // wait for downgrader to give go-ahead diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 0da23db7291..e5eacd5c440 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -102,12 +102,12 @@ impl ~[u8]: FromBase64 { } else if ch == '=' { match len - i { 1u => { - vec::push(r, ((n >> 16u) & 0xFFu) as u8); - vec::push(r, ((n >> 8u ) & 0xFFu) as u8); + r.push(((n >> 16u) & 0xFFu) as u8); + r.push(((n >> 8u ) & 0xFFu) as u8); return copy r; } 2u => { - vec::push(r, ((n >> 10u) & 0xFFu) as u8); + r.push(((n >> 10u) & 0xFFu) as u8); return copy r; } _ => fail ~"invalid base64 padding" @@ -119,9 +119,9 @@ impl ~[u8]: FromBase64 { i += 1u; }; - vec::push(r, ((n >> 16u) & 0xFFu) as u8); - vec::push(r, ((n >> 8u ) & 0xFFu) as u8); - vec::push(r, ((n ) & 0xFFu) as u8); + r.push(((n >> 16u) & 0xFFu) as u8); + r.push(((n >> 8u ) & 0xFFu) as u8); + r.push(((n ) & 0xFFu) as u8); } r diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 17d4b39b01e..8506bd5f6fc 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -38,8 +38,8 @@ fn create() -> Deque { let nalloc = uint::next_power_of_two(nelts + 1u); while i < nalloc { if i < nelts { - vec::push(rv, elts[(lo + i) % nelts]); - } else { vec::push(rv, None); } + rv.push(elts[(lo + i) % nelts]); + } else { rv.push(None); } i += 1u; } diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 9b7f7a79f22..3f6bcd31a73 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -211,7 +211,7 @@ impl Writer { write_vuint(self.writer, tag_id); // Write a placeholder four-byte size. - vec::push(self.size_positions, self.writer.tell()); + self.size_positions.push(self.writer.tell()); let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8]; self.writer.write(zeroes); } diff --git a/src/libstd/ebml2.rs b/src/libstd/ebml2.rs index 8b37dea6210..496010d579e 100644 --- a/src/libstd/ebml2.rs +++ b/src/libstd/ebml2.rs @@ -220,7 +220,7 @@ impl Serializer { write_vuint(self.writer, tag_id); // Write a placeholder four-byte size. - vec::push(self.size_positions, self.writer.tell()); + self.size_positions.push(self.writer.tell()); let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8]; self.writer.write(zeroes); } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index f8b86d80061..7a47db8a7f0 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -234,10 +234,10 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { let cur = args[i]; let curlen = str::len(cur); if !is_arg(cur) { - vec::push(free, cur); + free.push(cur); } else if cur == ~"--" { let mut j = i + 1u; - while j < l { vec::push(free, args[j]); j += 1u; } + while j < l { free.push(args[j]); j += 1u; } break; } else { let mut names; @@ -287,7 +287,7 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { } } } - vec::push(names, opt); + names.push(opt); j = range.next; } } @@ -303,23 +303,22 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { if !i_arg.is_none() { return Err(UnexpectedArgument(name_str(nm))); } - vec::push(vals[optid], Given); + vals[optid].push(Given); } Maybe => { if !i_arg.is_none() { - vec::push(vals[optid], Val(i_arg.get())); + vals[optid].push(Val(i_arg.get())); } else if name_pos < vec::len::(names) || i + 1u == l || is_arg(args[i + 1u]) { - vec::push(vals[optid], Given); - } else { i += 1u; vec::push(vals[optid], Val(args[i])); } + vals[optid].push(Given); + } else { i += 1u; vals[optid].push(Val(args[i])); } } Yes => { if !i_arg.is_none() { - vec::push(vals[optid], - Val(i_arg.get())); + vals[optid].push(Val(i_arg.get())); } else if i + 1u == l { return Err(ArgumentMissing(name_str(nm))); - } else { i += 1u; vec::push(vals[optid], Val(args[i])); } + } else { i += 1u; vals[optid].push(Val(args[i])); } } } } @@ -412,7 +411,7 @@ fn opts_str(+mm: Matches, names: &[~str]) -> ~str { fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { let mut acc: ~[~str] = ~[]; for vec::each(opt_vals(mm, nm)) |v| { - match *v { Val(s) => vec::push(acc, s), _ => () } + match *v { Val(s) => acc.push(s), _ => () } } return acc; } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index f75f033bb8e..29535c62b5e 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -594,7 +594,7 @@ priv impl Parser { loop { match move self.parse_value() { - Ok(move v) => vec::push(values, v), + Ok(move v) => values.push(v), Err(move e) => return Err(e) } @@ -690,13 +690,13 @@ pub fn Deserializer(rdr: io::Reader) -> Result { } priv impl Deserializer { - fn peek() -> &self/Json { - if self.stack.len() == 0 { vec::push(self.stack, &self.json); } + fn peek(&self) -> &self/Json { + if self.stack.len() == 0 { self.stack.push(&self.json); } vec::last(self.stack) } - fn pop() -> &self/Json { - if self.stack.len() == 0 { vec::push(self.stack, &self.json); } + fn pop(&self) -> &self/Json { + if self.stack.len() == 0 { self.stack.push(&self.json); } vec::pop(self.stack) } } @@ -772,7 +772,7 @@ pub impl Deserializer: serialization2::Deserializer { fn read_vec(&self, f: fn(uint) -> T) -> T { debug!("read_vec()"); let len = match *self.peek() { - List(list) => list.len(), + List(ref list) => list.len(), _ => fail ~"not a list", }; let res = f(len); @@ -784,7 +784,10 @@ pub impl Deserializer: serialization2::Deserializer { debug!("read_vec_elt(idx=%u)", idx); match *self.peek() { List(ref list) => { - vec::push(self.stack, &list[idx]); + // FIXME(#3148)---should be inferred + let list: &self/~[Json] = list; + + self.stack.push(&list[idx]); f() } _ => fail ~"not a list", @@ -820,7 +823,7 @@ pub impl Deserializer: serialization2::Deserializer { match obj.find_ref(&f_name) { None => fail fmt!("no such field: %s", f_name), Some(json) => { - vec::push(self.stack, json); + self.stack.push(json); f() } } @@ -845,8 +848,10 @@ pub impl Deserializer: serialization2::Deserializer { fn read_tup_elt(&self, idx: uint, f: fn() -> T) -> T { debug!("read_tup_elt(idx=%u)", idx); match *self.peek() { - List(list) => { - vec::push(self.stack, &list[idx]); + List(ref list) => { + // FIXME(#3148)---should be inferred + let list: &self/~[Json] = list; + self.stack.push(&list[idx]); f() } _ => fail ~"not a list" @@ -939,12 +944,12 @@ impl Json : Ord { // XXX: this is horribly inefficient... for d0.each |k, v| { - vec::push(d0_flat, (@copy *k, @copy *v)); + d0_flat.push((@copy *k, @copy *v)); } d0_flat.qsort(); for d1.each |k, v| { - vec::push(d1_flat, (@copy *k, @copy *v)); + d1_flat.push((@copy *k, @copy *v)); } d1_flat.qsort(); diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index a4272324670..0bf4f6f8610 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -11,14 +11,14 @@ fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { let mut msg = vec::append(vec::from_slice(msg), ~[0x80u8]); let mut bitlen = orig_len + 8u64; while (bitlen + 64u64) % 512u64 > 0u64 { - vec::push(msg, 0u8); + msg.push(0u8); bitlen += 8u64; } // append length let mut i = 0u64; while i < 8u64 { - vec::push(msg, (orig_len >> (i * 8u64)) as u8); + msg.push((orig_len >> (i * 8u64)) as u8); i += 1u64; } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 445bc62e4c9..347f2b271a1 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -277,7 +277,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int, result::Err(GetAddrUnknownError)); break; }; - vec::push(out_vec, move new_ip_addr); + out_vec.push(move new_ip_addr); let next_addr = ll::get_next_addrinfo(curr_addr); if next_addr == ptr::null::() as *addrinfo { diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index a1c7637dee6..a0ba8aae3f1 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -779,7 +779,7 @@ impl TcpSocketBuf: io::Reader { } } else { - vec::push_all(self.data.buf, result::unwrap(read_result)); + self.data.buf.push_all(result::unwrap(read_result)); } } @@ -790,7 +790,7 @@ impl TcpSocketBuf: io::Reader { vec::bytes::memcpy(buf, vec::view(data, 0, data.len()), count); - vec::push_all(self.data.buf, vec::view(data, count, data.len())); + self.data.buf.push_all(vec::view(data, count, data.len())); count } diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 8116bd4fb30..33e657c390b 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -329,7 +329,7 @@ fn query_from_str(rawquery: &str) -> Query { if str::len(rawquery) != 0 { for str::split_char(rawquery, '&').each |p| { let (k, v) = split_char_first(*p, '='); - vec::push(query, (decode_component(k), decode_component(v))); + query.push((decode_component(k), decode_component(v))); }; } return query; diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 38a814b22e0..2f98c4bad34 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -55,7 +55,7 @@ fn map_slices( f(base, slice) } }; - vec::push(futures, move f); + futures.push(move f); }; base += items_per_task; } diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 2d49ede3507..4680448e275 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -869,7 +869,7 @@ mod node { loop { match (leaf_iterator::next(&it)) { option::None => break, - option::Some(x) => vec::push(forest, @Leaf(x)) + option::Some(x) => forest.push(@Leaf(x)) } } //2. Rebuild tree from forest diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 46f79c01948..f1abe5be5a5 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -47,9 +47,9 @@ fn merge_sort(le: Le, v: &[const T]) -> ~[T] { let mut b_ix = 0u; while a_ix < a_len && b_ix < b_len { if le(&a[a_ix], &b[b_ix]) { - vec::push(rs, a[a_ix]); + rs.push(a[a_ix]); a_ix += 1u; - } else { vec::push(rs, b[b_ix]); b_ix += 1u; } + } else { rs.push(b[b_ix]); b_ix += 1u; } } rs = vec::append(rs, vec::slice(a, a_ix, a_len)); rs = vec::append(rs, vec::slice(b, b_ix, b_len)); diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 8fdcc22b4c1..7638b43ad86 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -82,7 +82,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint) -> Sem<~[mut Waitqueue]> { let mut queues = ~[]; for num_condvars.times { - vec::push(queues, new_waitqueue()); + queues.push(new_waitqueue()); } new_sem(count, vec::to_mut(move queues)) } @@ -840,7 +840,7 @@ mod tests { for num_waiters.times { let mi = ~m.clone(); let (chan, port) = pipes::stream(); - vec::push(ports, port); + ports.push(port); do task::spawn { do mi.lock_cond |cond| { chan.send(()); @@ -930,7 +930,7 @@ mod tests { for 2.times { let (c,p) = pipes::stream(); let c = ~mut Some(c); - vec::push(sibling_convos, p); + sibling_convos.push(p); let mi = ~m2.clone(); // spawn sibling task do task::spawn { // linked @@ -1194,7 +1194,7 @@ mod tests { for num_waiters.times { let xi = ~x.clone(); let (chan, port) = pipes::stream(); - vec::push(ports, port); + ports.push(port); do task::spawn { do lock_cond(xi, dg1) |cond| { chan.send(()); diff --git a/src/libstd/test.rs b/src/libstd/test.rs index e872cba5dc9..facc43f6273 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -141,7 +141,7 @@ fn run_tests_console(opts: &TestOpts, st.failed += 1u; write_failed(st.out, st.use_color); st.out.write_line(~""); - vec::push(st.failures, copy test); + st.failures.push(copy test); } TrIgnored => { st.ignored += 1u; @@ -545,7 +545,7 @@ mod tests { for vec::each(names) |name| { let test = {name: *name, testfn: copy testfn, ignore: false, should_fail: false}; - vec::push(tests, test); + tests.push(test); } tests }; 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(f: fn@(T) -> Option, 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; diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index c8f5871333f..4bbd51524c4 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -392,14 +392,14 @@ fn build_link_meta(sess: session, c: ast::crate, output: &Path, if attr::get_meta_item_name(*meta) == ~"name" { match attr::get_meta_item_value_str(*meta) { Some(v) => { name = Some(v); } - None => vec::push(cmh_items, *meta) + None => cmh_items.push(*meta) } } else if attr::get_meta_item_name(*meta) == ~"vers" { match attr::get_meta_item_value_str(*meta) { Some(v) => { vers = Some(v); } - None => vec::push(cmh_items, *meta) + None => cmh_items.push(*meta) } - } else { vec::push(cmh_items, *meta); } + } else { cmh_items.push(*meta); } } return {name: name, vers: vers, cmh_items: cmh_items}; } @@ -657,9 +657,9 @@ fn link_binary(sess: session, let mut cc_args = vec::append(~[stage], sess.targ_cfg.target_strs.cc_args); - vec::push(cc_args, ~"-o"); - vec::push(cc_args, output.to_str()); - vec::push(cc_args, obj_filename.to_str()); + cc_args.push(~"-o"); + cc_args.push(output.to_str()); + cc_args.push(obj_filename.to_str()); let mut lib_cmd; let os = sess.targ_cfg.os; @@ -674,17 +674,17 @@ fn link_binary(sess: session, let cstore = sess.cstore; for cstore::get_used_crate_files(cstore).each |cratepath| { if cratepath.filetype() == Some(~".rlib") { - vec::push(cc_args, cratepath.to_str()); + cc_args.push(cratepath.to_str()); loop; } let dir = cratepath.dirname(); - if dir != ~"" { vec::push(cc_args, ~"-L" + dir); } + if dir != ~"" { cc_args.push(~"-L" + dir); } let libarg = unlib(sess.targ_cfg, cratepath.filestem().get()); - vec::push(cc_args, ~"-l" + libarg); + cc_args.push(~"-l" + libarg); } let ula = cstore::get_used_link_args(cstore); - for ula.each |arg| { vec::push(cc_args, *arg); } + for ula.each |arg| { cc_args.push(*arg); } // # Extern library linking @@ -695,41 +695,41 @@ fn link_binary(sess: session, // forces to make sure that library can be found at runtime. let addl_paths = sess.opts.addl_lib_search_paths; - for addl_paths.each |path| { vec::push(cc_args, ~"-L" + path.to_str()); } + for addl_paths.each |path| { cc_args.push(~"-L" + path.to_str()); } // The names of the extern libraries let used_libs = cstore::get_used_libraries(cstore); - for used_libs.each |l| { vec::push(cc_args, ~"-l" + *l); } + for used_libs.each |l| { cc_args.push(~"-l" + *l); } if sess.building_library { - vec::push(cc_args, lib_cmd); + cc_args.push(lib_cmd); // On mac we need to tell the linker to let this library // be rpathed if sess.targ_cfg.os == session::os_macos { - vec::push(cc_args, ~"-Wl,-install_name,@rpath/" + cc_args.push(~"-Wl,-install_name,@rpath/" + output.filename().get()); } } if !sess.debugging_opt(session::no_rt) { // Always want the runtime linked in - vec::push(cc_args, ~"-lrustrt"); + cc_args.push(~"-lrustrt"); } // On linux librt and libdl are an indirect dependencies via rustrt, // and binutils 2.22+ won't add them automatically if sess.targ_cfg.os == session::os_linux { - vec::push_all(cc_args, ~[~"-lrt", ~"-ldl"]); + cc_args.push_all(~[~"-lrt", ~"-ldl"]); // LLVM implements the `frem` instruction as a call to `fmod`, // which lives in libm. Similar to above, on some linuxes we // have to be explicit about linking to it. See #2510 - vec::push(cc_args, ~"-lm"); + cc_args.push(~"-lm"); } if sess.targ_cfg.os == session::os_freebsd { - vec::push_all(cc_args, ~[~"-pthread", ~"-lrt", + cc_args.push_all(~[~"-pthread", ~"-lrt", ~"-L/usr/local/lib", ~"-lexecinfo", ~"-L/usr/local/lib/gcc46", ~"-L/usr/local/lib/gcc44", ~"-lstdc++", @@ -743,15 +743,15 @@ fn link_binary(sess: session, // understand how to unwind our __morestack frame, so we have to turn it // off. This has impacted some other projects like GHC. if sess.targ_cfg.os == session::os_macos { - vec::push(cc_args, ~"-Wl,-no_compact_unwind"); + cc_args.push(~"-Wl,-no_compact_unwind"); } // Stack growth requires statically linking a __morestack function - vec::push(cc_args, ~"-lmorestack"); + cc_args.push(~"-lmorestack"); // FIXME (#2397): At some point we want to rpath our guesses as to where // extern libraries might live, based on the addl_lib_search_paths - vec::push_all(cc_args, rpath::get_rpath_flags(sess, &output)); + cc_args.push_all(rpath::get_rpath_flags(sess, &output)); debug!("%s link args: %s", cc_prog, str::connect(cc_args, ~" ")); // We run 'cc' here diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index 132bbc96344..8aa7caefc7a 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -81,8 +81,8 @@ fn get_rpaths(os: session::os, log_rpaths(~"fallback", fallback_rpaths); let mut rpaths = rel_rpaths; - vec::push_all(rpaths, abs_rpaths); - vec::push_all(rpaths, fallback_rpaths); + rpaths.push_all(abs_rpaths); + rpaths.push_all(fallback_rpaths); // Remove duplicates let rpaths = minimize_rpaths(rpaths); @@ -136,9 +136,9 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path { } let mut path = ~[]; - for uint::range(start_idx, len1 - 1) |_i| { vec::push(path, ~".."); }; + for uint::range(start_idx, len1 - 1) |_i| { path.push(~".."); }; - vec::push_all(path, vec::view(split2, start_idx, len2 - 1)); + path.push_all(vec::view(split2, start_idx, len2 - 1)); if vec::is_not_empty(path) { return Path("").push_many(path); @@ -172,7 +172,7 @@ fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] { for rpaths.each |rpath| { let s = rpath.to_str(); if !set.contains_key(s) { - vec::push(minimized, *rpath); + minimized.push(*rpath); set.insert(s, ()); } } diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index f289a0bdf27..a2c864f6f46 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -28,7 +28,7 @@ fn declare_upcalls(targ_cfg: @session::config, tys: ~[TypeRef], rv: TypeRef) -> ValueRef { let mut arg_tys: ~[TypeRef] = ~[]; - for tys.each |t| { vec::push(arg_tys, *t); } + for tys.each |t| { arg_tys.push(*t); } let fn_ty = T_fn(arg_tys, rv); return base::decl_cdecl_fn(llmod, prefix + name, fn_ty); } diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index f890fa85eb3..3acacd3c0a5 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -94,7 +94,7 @@ fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg { // meta_word variant. let mut words = ~[]; for cfgspecs.each |s| { - vec::push(words, attr::mk_word_item(*s)); + words.push(attr::mk_word_item(*s)); } return words; } @@ -466,7 +466,7 @@ fn build_session_options(binary: ~str, level_name, lint_name)); } Some(lint) => { - vec::push(lint_opts, (lint.lint, *level)); + lint_opts.push((lint.lint, *level)); } } } diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index e1441d9ee5e..55d71ab6950 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -99,7 +99,7 @@ fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) -> fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> Option<@ast::item> { - vec::push(cx.path, i.ident); + cx.path.push(i.ident); debug!("current path: %s", ast_util::path_name_i(cx.path, cx.sess.parse_sess.interner)); @@ -286,7 +286,7 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr { debug!("building test vector from %u tests", cx.testfns.len()); let mut descs = ~[]; for cx.testfns.each |test| { - vec::push(descs, mk_test_desc_rec(cx, *test)); + descs.push(mk_test_desc_rec(cx, *test)); } let inner_expr = @{id: cx.sess.next_node_id(), diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index 8a982eaf497..edf6a9612c7 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -115,7 +115,7 @@ fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) { fn add_used_crate_file(cstore: cstore, lib: &Path) { if !vec::contains(p(cstore).used_crate_files, copy *lib) { - vec::push(p(cstore).used_crate_files, copy *lib); + p(cstore).used_crate_files.push(copy *lib); } } @@ -127,7 +127,7 @@ fn add_used_library(cstore: cstore, lib: ~str) -> bool { assert lib != ~""; if vec::contains(p(cstore).used_libraries, lib) { return false; } - vec::push(p(cstore).used_libraries, lib); + p(cstore).used_libraries.push(lib); return true; } @@ -136,7 +136,7 @@ fn get_used_libraries(cstore: cstore) -> ~[~str] { } fn add_used_link_args(cstore: cstore, args: ~str) { - vec::push_all(p(cstore).used_link_args, str::split_char(args, ' ')); + p(cstore).used_link_args.push_all(str::split_char(args, ' ')); } fn get_used_link_args(cstore: cstore) -> ~[~str] { @@ -163,7 +163,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[~str] { let cdata = cstore::get_crate_data(cstore, cnum); let hash = decoder::get_crate_hash(cdata.data); debug!("Add hash[%s]: %s", cdata.name, hash); - vec::push(result, {name: cdata.name, hash: hash}); + result.push({name: cdata.name, hash: hash}); }; pure fn lteq(a: &crate_hash, b: &crate_hash) -> bool {a.name <= b.name} let sorted = std::sort::merge_sort(lteq, result); diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 4a72867eb85..a6bb681bc16 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -227,7 +227,7 @@ fn item_type(item_id: ast::def_id, item: ebml::Doc, fn item_impl_traits(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] { let mut results = ~[]; for ebml::tagged_docs(item, tag_impl_trait) |ity| { - vec::push(results, doc_type(ity, tcx, cdata)); + results.push(doc_type(ity, tcx, cdata)); }; results } @@ -239,7 +239,7 @@ fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx, |did| { translate_def_id(cdata, did) }); - vec::push(bounds, bd); + bounds.push(bd); } @bounds } @@ -263,7 +263,7 @@ fn enum_variant_ids(item: ebml::Doc, cdata: cmd) -> ~[ast::def_id] { let v = tag_items_data_item_variant; for ebml::tagged_docs(item, v) |p| { let ext = ebml::with_doc_data(p, |d| parse_def_id(d)); - vec::push(ids, {crate: cdata.cnum, node: ext.node}); + ids.push({crate: cdata.cnum, node: ext.node}); }; return ids; } @@ -278,10 +278,10 @@ fn item_path(intr: @ident_interner, item_doc: ebml::Doc) -> ast_map::path { for ebml::docs(path_doc) |tag, elt_doc| { if tag == tag_path_elt_mod { let str = ebml::doc_as_str(elt_doc); - vec::push(result, ast_map::path_mod(intr.intern(@str))); + result.push(ast_map::path_mod(intr.intern(@str))); } else if tag == tag_path_elt_name { let str = ebml::doc_as_str(elt_doc); - vec::push(result, ast_map::path_name(intr.intern(@str))); + result.push(ast_map::path_name(intr.intern(@str))); } else { // ignore tag_path_len element } @@ -584,7 +584,7 @@ fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id, let mut arg_tys: ~[ty::t] = ~[]; match ty::get(ctor_ty).sty { ty::ty_fn(f) => { - for f.sig.inputs.each |a| { vec::push(arg_tys, a.ty); } + for f.sig.inputs.each |a| { arg_tys.push(a.ty); } } _ => { /* Nullary enum variant. */ } } @@ -592,7 +592,7 @@ fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id, Some(val) => { disr_val = val; } _ => { /* empty */ } } - vec::push(infos, @{args: arg_tys, ctor_ty: ctor_ty, name: name, + infos.push(@{args: arg_tys, ctor_ty: ctor_ty, name: name, id: *did, disr_val: disr_val}); disr_val += 1; } @@ -645,7 +645,7 @@ fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc, let m_did = ebml::with_doc_data(doc, |d| parse_def_id(d)); let mth_item = lookup_item(m_did.node, cdata.data); let self_ty = get_self_ty(mth_item); - vec::push(rslt, @{did: translate_def_id(cdata, m_did), + rslt.push(@{did: translate_def_id(cdata, m_did), /* FIXME (maybe #2323) tjc: take a look at this. */ n_tps: item_ty_param_count(mth_item) - base_tps, ident: item_name(intr, mth_item), @@ -675,7 +675,7 @@ fn get_impls_for_mod(intr: @ident_interner, cdata: cmd, let nm = item_name(intr, item); if match name { Some(n) => { n == nm } None => { true } } { let base_tps = item_ty_param_count(item); - vec::push(result, @{ + result.push(@{ did: local_did, ident: nm, methods: item_impl_methods(intr, impl_cdata, item, base_tps) }); @@ -701,7 +701,7 @@ fn get_trait_methods(intr: @ident_interner, cdata: cmd, id: ast::node_id, ~"get_trait_methods: id has non-function type"); } }; let self_ty = get_self_ty(mth); - vec::push(result, {ident: name, tps: bounds, fty: fty, + result.push({ident: name, tps: bounds, fty: fty, self_ty: self_ty, vis: ast::public}); } @@ -753,7 +753,7 @@ fn get_class_members(intr: @ident_interner, cdata: cmd, id: ast::node_id, let name = item_name(intr, an_item); let did = item_def_id(an_item, cdata); let mt = field_mutability(an_item); - vec::push(result, {ident: name, id: did, vis: + result.push({ident: name, id: did, vis: family_to_visibility(f), mutability: mt}); } } @@ -835,7 +835,7 @@ fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] { for ebml::tagged_docs(md, tag_meta_item_word) |meta_item_doc| { let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let n = str::from_bytes(ebml::doc_data(nd)); - vec::push(items, attr::mk_word_item(n)); + items.push(attr::mk_word_item(n)); }; for ebml::tagged_docs(md, tag_meta_item_name_value) |meta_item_doc| { let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); @@ -844,13 +844,13 @@ fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] { let v = str::from_bytes(ebml::doc_data(vd)); // FIXME (#623): Should be able to decode meta_name_value variants, // but currently the encoder just drops them - vec::push(items, attr::mk_name_value_item_str(n, v)); + items.push(attr::mk_name_value_item_str(n, v)); }; for ebml::tagged_docs(md, tag_meta_item_list) |meta_item_doc| { let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let n = str::from_bytes(ebml::doc_data(nd)); let subitems = get_meta_items(meta_item_doc); - vec::push(items, attr::mk_list_item(n, subitems)); + items.push(attr::mk_list_item(n, subitems)); }; return items; } @@ -865,10 +865,10 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] { // an attribute assert (vec::len(meta_items) == 1u); let meta_item = meta_items[0]; - vec::push(attrs, - {node: {style: ast::attr_outer, value: *meta_item, - is_sugared_doc: false}, - span: ast_util::dummy_sp()}); + attrs.push( + {node: {style: ast::attr_outer, value: *meta_item, + is_sugared_doc: false}, + span: ast_util::dummy_sp()}); }; } option::None => () @@ -910,7 +910,7 @@ fn get_crate_deps(intr: @ident_interner, data: @~[u8]) -> ~[crate_dep] { str::from_bytes(ebml::doc_data(ebml::get_doc(doc, tag_))) } for ebml::tagged_docs(depsdoc, tag_crate_dep) |depdoc| { - vec::push(deps, {cnum: crate_num, + deps.push({cnum: crate_num, name: intr.intern(@docstr(depdoc, tag_crate_dep_name)), vers: docstr(depdoc, tag_crate_dep_vers), hash: docstr(depdoc, tag_crate_dep_hash)}); @@ -977,7 +977,7 @@ fn get_crate_module_paths(intr: @ident_interner, cdata: cmd) // Collect everything by now. There might be multiple // paths pointing to the same did. Those will be // unified later by using the mods map - vec::push(res, (did, path)); + res.push((did, path)); } return do vec::filter(res) |x| { let (_, xp) = x; diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 3424ea8dd57..81ad9dfc3a5 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -118,12 +118,12 @@ type entry = {val: T, pos: uint}; fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: &[ident], &index: ~[entry<~str>], name: ident) { let mut full_path = ~[]; - vec::push_all(full_path, path); - vec::push(full_path, name); - vec::push(index, - {val: ast_util::path_name_i(full_path, - ecx.tcx.sess.parse_sess.interner), - pos: ebml_w.writer.tell()}); + full_path.push_all(path); + full_path.push(name); + index.push( + {val: ast_util::path_name_i(full_path, + ecx.tcx.sess.parse_sess.interner), + pos: ebml_w.writer.tell()}); } fn encode_trait_ref(ebml_w: ebml::Writer, ecx: @encode_ctxt, t: @trait_ref) { @@ -225,7 +225,7 @@ fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::Writer, let mut i = 0; let vi = ty::enum_variants(ecx.tcx, {crate: local_crate, node: id}); for variants.each |variant| { - vec::push(*index, {val: variant.node.id, pos: ebml_w.writer.tell()}); + index.push({val: variant.node.id, pos: ebml_w.writer.tell()}); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(variant.node.id)); encode_family(ebml_w, 'v'); @@ -390,9 +390,9 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::Writer, match field.node.kind { named_field(nm, mt, vis) => { let id = field.node.id; - vec::push(*index, {val: id, pos: ebml_w.writer.tell()}); - vec::push(*global_index, {val: id, - pos: ebml_w.writer.tell()}); + index.push({val: id, pos: ebml_w.writer.tell()}); + global_index.push({val: id, + pos: ebml_w.writer.tell()}); ebml_w.start_tag(tag_items_data_item); debug!("encode_info_for_class: doing %s %d", tcx.sess.str_of(nm), id); @@ -411,9 +411,9 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::Writer, for methods.each |m| { match m.vis { public | inherited => { - vec::push(*index, {val: m.id, pos: ebml_w.writer.tell()}); - vec::push(*global_index, - {val: m.id, pos: ebml_w.writer.tell()}); + index.push({val: m.id, pos: ebml_w.writer.tell()}); + global_index.push( + {val: m.id, pos: ebml_w.writer.tell()}); let impl_path = vec::append_one(path, ast_map::path_name(m.ident)); debug!("encode_info_for_class: doing %s %d", @@ -519,7 +519,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item, fn add_to_index_(item: @item, ebml_w: ebml::Writer, index: @mut ~[entry]) { - vec::push(*index, {val: item.id, pos: ebml_w.writer.tell()}); + index.push({val: item.id, pos: ebml_w.writer.tell()}); } let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index); @@ -603,7 +603,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item, index); /* Encode the dtor */ do struct_def.dtor.iter |dtor| { - vec::push(*index, {val: dtor.node.id, pos: ebml_w.writer.tell()}); + index.push({val: dtor.node.id, pos: ebml_w.writer.tell()}); encode_info_for_ctor(ecx, ebml_w, dtor.node.id, ecx.tcx.sess.ident_of( ecx.tcx.sess.str_of(item.ident) + @@ -688,7 +688,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item, for struct_def.ctor.each |ctor| { debug!("encoding info for ctor %s %d", ecx.tcx.sess.str_of(item.ident), ctor.node.id); - vec::push(*index, { + index.push({ val: ctor.node.id, pos: ebml_w.writer.tell() }); @@ -723,7 +723,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item, let impl_path = vec::append_one(path, ast_map::path_name(item.ident)); for methods.each |m| { - vec::push(*index, {val: m.id, pos: ebml_w.writer.tell()}); + index.push({val: m.id, pos: ebml_w.writer.tell()}); encode_info_for_method(ecx, ebml_w, impl_path, should_inline(m.attrs), item.id, *m, vec::append(tps, m.tps)); @@ -774,7 +774,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item, let ty_m = ast_util::trait_method_to_ty_method(*m); if ty_m.self_ty.node != ast::sty_static { loop; } - vec::push(*index, {val: ty_m.id, pos: ebml_w.writer.tell()}); + index.push({val: ty_m.id, pos: ebml_w.writer.tell()}); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(ty_m.id)); @@ -799,7 +799,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, index: @mut ~[entry], path: ast_map::path, abi: foreign_abi) { if !reachable(ecx, nitem.id) { return; } - vec::push(*index, {val: nitem.id, pos: ebml_w.writer.tell()}); + index.push({val: nitem.id, pos: ebml_w.writer.tell()}); ebml_w.start_tag(tag_items_data_item); match nitem.node { @@ -831,7 +831,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::Writer, crate: @crate) -> ~[entry] { let index = @mut ~[]; ebml_w.start_tag(tag_items_data); - vec::push(*index, {val: crate_node_id, pos: ebml_w.writer.tell()}); + index.push({val: crate_node_id, pos: ebml_w.writer.tell()}); encode_info_for_mod(ecx, ebml_w, crate.node.module, crate_node_id, ~[], syntax::parse::token::special_idents::invalid); @@ -869,15 +869,15 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::Writer, fn create_index(index: ~[entry]) -> ~[@~[entry]] { let mut buckets: ~[@mut ~[entry]] = ~[]; - for uint::range(0u, 256u) |_i| { vec::push(buckets, @mut ~[]); }; + for uint::range(0u, 256u) |_i| { buckets.push(@mut ~[]); }; for index.each |elt| { let h = elt.val.hash() as uint; - vec::push(*buckets[h % 256], *elt); + buckets[h % 256].push(*elt); } let mut buckets_frozen = ~[]; for buckets.each |bucket| { - vec::push(buckets_frozen, @**bucket); + buckets_frozen.push(@**bucket); } return buckets_frozen; } @@ -889,7 +889,7 @@ fn encode_index(ebml_w: ebml::Writer, buckets: ~[@~[entry]], let mut bucket_locs: ~[uint] = ~[]; ebml_w.start_tag(tag_index_buckets); for buckets.each |bucket| { - vec::push(bucket_locs, ebml_w.writer.tell()); + bucket_locs.push(ebml_w.writer.tell()); ebml_w.start_tag(tag_index_buckets_bucket); for vec::each(**bucket) |elt| { ebml_w.start_tag(tag_index_buckets_bucket_elt); @@ -996,8 +996,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { let mut attrs: ~[attribute] = ~[]; let mut found_link_attr = false; for crate.node.attrs.each |attr| { - vec::push( - attrs, + attrs.push( if attr::get_attr_name(*attr) != ~"link" { *attr } else { @@ -1011,7 +1010,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { }); } - if !found_link_attr { vec::push(attrs, synthesize_link_attr(ecx, ~[])); } + if !found_link_attr { attrs.push(synthesize_link_attr(ecx, ~[])); } return attrs; } @@ -1031,7 +1030,7 @@ fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::Writer, let dep = {cnum: key, name: ecx.tcx.sess.ident_of(val.name), vers: decoder::get_crate_vers(val.data), hash: decoder::get_crate_hash(val.data)}; - vec::push(deps, dep); + deps.push(dep); }; // Sort by cnum diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index 77d06bd2d29..63370b09321 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -39,15 +39,15 @@ fn mk_filesearch(maybe_sysroot: Option, fn lib_search_paths() -> ~[Path] { let mut paths = self.addl_lib_search_paths; - vec::push(paths, - make_target_lib_path(&self.sysroot, - self.target_triple)); + paths.push( + make_target_lib_path(&self.sysroot, + self.target_triple)); match get_cargo_lib_path_nearest() { - result::Ok(p) => vec::push(paths, p), + result::Ok(p) => paths.push(p), result::Err(_) => () } match get_cargo_lib_path() { - result::Ok(p) => vec::push(paths, p), + result::Ok(p) => paths.push(p), result::Err(_) => () } paths diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index b2c28fafd4c..2ccaccf17a5 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -90,7 +90,7 @@ fn find_library_crate_aux(cx: ctxt, option::None::<()> } else { debug!("found %s with matching metadata", path.to_str()); - vec::push(matches, {ident: path.to_str(), data: cvec}); + matches.push({ident: path.to_str(), data: cvec}); option::None::<()> } } diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index 5cf24aef558..f3fa0e3f350 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -84,7 +84,7 @@ fn parse_ret_ty(st: @pstate, conv: conv_did) -> (ast::ret_style, ty::t) { fn parse_path(st: @pstate) -> @ast::path { let mut idents: ~[ast::ident] = ~[]; fn is_last(c: char) -> bool { return c == '(' || c == ':'; } - vec::push(idents, parse_ident_(st, is_last)); + idents.push(parse_ident_(st, is_last)); loop { match peek(st) { ':' => { next(st); next(st); } @@ -93,7 +93,7 @@ fn parse_path(st: @pstate) -> @ast::path { return @{span: ast_util::dummy_sp(), global: false, idents: idents, rp: None, types: ~[]}; - } else { vec::push(idents, parse_ident_(st, is_last)); } + } else { idents.push(parse_ident_(st, is_last)); } } } }; @@ -136,7 +136,7 @@ fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs { assert next(st) == '['; let mut params: ~[ty::t] = ~[]; - while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); } + while peek(st) != ']' { params.push(parse_ty(st, conv)); } st.pos = st.pos + 1u; return {self_r: self_r, @@ -273,7 +273,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { let mut fields: ~[ty::field] = ~[]; while peek(st) != ']' { let name = st.tcx.sess.ident_of(parse_str(st, '=')); - vec::push(fields, {ident: name, mt: parse_mt(st, conv)}); + fields.push({ident: name, mt: parse_mt(st, conv)}); } st.pos = st.pos + 1u; return ty::mk_rec(st.tcx, fields); @@ -281,7 +281,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { 'T' => { assert (next(st) == '['); let mut params = ~[]; - while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); } + while peek(st) != ']' { params.push(parse_ty(st, conv)); } st.pos = st.pos + 1u; return ty::mk_tup(st.tcx, params); } @@ -348,7 +348,7 @@ fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt { fn parse_def(st: @pstate, conv: conv_did) -> ast::def_id { let mut def = ~[]; - while peek(st) != '|' { vec::push(def, next_byte(st)); } + while peek(st) != '|' { def.push(next_byte(st)); } st.pos = st.pos + 1u; return conv(parse_def_id(def)); } @@ -412,7 +412,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::FnTy { let mut inputs: ~[ty::arg] = ~[]; while peek(st) != ']' { let mode = parse_mode(st); - vec::push(inputs, {mode: mode, ty: parse_ty(st, conv)}); + inputs.push({mode: mode, ty: parse_ty(st, conv)}); } st.pos += 1u; // eat the ']' let (ret_style, ret_ty) = parse_ret_ty(st, conv); @@ -464,7 +464,7 @@ fn parse_bounds_data(data: @~[u8], start: uint, fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] { let mut bounds = ~[]; loop { - vec::push(bounds, match next(st) { + bounds.push(match next(st) { 'S' => ty::bound_send, 'C' => ty::bound_copy, 'K' => ty::bound_const, diff --git a/src/rustc/middle/capture.rs b/src/rustc/middle/capture.rs index 1e885605171..618d43e121a 100644 --- a/src/rustc/middle/capture.rs +++ b/src/rustc/middle/capture.rs @@ -122,6 +122,6 @@ fn compute_capture_vars(tcx: ty::ctxt, } let mut result = ~[]; - for cap_map.each_value |cap_var| { vec::push(result, cap_var); } + for cap_map.each_value |cap_var| { result.push(cap_var); } return result; } diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index 32801ed760c..54f415857ba 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -67,7 +67,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) { } _ => () } - if arm.guard.is_none() { vec::push(seen, v); } + if arm.guard.is_none() { seen.push(v); } } } } @@ -269,7 +269,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option { let mut found = ~[]; for m.each |r| { do option::iter(&pat_ctor_id(tcx, r[0])) |id| { - if !vec::contains(found, id) { vec::push(found, id); } + if !vec::contains(found, id) { found.push(id); } } } let variants = ty::enum_variants(tcx, eid); diff --git a/src/rustc/middle/freevars.rs b/src/rustc/middle/freevars.rs index 251ef2c89b7..7e925d7d8d8 100644 --- a/src/rustc/middle/freevars.rs +++ b/src/rustc/middle/freevars.rs @@ -63,7 +63,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk) if i == depth { // Made it to end of loop let dnum = ast_util::def_id_of_def(def).node; if !seen.contains_key(dnum) { - vec::push(*refs, @{def:def, span:expr.span}); + refs.push(@{def:def, span:expr.span}); seen.insert(dnum, ()); } } diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 4f9045ec77e..7d911f7d05a 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -42,17 +42,17 @@ fn kind_to_str(k: kind) -> ~str { let mut kinds = ~[]; if ty::kind_lteq(kind_const(), k) { - vec::push(kinds, ~"const"); + kinds.push(~"const"); } if ty::kind_can_be_copied(k) { - vec::push(kinds, ~"copy"); + kinds.push(~"copy"); } if ty::kind_can_be_sent(k) { - vec::push(kinds, ~"send"); + kinds.push(~"send"); } else if ty::kind_is_owned(k) { - vec::push(kinds, ~"owned"); + kinds.push(~"owned"); } str::connect(kinds, ~" ") diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index ff77a598d27..b92f8e8441f 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -288,7 +288,7 @@ impl ctxt { for metas.each |meta| { match meta.node { ast::meta_word(lintname) => { - vec::push(triples, (*meta, *level, lintname)); + triples.push((*meta, *level, lintname)); } _ => { self.sess.span_err( diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index a4c9b5f4b35..b39b7914905 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -302,7 +302,7 @@ fn IrMaps(tcx: ty::ctxt, method_map: typeck::method_map, impl IrMaps { fn add_live_node(lnk: LiveNodeKind) -> LiveNode { let ln = LiveNode(self.num_live_nodes); - vec::push(self.lnks, lnk); + self.lnks.push(lnk); self.num_live_nodes += 1u; debug!("%s is of kind %?", ln.to_str(), lnk); @@ -319,7 +319,7 @@ impl IrMaps { fn add_variable(vk: VarKind) -> Variable { let v = Variable(self.num_vars); - vec::push(self.var_kinds, vk); + self.var_kinds.push(vk); self.num_vars += 1u; match vk { @@ -540,7 +540,7 @@ fn visit_expr(expr: @expr, &&self: @IrMaps, vt: vt<@IrMaps>) { cap_move | cap_drop => true, // var must be dead afterwards cap_copy | cap_ref => false // var can still be used }; - vec::push(call_caps, {ln: cv_ln, is_move: is_move, rv: rv}); + call_caps.push({ln: cv_ln, is_move: is_move, rv: rv}); } None => {} } diff --git a/src/rustc/middle/pat_util.rs b/src/rustc/middle/pat_util.rs index e67b85b869c..006065988b9 100644 --- a/src/rustc/middle/pat_util.rs +++ b/src/rustc/middle/pat_util.rs @@ -54,6 +54,6 @@ fn pat_bindings(dm: resolve::DefMap, pat: @pat, fn pat_binding_ids(dm: resolve::DefMap, pat: @pat) -> ~[node_id] { let mut found = ~[]; - pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| vec::push(found, b_id) ); + pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| found.push(b_id) ); return found; } diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index ae1c739b26b..ff708b7f4ef 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -141,7 +141,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, match region_map.find(scope) { None => return result, Some(superscope) => { - vec::push(result, superscope); + result.push(superscope); scope = superscope; } } diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 7380a217ebe..99d98c52f95 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -2897,7 +2897,7 @@ impl Resolver { if reexport { ~"reexport" } else { ~"export"}, self.session.str_of(ident), def_id_of_def(d.def)); - vec::push(*exports2, Export2 { + exports2.push(Export2 { reexport: reexport, name: self.session.str_of(ident), def_id: def_id_of_def(d.def) @@ -2949,7 +2949,7 @@ impl Resolver { for %?", self.session.str_of(name), module_.def_id); - vec::push(*exports2, Export2 { + exports2.push(Export2 { reexport: false, name: self.session.str_of(name), def_id: def_id_of_def(target_def) @@ -2960,7 +2960,7 @@ impl Resolver { %?", self.session.str_of(name), module_.def_id); - vec::push(*exports2, Export2 { + exports2.push(Export2 { reexport: true, name: self.session.str_of(name), def_id: def_id_of_def(target_def) diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 11b694bcb1d..165ca8e2fc4 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -305,7 +305,7 @@ fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r], _ => {} } - vec::push(result, @Match {pats: pats, data: br.data}); + result.push(@Match {pats: pats, data: br.data}); } None => () } @@ -398,8 +398,8 @@ fn enter_rec_or_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint, let mut pats = ~[]; for vec::each(fields) |fname| { match fpats.find(|p| p.ident == *fname) { - None => vec::push(pats, dummy), - Some(pat) => vec::push(pats, pat.pat) + None => pats.push(dummy), + Some(pat) => pats.push(pat.pat) } } Some(pats) @@ -582,7 +582,7 @@ fn collect_record_or_struct_fields(m: &[@Match], col: uint) -> ~[ast::ident] { for field_pats.each |field_pat| { let field_ident = field_pat.ident; if !vec::any(*idents, |x| x == field_ident) { - vec::push(*idents, field_ident); + idents.push(field_ident); } } } @@ -1162,9 +1162,9 @@ fn trans_alt_inner(scope_cx: block, let arm_data = @ArmData {bodycx: body, arm: arm, bindings_map: bindings_map}; - vec::push(arm_datas, arm_data); + arm_datas.push(arm_data); for vec::each(arm.pats) |p| { - vec::push(matches, @Match {pats: ~[*p], data: arm_data}); + matches.push(@Match {pats: ~[*p], data: arm_data}); } } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index b29fac0fa2f..94b09a30e4b 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -76,7 +76,7 @@ impl @crate_ctxt: get_insn_ctxt { fn insn_ctxt(s: &str) -> icx_popper { debug!("new insn_ctxt: %s", s); if self.sess.count_llvm_insns() { - vec::push(*self.stats.llvm_insn_ctxt, str::from_slice(s)); + self.stats.llvm_insn_ctxt.push(str::from_slice(s)); } icx_popper(self) } @@ -98,7 +98,7 @@ fn log_fn_time(ccx: @crate_ctxt, name: ~str, start: time::Timespec, end: time::Timespec) { let elapsed = 1000 * ((end.sec - start.sec) as int) + ((end.nsec as int) - (start.nsec as int)) / 1000000; - vec::push(*ccx.stats.fn_times, {ident: name, time: elapsed}); + ccx.stats.fn_times.push({ident: name, time: elapsed}); } fn decl_fn(llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv, @@ -1153,7 +1153,7 @@ fn cleanup_and_leave(bcx: block, upto: Option, } let sub_cx = sub_block(bcx, ~"cleanup"); Br(bcx, sub_cx.llbb); - vec::push(inf.cleanup_paths, {target: leave, dest: sub_cx.llbb}); + inf.cleanup_paths.push({target: leave, dest: sub_cx.llbb}); bcx = trans_block_cleanups_(sub_cx, block_cleanups(cur), is_lpad); } _ => () @@ -2001,7 +2001,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, let llenvarg = llvm::LLVMGetParam(llfdecl, 1 as c_uint); let mut args = ~[lloutputarg, llenvarg]; if takes_argv { - vec::push(args, llvm::LLVMGetParam(llfdecl, 2 as c_uint)); + args.push(llvm::LLVMGetParam(llfdecl, 2 as c_uint)); } Call(bcx, main_llfn, args); @@ -2451,10 +2451,10 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef { for ccx.module_data.each |key, val| { let elt = C_struct(~[p2i(ccx, C_cstr(ccx, key)), p2i(ccx, val)]); - vec::push(elts, elt); + elts.push(elt); } let term = C_struct(~[C_int(ccx, 0), C_int(ccx, 0)]); - vec::push(elts, term); + elts.push(term); llvm::LLVMSetInitializer(map, C_array(elttype, elts)); return map; } @@ -2492,10 +2492,10 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) { let cr = str::as_c_str(nm, |buf| { llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf) }); - vec::push(subcrates, p2i(ccx, cr)); + subcrates.push(p2i(ccx, cr)); i += 1; } - vec::push(subcrates, C_int(ccx, 0)); + subcrates.push(C_int(ccx, 0)); let llannihilatefn; let annihilate_def_id = ccx.tcx.lang_items.annihilate_fn.get(); diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index 865374054e6..070132b4b18 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -435,7 +435,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { // XXX: Use a small-vector optimization to avoid allocations here. fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef { let mut v: ~[ValueRef] = ~[]; - for vec::each(ixs) |i| { vec::push(v, C_i32(*i as i32)); } + for vec::each(ixs) |i| { v.push(C_i32(*i as i32)); } count_insn(cx, "gepi"); return InBoundsGEP(cx, base, v); } diff --git a/src/rustc/middle/trans/callee.rs b/src/rustc/middle/trans/callee.rs index 3050297b360..470d4dbb4ab 100644 --- a/src/rustc/middle/trans/callee.rs +++ b/src/rustc/middle/trans/callee.rs @@ -478,10 +478,10 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t, } } }; - vec::push(llargs, llretslot); + llargs.push(llretslot); // Arg 1: Env (closure-bindings / self value) - vec::push(llargs, llenv); + llargs.push(llenv); // ... then explicit args. @@ -497,11 +497,11 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t, if i == last { ret_flag } else { None }, autoref_arg) }); - vec::push(llargs, arg_val); + llargs.push(arg_val); } } ArgVals(vs) => { - vec::push_all(llargs, vs); + llargs.push_all(vs); } } @@ -622,7 +622,7 @@ fn trans_arg_expr(bcx: block, // However, we must cleanup should we fail before the // callee is actually invoked. scratch.add_clean(bcx); - vec::push(*temp_cleanups, scratch.val); + temp_cleanups.push(scratch.val); match arg_datum.appropriate_mode() { ByValue => { diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 38526c223a1..7b071866136 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -259,16 +259,16 @@ fn build_closure(bcx0: block, match cap_var.mode { capture::cap_ref => { assert ck == ty::ck_block; - vec::push(env_vals, EnvValue {action: EnvRef, - datum: datum}); + env_vals.push(EnvValue {action: EnvRef, + datum: datum}); } capture::cap_copy => { - vec::push(env_vals, EnvValue {action: EnvStore, - datum: datum}); + env_vals.push(EnvValue {action: EnvStore, + datum: datum}); } capture::cap_move => { - vec::push(env_vals, EnvValue {action: EnvMove, - datum: datum}); + env_vals.push(EnvValue {action: EnvMove, + datum: datum}); } capture::cap_drop => { bcx = datum.drop_val(bcx); @@ -283,8 +283,8 @@ fn build_closure(bcx0: block, // Flag indicating we have returned (a by-ref bool): let flag_datum = Datum {val: flagptr, ty: ty::mk_bool(tcx), mode: ByRef, source: FromLvalue}; - vec::push(env_vals, EnvValue {action: EnvRef, - datum: flag_datum}); + env_vals.push(EnvValue {action: EnvRef, + datum: flag_datum}); // Return value (we just pass a by-ref () and cast it later to // the right thing): @@ -295,8 +295,8 @@ fn build_closure(bcx0: block, let ret_casted = PointerCast(bcx, ret_true, T_ptr(T_nil())); let ret_datum = Datum {val: ret_casted, ty: ty::mk_nil(tcx), mode: ByRef, source: FromLvalue}; - vec::push(env_vals, EnvValue {action: EnvRef, - datum: ret_datum}); + env_vals.push(EnvValue {action: EnvRef, + datum: ret_datum}); } return store_environment(bcx, env_vals, ck); diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index fc74e5e0e4d..0df63e40acf 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -348,9 +348,9 @@ fn add_clean(bcx: block, val: ValueRef, t: ty::t) { let {root, rooted} = root_for_cleanup(bcx, val, t); let cleanup_type = cleanup_type(bcx.tcx(), t); do in_scope_cx(bcx) |info| { - vec::push(info.cleanups, - clean(|a| glue::drop_ty_root(a, root, rooted, t), - cleanup_type)); + info.cleanups.push( + clean(|a| glue::drop_ty_root(a, root, rooted, t), + cleanup_type)); scope_clean_changed(info); } } @@ -362,9 +362,9 @@ fn add_clean_temp_immediate(cx: block, val: ValueRef, ty: ty::t) { ty_to_str(cx.ccx().tcx, ty)); let cleanup_type = cleanup_type(cx.tcx(), ty); do in_scope_cx(cx) |info| { - vec::push(info.cleanups, - clean_temp(val, |a| glue::drop_ty_immediate(a, val, ty), - cleanup_type)); + info.cleanups.push( + clean_temp(val, |a| glue::drop_ty_immediate(a, val, ty), + cleanup_type)); scope_clean_changed(info); } } @@ -376,9 +376,9 @@ fn add_clean_temp_mem(bcx: block, val: ValueRef, t: ty::t) { let {root, rooted} = root_for_cleanup(bcx, val, t); let cleanup_type = cleanup_type(bcx.tcx(), t); do in_scope_cx(bcx) |info| { - vec::push(info.cleanups, - clean_temp(val, |a| glue::drop_ty_root(a, root, rooted, t), - cleanup_type)); + info.cleanups.push( + clean_temp(val, |a| glue::drop_ty_root(a, root, rooted, t), + cleanup_type)); scope_clean_changed(info); } } @@ -388,8 +388,8 @@ fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) { heap_exchange => |a| glue::trans_unique_free(a, ptr) }; do in_scope_cx(cx) |info| { - vec::push(info.cleanups, clean_temp(ptr, free_fn, - normal_exit_and_unwind)); + info.cleanups.push(clean_temp(ptr, free_fn, + normal_exit_and_unwind)); scope_clean_changed(info); } } @@ -1050,7 +1050,7 @@ fn C_postr(s: ~str) -> ValueRef { fn C_zero_byte_arr(size: uint) -> ValueRef unsafe { let mut i = 0u; let mut elts: ~[ValueRef] = ~[]; - while i < size { vec::push(elts, C_u8(0u)); i += 1u; } + while i < size { elts.push(C_u8(0u)); i += 1u; } return llvm::LLVMConstArray(T_i8(), vec::raw::to_ptr(elts), elts.len() as c_uint); } diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index 26a83951c01..6cd4b49fa3b 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -383,7 +383,7 @@ fn create_derived_type(type_tag: int, file: ValueRef, name: ~str, line: int, fn add_member(cx: @struct_ctxt, name: ~str, line: int, size: int, align: int, ty: ValueRef) { - vec::push(cx.members, create_derived_type(MemberTag, cx.file, name, line, + cx.members.push(create_derived_type(MemberTag, cx.file, name, line, size * 8, align * 8, cx.total_size, ty)); cx.total_size += size * 8; @@ -529,7 +529,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) ty::ty_rec(fields) { let fs = ~[]; for field in fields { - vec::push(fs, {node: {ident: field.ident, + fs.push({node: {ident: field.ident, mt: {ty: t_to_ty(cx, field.mt.ty, span), mutbl: field.mt.mutbl}}, span: span}); diff --git a/src/rustc/middle/trans/expr.rs b/src/rustc/middle/trans/expr.rs index 17a1ff112cd..dafaebef9e0 100644 --- a/src/rustc/middle/trans/expr.rs +++ b/src/rustc/middle/trans/expr.rs @@ -993,7 +993,7 @@ fn trans_rec_or_struct(bcx: block, let dest = GEPi(bcx, addr, struct_field(ix)); bcx = trans_into(bcx, field.node.expr, SaveIn(dest)); add_clean_temp_mem(bcx, dest, field_tys[ix].mt.ty); - vec::push(temp_cleanups, dest); + temp_cleanups.push(dest); } // copy over any remaining fields from the base (for @@ -1046,7 +1046,7 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: Dest) -> block { let e_ty = expr_ty(bcx, *e); bcx = trans_into(bcx, *e, SaveIn(dest)); add_clean_temp_mem(bcx, dest, e_ty); - vec::push(temp_cleanups, dest); + temp_cleanups.push(dest); } for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, *cleanup); diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index e775b3fd746..f1077912fec 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -297,21 +297,21 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef { while i < e { match cls[i] { integer_class => { - vec::push(tys, T_i64()); + tys.push(T_i64()); } sse_fv_class => { let vec_len = llvec_len(vec::tailn(cls, i + 1u)) * 2u; let vec_ty = llvm::LLVMVectorType(T_f32(), vec_len as c_uint); - vec::push(tys, vec_ty); + tys.push(vec_ty); i += vec_len; loop; } sse_fs_class => { - vec::push(tys, T_f32()); + tys.push(T_f32()); } sse_ds_class => { - vec::push(tys, T_f64()); + tys.push(T_f64()); } _ => fail ~"llregtype: unhandled class" } @@ -378,8 +378,8 @@ fn x86_64_tys(atys: ~[TypeRef], let mut attrs = ~[]; for vec::each(atys) |t| { let (ty, attr) = x86_64_ty(*t, is_pass_byval, ByValAttribute); - vec::push(arg_tys, ty); - vec::push(attrs, attr); + arg_tys.push(ty); + attrs.push(attr); } let mut (ret_ty, ret_attr) = x86_64_ty(rty, is_ret_bysret, StructRetAttribute); @@ -619,7 +619,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, } else { load_inbounds(bcx, llargbundle, [0u, i]) }; - vec::push(llargvals, llargval); + llargvals.push(llargval); i += 1u; } } @@ -627,7 +627,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, while i < n { let llargval = load_inbounds(bcx, llargbundle, [0u, i]); - vec::push(llargvals, llargval); + llargvals.push(llargval); i += 1u; } } @@ -1041,12 +1041,12 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let mut i = 0u; let n = vec::len(tys.arg_tys); let llretptr = load_inbounds(bcx, llargbundle, ~[0u, n]); - vec::push(llargvals, llretptr); + llargvals.push(llretptr); let llenvptr = C_null(T_opaque_box_ptr(bcx.ccx())); - vec::push(llargvals, llenvptr); + llargvals.push(llenvptr); while i < n { let llargval = load_inbounds(bcx, llargbundle, ~[0u, i]); - vec::push(llargvals, llargval); + llargvals.push(llargval); i += 1u; } return llargvals; diff --git a/src/rustc/middle/trans/monomorphize.rs b/src/rustc/middle/trans/monomorphize.rs index 8a68ef4823b..40558e72c80 100644 --- a/src/rustc/middle/trans/monomorphize.rs +++ b/src/rustc/middle/trans/monomorphize.rs @@ -246,7 +246,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], for vec::each(*bounds) |bound| { match *bound { ty::bound_trait(_) => { - vec::push(v, meth::vtable_id(ccx, vts[i])); + v.push(meth::vtable_id(ccx, vts[i])); i += 1u; } _ => () diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 10f93626280..e1eae115694 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -332,7 +332,7 @@ fn write_content(bcx: block, bcx = expr::trans_into(bcx, *element, SaveIn(lleltptr)); add_clean_temp_mem(bcx, lleltptr, vt.unit_ty); - vec::push(temp_cleanups, lleltptr); + temp_cleanups.push(lleltptr); } for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, *cleanup); @@ -369,7 +369,7 @@ fn write_content(bcx: block, bcx = tmpdatum.move_to(bcx, INIT, lleltptr); } add_clean_temp_mem(bcx, lleltptr, vt.unit_ty); - vec::push(temp_cleanups, lleltptr); + temp_cleanups.push(lleltptr); } for vec::each(temp_cleanups) |cleanup| { diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index d9032f8ce90..99555d5b294 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -39,13 +39,13 @@ fn type_of_fn(cx: @crate_ctxt, inputs: ~[ty::arg], let mut atys: ~[TypeRef] = ~[]; // Arg 0: Output pointer. - vec::push(atys, T_ptr(type_of(cx, output))); + atys.push(T_ptr(type_of(cx, output))); // Arg 1: Environment - vec::push(atys, T_opaque_box_ptr(cx)); + atys.push(T_opaque_box_ptr(cx)); // ... then explicit args. - vec::push_all(atys, type_of_explicit_args(cx, inputs)); + atys.push_all(type_of_explicit_args(cx, inputs)); return T_fn(atys, llvm::LLVMVoidType()); } @@ -151,7 +151,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { let mut tys: ~[TypeRef] = ~[]; for vec::each(fields) |f| { let mt_ty = f.mt.ty; - vec::push(tys, type_of(cx, mt_ty)); + tys.push(type_of(cx, mt_ty)); } // n.b.: introduce an extra layer of indirection to match @@ -164,7 +164,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { ty::ty_tup(elts) => { let mut tys = ~[]; for vec::each(elts) |elt| { - vec::push(tys, type_of(cx, *elt)); + tys.push(type_of(cx, *elt)); } T_struct(tys) } diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index f256b4b76cd..ed71d27451c 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -2243,10 +2243,10 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { } ty_class(did, ref substs) => { - vec::push(*seen, did); - let r = vec::any(class_items_as_fields(cx, did, substs), - |f| type_requires(cx, seen, r_ty, f.mt.ty)); - vec::pop(*seen); + seen.push(did); + let r = vec::any(class_items_as_fields(cx, did, substs), + |f| type_requires(cx, seen, r_ty, f.mt.ty)); + vec::pop(*seen); r } @@ -2258,18 +2258,18 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { false } - ty_enum(did, ref substs) => { - vec::push(*seen, did); - let vs = enum_variants(cx, did); - let r = vec::len(*vs) > 0u && vec::all(*vs, |variant| { - vec::any(variant.args, |aty| { - let sty = subst(cx, substs, aty); - type_requires(cx, seen, r_ty, sty) - }) - }); - vec::pop(*seen); - r - } + ty_enum(did, ref substs) => { + seen.push(did); + let vs = enum_variants(cx, did); + let r = vec::len(*vs) > 0u && vec::all(*vs, |variant| { + vec::any(variant.args, |aty| { + let sty = subst(cx, substs, aty); + type_requires(cx, seen, r_ty, sty) + }) + }); + vec::pop(*seen); + r + } }; debug!("subtypes_require(%s, %s)? %b", @@ -3036,7 +3036,7 @@ fn param_tys_in_type(ty: t) -> ~[param_ty] { do walk_ty(ty) |ty| { match get(ty).sty { ty_param(p) => { - vec::push(rslt, p); + rslt.push(p); } _ => () } @@ -3052,7 +3052,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) { let mut rslt = ~[]; do walk_ty(ty) |ty| { match get(ty).sty { - ty_infer(TyVar(v)) => vec::push(rslt, v), + ty_infer(TyVar(v)) => rslt.push(v), _ => () } } @@ -3704,10 +3704,10 @@ fn class_field_tys(fields: ~[@struct_field]) -> ~[field_ty] { for fields.each |field| { match field.node.kind { named_field(ident, mutability, visibility) => { - vec::push(rslt, {ident: ident, - id: ast_util::local_def(field.node.id), - vis: visibility, - mutability: mutability}); + rslt.push({ident: ident, + id: ast_util::local_def(field.node.id), + vis: visibility, + mutability: mutability}); } unnamed_field => {} } @@ -3747,7 +3747,7 @@ fn class_item_fields(cx:ctxt, for lookup_class_fields(cx, did).each |f| { // consider all instance vars mut, because the // constructor may mutate all vars - vec::push(rslt, {ident: f.ident, mt: + rslt.push({ident: f.ident, mt: {ty: lookup_field_type(cx, did, f.id, substs), mutbl: frob_mutability(f.mutability)}}); } diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 8d2384cd530..bc7711c059b 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -818,7 +818,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> (ty::t, uint) { if vec::contains(enum_dids, did) { return (t1, autoderefs); } - vec::push(enum_dids, did); + enum_dids.push(did); } _ => { /*ok*/ } } @@ -2029,8 +2029,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let name = class_field.ident; let (_, seen) = class_field_map.get(name); if !seen { - vec::push(missing_fields, - ~"`" + tcx.sess.str_of(name) + ~"`"); + missing_fields.push( + ~"`" + tcx.sess.str_of(name) + ~"`"); } } @@ -2298,7 +2298,7 @@ fn check_enum_variants(ccx: @crate_ctxt, ccx.tcx.sess.span_err(v.span, ~"discriminator value already exists"); } - vec::push(*disr_vals, *disr_val); + disr_vals.push(*disr_val); let ctor_ty = ty::node_id_to_type(ccx.tcx, v.node.id); let arg_tys; @@ -2321,7 +2321,8 @@ fn check_enum_variants(ccx: @crate_ctxt, match arg_tys { None => {} Some(arg_tys) => { - vec::push(*variants, @{args: arg_tys, ctor_ty: ctor_ty, + variants.push( + @{args: arg_tys, ctor_ty: ctor_ty, name: v.node.name, id: local_def(v.node.id), disr_val: this_disr_val}); } diff --git a/src/rustc/middle/typeck/check/regionmanip.rs b/src/rustc/middle/typeck/check/regionmanip.rs index d969ce908f0..aec42f77048 100644 --- a/src/rustc/middle/typeck/check/regionmanip.rs +++ b/src/rustc/middle/typeck/check/regionmanip.rs @@ -27,13 +27,13 @@ fn replace_bound_regions_in_fn_ty( let region = ty::re_bound(ty::br_self); let ty = ty::mk_rptr(tcx, region, { ty: ty::mk_self(tcx), mutbl: m }); - vec::push(all_tys, ty); + all_tys.push(ty); } _ => {} } - for self_ty.each |t| { vec::push(all_tys, *t) } + for self_ty.each |t| { all_tys.push(*t) } debug!("replace_bound_regions_in_fn_ty(self_info.self_ty=%?, fn_ty=%s, \ all_tys=%?)", diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index d48f5b9c070..453559e5e42 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -51,8 +51,8 @@ fn lookup_vtables(fcx: @fn_ctxt, match *bound { ty::bound_trait(i_ty) => { let i_ty = ty::subst(tcx, substs, i_ty); - vec::push(result, lookup_vtable(fcx, expr, *ty, i_ty, - allow_unsafe, is_early)); + result.push(lookup_vtable(fcx, expr, *ty, i_ty, + allow_unsafe, is_early)); } _ => () } @@ -331,9 +331,9 @@ fn lookup_vtable(fcx: @fn_ctxt, // the impl as well as the resolved list // of type substitutions for the target // trait. - vec::push(found, - vtable_static(im.did, substs_f.tps, - subres)); + found.push( + vtable_static(im.did, substs_f.tps, + subres)); } } } diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index a70e5f600d3..33a26c8daf4 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -94,7 +94,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) let mut new_tps = ~[]; for substs.tps.each |subst| { match resolve_type_vars_in_type(fcx, sp, *subst) { - Some(t) => vec::push(new_tps, t), + Some(t) => new_tps.push(t), None => { wbcx.success = false; return None; } } } diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index 77c665755c3..907cdb4f5ec 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -198,7 +198,7 @@ impl CoherenceChecker { existing trait", sess.str_of(mi.ident)); let mut method_infos = mis; - push(method_infos, mi); + method_infos.push(mi); pmm.insert(item.id, method_infos); } None => { @@ -547,7 +547,7 @@ impl CoherenceChecker { debug!( "(creating impl) adding provided method `%s` to impl", sess.str_of(provided_method.ident)); - push(methods, *provided_method); + methods.push(*provided_method); } } @@ -559,8 +559,7 @@ impl CoherenceChecker { let mut methods = ~[]; for ast_methods.each |ast_method| { - push(methods, - method_to_MethodInfo(*ast_method)); + methods.push(method_to_MethodInfo(*ast_method)); } // For each trait that the impl implements, see what @@ -619,7 +618,7 @@ impl CoherenceChecker { -> @Impl { let mut methods = ~[]; for struct_def.methods.each |ast_method| { - push(methods, @{ + methods.push(@{ did: local_def(ast_method.id), n_tps: ast_method.tps.len(), ident: ast_method.ident, diff --git a/src/rustc/middle/typeck/infer/region_var_bindings.rs b/src/rustc/middle/typeck/infer/region_var_bindings.rs index c0312872488..8eabb2c0787 100644 --- a/src/rustc/middle/typeck/infer/region_var_bindings.rs +++ b/src/rustc/middle/typeck/infer/region_var_bindings.rs @@ -830,7 +830,7 @@ impl RegionVarBindings { // It would be nice to write this using map(): let mut edges = vec::with_capacity(num_edges); for self.constraints.each_ref |constraint, span| { - vec::push(edges, GraphEdge { + edges.push(GraphEdge { next_edge: [mut uint::max_value, uint::max_value], constraint: *constraint, span: *span @@ -1201,13 +1201,13 @@ impl RegionVarBindings { Outgoing => to_vid }; if set.insert(*vid, ()) { - vec::push(stack, vid); + stack.push(vid); } } ConstrainRegSubVar(region, _) => { assert dir == Incoming; - vec::push(result, SpannedRegion { + result.push(SpannedRegion { region: region, span: edge.span }); @@ -1215,7 +1215,7 @@ impl RegionVarBindings { ConstrainVarSubReg(_, region) => { assert dir == Outgoing; - vec::push(result, SpannedRegion { + result.push(SpannedRegion { region: region, span: edge.span }); diff --git a/src/rustc/middle/typeck/infer/resolve.rs b/src/rustc/middle/typeck/infer/resolve.rs index 5d748efc332..a366a2ef1c7 100644 --- a/src/rustc/middle/typeck/infer/resolve.rs +++ b/src/rustc/middle/typeck/infer/resolve.rs @@ -174,7 +174,7 @@ impl resolve_state { self.err = Some(cyclic_ty(vid)); return ty::mk_var(self.infcx.tcx, vid); } else { - vec::push(self.v_seen, vid); + self.v_seen.push(vid); let tcx = self.infcx.tcx; // Nonobvious: prefer the most specific type diff --git a/src/rustc/middle/typeck/infer/unify.rs b/src/rustc/middle/typeck/infer/unify.rs index 500a4d5b419..7ccbaa40ada 100644 --- a/src/rustc/middle/typeck/infer/unify.rs +++ b/src/rustc/middle/typeck/infer/unify.rs @@ -51,7 +51,7 @@ impl infer_ctxt { +new_v: var_value) { let old_v = vb.vals.get(vid.to_uint()); - vec::push(vb.bindings, (vid, old_v)); + vb.bindings.push((vid, old_v)); vb.vals.insert(vid.to_uint(), new_v); debug!("Updating variable %s from %s to %s", diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index 4c033515b9a..37cc016e8ea 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -36,7 +36,7 @@ fn field_expr(f: ast::field) -> @ast::expr { return f.node.expr; } fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] { let mut es = ~[]; - for fields.each |f| { vec::push(es, f.node.expr); } + for fields.each |f| { es.push(f.node.expr); } return es; } diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 0498a0f9541..0df5827ed3d 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -286,7 +286,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { } s += ~"("; let mut strs = ~[]; - for inputs.each |a| { vec::push(strs, fn_input_to_str(cx, *a)); } + for inputs.each |a| { strs.push(fn_input_to_str(cx, *a)); } s += str::connect(strs, ~", "); s += ~")"; if ty::get(output).sty != ty_nil { @@ -342,12 +342,12 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { ty_type => ~"type", ty_rec(elems) => { let mut strs: ~[~str] = ~[]; - for elems.each |fld| { vec::push(strs, field_to_str(cx, *fld)); } + for elems.each |fld| { strs.push(field_to_str(cx, *fld)); } ~"{" + str::connect(strs, ~",") + ~"}" } ty_tup(elems) => { let mut strs = ~[]; - for elems.each |elem| { vec::push(strs, ty_to_str(cx, *elem)); } + for elems.each |elem| { strs.push(ty_to_str(cx, *elem)); } ~"(" + str::connect(strs, ~",") + ~")" } ty_fn(ref f) => { diff --git a/src/rustdoc/extract.rs b/src/rustdoc/extract.rs index 448e699fc8d..7b34a327bee 100644 --- a/src/rustdoc/extract.rs +++ b/src/rustdoc/extract.rs @@ -140,7 +140,7 @@ fn nmoddoc_from_mod( let ItemDoc = mk_itemdoc(item.id, to_str(item.ident)); match item.node { ast::foreign_item_fn(*) => { - vec::push(fns, fndoc_from_fn(ItemDoc)); + fns.push(fndoc_from_fn(ItemDoc)); } ast::foreign_item_const(*) => {} // XXX: Not implemented. } diff --git a/src/rustdoc/path_pass.rs b/src/rustdoc/path_pass.rs index 84b542f6bf0..96ed269a7e9 100644 --- a/src/rustdoc/path_pass.rs +++ b/src/rustdoc/path_pass.rs @@ -43,7 +43,7 @@ fn fold_item(fold: fold::Fold, doc: doc::ItemDoc) -> doc::ItemDoc { fn fold_mod(fold: fold::Fold, doc: doc::ModDoc) -> doc::ModDoc { let is_topmod = doc.id() == ast::crate_node_id; - if !is_topmod { vec::push(fold.ctxt.path, doc.name()); } + if !is_topmod { fold.ctxt.path.push(doc.name()); } let doc = fold::default_any_fold_mod(fold, doc); if !is_topmod { vec::pop(fold.ctxt.path); } @@ -54,7 +54,7 @@ fn fold_mod(fold: fold::Fold, doc: doc::ModDoc) -> doc::ModDoc { } fn fold_nmod(fold: fold::Fold, doc: doc::NmodDoc) -> doc::NmodDoc { - vec::push(fold.ctxt.path, doc.name()); + fold.ctxt.path.push(doc.name()); let doc = fold::default_seq_fold_nmod(fold, doc); vec::pop(fold.ctxt.path); diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index a7312cc8320..9454ef7aec7 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -47,7 +47,7 @@ fn shift_push() { let mut v2 = ~[]; while v1.len() > 0 { - vec::push(v2, vec::shift(v1)); + v2.push(vec::shift(v1)); } } @@ -122,11 +122,11 @@ fn vec_push_all() { for uint::range(0, 1500) |i| { let mut rv = vec::from_elem(r.gen_uint_range(0, i + 1), i); if r.gen_bool() { - vec::push_all(v, rv); + v.push_all(rv); } else { v <-> rv; - vec::push_all(v, rv); + v.push_all(rv); } } } diff --git a/src/test/bench/core-vec-append.rs b/src/test/bench/core-vec-append.rs index d708ac9eaa7..2b9216876b4 100644 --- a/src/test/bench/core-vec-append.rs +++ b/src/test/bench/core-vec-append.rs @@ -7,7 +7,7 @@ use io::WriterUtil; fn collect_raw(num: uint) -> ~[uint] { let mut result = ~[]; for uint::range(0u, num) |i| { - vec::push(result, i); + result.push(i); } return result; } diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 61d556b4613..ef2fa8dfa9e 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -318,7 +318,7 @@ fn validate(edges: ~[(node_id, node_id)], status = false; } - vec::push(path, parent); + path.push(parent); parent = tree[parent]; } diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 89d339b7a76..392f67d6714 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -60,7 +60,7 @@ fn run(args: &[~str]) { for uint::range(0u, workers) |i| { let to_child = to_child.clone(); do task::task().future_result(|+r| { - vec::push(worker_results, r); + worker_results.push(r); }).spawn { for uint::range(0u, size / workers) |_i| { //error!("worker %?: sending %? bytes", i, num_bytes); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index babc97694a5..6ba8b71d8c4 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -57,7 +57,7 @@ fn run(args: &[~str]) { let (to_child, from_parent_) = pipes::stream(); from_parent.add(from_parent_); do task::task().future_result(|+r| { - vec::push(worker_results, r); + worker_results.push(r); }).spawn { for uint::range(0u, size / workers) |_i| { //error!("worker %?: sending %? bytes", i, num_bytes); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index e3d8afce1bf..2931cab248f 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -18,7 +18,7 @@ type pipe = arc::MutexARC<~[uint]>; fn send(p: &pipe, msg: uint) { do p.access_cond |state, cond| { - vec::push(*state, msg); + state.push(msg); cond.signal(); } } @@ -91,7 +91,7 @@ fn main(++args: ~[~str]) { option::unwrap(num_chan), option::unwrap(num_port1)) }); - vec::push(futures, new_future); + futures.push(new_future); num_chan = Some(new_chan); }; diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index 645aa654700..3c888fd0c8d 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -88,7 +88,7 @@ fn main(++args: ~[~str]) { option::unwrap(num_chan), option::unwrap(num_port1)) }; - vec::push(futures, new_future); + futures.push(new_future); num_chan = Some(new_chan); }; diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index b4b75adc3b5..525cf8f1c50 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -18,7 +18,7 @@ type pipe = arc::RWARC<~[uint]>; fn send(p: &pipe, msg: uint) { do p.write_cond |state, cond| { - vec::push(*state, msg); + state.push(msg); cond.signal(); } } @@ -92,7 +92,7 @@ fn main(++args: ~[~str]) { option::unwrap(num_chan), option::unwrap(num_port1)) }; - vec::push(futures, new_future); + futures.push(new_future); num_chan = Some(new_chan); }; diff --git a/src/test/bench/msgsend-ring.rs b/src/test/bench/msgsend-ring.rs index 47ce0d2b91f..5533aeeeb41 100644 --- a/src/test/bench/msgsend-ring.rs +++ b/src/test/bench/msgsend-ring.rs @@ -51,7 +51,7 @@ fn main(++args: ~[~str]) { get_chan_chan.send(Chan(p)); thread_ring(i, msg_per_task, num_chan, p) }; - vec::push(futures, new_future); + futures.push(new_future); num_chan = get_chan.recv(); }; diff --git a/src/test/bench/msgsend.rs b/src/test/bench/msgsend.rs index 2790f00d40d..fb1e3ae9226 100644 --- a/src/test/bench/msgsend.rs +++ b/src/test/bench/msgsend.rs @@ -37,7 +37,7 @@ fn run(args: ~[~str]) { let mut worker_results = ~[]; for uint::range(0u, workers) |_i| { do task::task().future_result(|+r| { - vec::push(worker_results, r); + worker_results.push(r); }).spawn { for uint::range(0u, size / workers) |_i| { comm::send(to_child, bytes(100u)); diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index bdfe4b7b727..5c7827f5106 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -163,7 +163,7 @@ fn rendezvous(nn: uint, set: ~[color]) { // save each creature's meeting stats let mut report = ~[]; for vec::each(to_creature) |_to_one| { - vec::push(report, comm::recv(from_creatures_log)); + report.push(comm::recv(from_creatures_log)); } // print each color in the set diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index b5dcacd76d3..4f821a534ab 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -41,7 +41,7 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { // map -> [(k,%)] mm.each(fn&(key: ~[u8], val: uint) -> bool { - vec::push(pairs, (key, pct(val, total))); + pairs.push((key, pct(val, total))); return true; }); @@ -152,7 +152,7 @@ fn main(++args: ~[~str]) { stream <-> streams[ii]; let (to_parent_, from_child_) = option::unwrap(stream); - vec::push(from_child, from_child_); + from_child.push(from_child_); let (to_child, from_parent) = pipes::stream(); diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 5f7036ed82a..3b00fd99a55 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -38,7 +38,7 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { // map -> [(k,%)] mm.each(fn&(key: ~[u8], val: uint) -> bool { - vec::push(pairs, (key, pct(val, total))); + pairs.push((key, pct(val, total))); return true; }); diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 0cf0f0da5e5..d9859d54648 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -85,7 +85,7 @@ fn chanmb(i: uint, size: uint, ch: comm::Chan) -> () let xincr = 8f64*incr; for uint::range(0_u, size/8_u) |j| { let x = cmplx {re: xincr*(j as f64) - 1.5f64, im: y}; - vec::push(crv, fillbyte(x, incr)); + crv.push(fillbyte(x, incr)); }; comm::send(ch, {i:i, b:crv}); } diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 705679bd403..90224645f84 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -73,7 +73,7 @@ fn stress(num_tasks: int) { let mut results = ~[]; for range(0, num_tasks) |i| { do task::task().future_result(|+r| { - vec::push(results, r); + results.push(r); }).spawn { stress_task(i); } diff --git a/src/test/bench/task-perf-one-million.rs b/src/test/bench/task-perf-one-million.rs index da8b1932f65..c9d4fb6b4d8 100644 --- a/src/test/bench/task-perf-one-million.rs +++ b/src/test/bench/task-perf-one-million.rs @@ -21,7 +21,7 @@ fn calc(children: uint, parent_ch: comm::Chan) { for iter::repeat (children) { match comm::recv(port) { ready(child_ch) => { - vec::push(child_chs, child_ch); + child_chs.push(child_ch); } _ => fail ~"task-perf-one-million failed (port not ready)" } diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 73c5dab16d8..efb795a76af 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -155,8 +155,8 @@ mod map_reduce { let (ctrl, ctrl_server) = ctrl_proto::init(); let ctrl = box(ctrl); let i = copy *i; - vec::push(tasks, spawn_joinable(|move i| map_task(map, ctrl, i))); - vec::push(ctrls, ctrl_server); + tasks.push(spawn_joinable(|move i| map_task(map, ctrl, i))); + ctrls.push(ctrl_server); } return tasks; } @@ -270,8 +270,7 @@ mod map_reduce { let p = Port(); let ch = Chan(p); let r = reduce, kk = k; - vec::push(tasks, - spawn_joinable(|| reduce_task(r, kk, ch) )); + tasks.push(spawn_joinable(|| reduce_task(r, kk, ch) )); c = recv(p); reducers.insert(k, c); } diff --git a/src/test/compile-fail/purity-infer-fail.rs b/src/test/compile-fail/purity-infer-fail.rs index 691829edf59..b7666fa8650 100644 --- a/src/test/compile-fail/purity-infer-fail.rs +++ b/src/test/compile-fail/purity-infer-fail.rs @@ -2,5 +2,5 @@ fn something(f: pure fn()) { f(); } fn main() { let mut x = ~[]; - something(|| vec::push(x, 0) ); //~ ERROR access to impure function prohibited in pure context + something(|| x.push(0) ); //~ ERROR access to impure function prohibited in pure context } diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index 4e97d2f903f..c6239c1f657 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -8,7 +8,7 @@ fn enum_chars(start: u8, end: u8) -> ~[char] { assert start < end; let mut i = start; let mut r = ~[]; - while i <= end { vec::push(r, i as char); i += 1u as u8; } + while i <= end { r.push(i as char); i += 1u as u8; } return r; } @@ -16,7 +16,7 @@ fn enum_uints(start: uint, end: uint) -> ~[uint] { assert start < end; let mut i = start; let mut r = ~[]; - while i <= end { vec::push(r, i); i += 1u; } + while i <= end { r.push(i); i += 1u; } return r; } diff --git a/src/test/run-pass/auto-ref-sliceable.rs b/src/test/run-pass/auto-ref-sliceable.rs index 43d9fa5b14b..48d83da74ad 100644 --- a/src/test/run-pass/auto-ref-sliceable.rs +++ b/src/test/run-pass/auto-ref-sliceable.rs @@ -4,7 +4,7 @@ trait Pushable { impl ~[T]: Pushable { fn push_val(&mut self, +t: T) { - vec::push(*self, t); + self.push(t); } } diff --git a/src/test/run-pass/autoref-vec-push.rs b/src/test/run-pass/autoref-vec-push.rs deleted file mode 100644 index cb70a1810b7..00000000000 --- a/src/test/run-pass/autoref-vec-push.rs +++ /dev/null @@ -1,17 +0,0 @@ -trait VecPush { - fn push(&mut self, +t: T); -} - -impl ~[T]: VecPush { - fn push(&mut self, +t: T) { - vec::push(*self, t); - } -} - -fn main() { - let mut x = ~[]; - x.push(1); - x.push(2); - x.push(3); - assert x == ~[1, 2, 3]; -} \ No newline at end of file diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 6db380735cb..2d1833c0736 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -4,7 +4,7 @@ fn add_int(x: &mut ints, v: int) { *x.sum += v; let mut values = ~[]; x.values <-> values; - vec::push(values, v); + values.push(v); x.values <- values; } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 3eb6561eb96..fc637429cd0 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -52,10 +52,15 @@ fn read_board_grid(+in: rdr) -> ~[~[square]] { let mut grid = ~[]; for in.each_line |line| { let mut row = ~[]; +<<<<<<< HEAD for str::each_char(line) |c| { vec::push(row, square_from_char(c)) +======= + for line.each_char |c| { + row.push(square_from_char(c)) +>>>>>>> Demode vec::push (and convert to method) } - vec::push(grid, row) + grid.push(row) } let width = grid[0].len(); for grid.each |row| { assert row.len() == width } diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index dd2dd5e54d4..4faac4fdac1 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -34,7 +34,7 @@ fn test00() { while i < number_of_tasks { let ch = po.chan(); do task::task().future_result(|+r| { - vec::push(results, r); + results.push(r); }).spawn |copy i| { test00_start(ch, i, number_of_messages) } diff --git a/src/test/run-pass/task-comm.rs b/src/test/run-pass/task-comm.rs index a3a6b6efd7f..8d144b1a399 100644 --- a/src/test/run-pass/task-comm.rs +++ b/src/test/run-pass/task-comm.rs @@ -40,7 +40,7 @@ fn test00() { while i < number_of_tasks { i = i + 1; do task::task().future_result(|+r| { - vec::push(results, r); + results.push(r); }).spawn |copy i| { test00_start(ch, i, number_of_messages); } @@ -127,7 +127,7 @@ fn test06() { while i < number_of_tasks { i = i + 1; do task::task().future_result(|+r| { - vec::push(results, r); + results.push(r); }).spawn |copy i| { test06_start(i); }; diff --git a/src/test/run-pass/vec-push.rs b/src/test/run-pass/vec-push.rs index 3e47f7e0a3b..d4190d41386 100644 --- a/src/test/run-pass/vec-push.rs +++ b/src/test/run-pass/vec-push.rs @@ -1 +1 @@ -fn main() { let mut v = ~[1, 2, 3]; vec::push(v, 1); } +fn main() { let mut v = ~[1, 2, 3]; v.push(1); } diff --git a/src/test/run-pass/zip-same-length.rs b/src/test/run-pass/zip-same-length.rs index 61e359129fe..9b8304792fa 100644 --- a/src/test/run-pass/zip-same-length.rs +++ b/src/test/run-pass/zip-same-length.rs @@ -7,7 +7,7 @@ fn enum_chars(start: u8, end: u8) -> ~[char] { assert start < end; let mut i = start; let mut r = ~[]; - while i <= end { vec::push(r, i as char); i += 1u as u8; } + while i <= end { r.push(i as char); i += 1u as u8; } return r; } @@ -15,7 +15,7 @@ fn enum_uints(start: uint, end: uint) -> ~[uint] { assert start < end; let mut i = start; let mut r = ~[]; - while i <= end { vec::push(r, i); i += 1u; } + while i <= end { r.push(i); i += 1u; } return r; } -- cgit 1.4.1-3-g733a5 From 8f0e9ff02914459a98d1727f5bf0c26bba604bb9 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 26 Sep 2012 18:23:05 -0700 Subject: Long lines --- src/libsyntax/parse/parser.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 10981c5c708..b650a8890c5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2285,7 +2285,8 @@ impl parser { let stmt = self.parse_stmt(initial_attrs); initial_attrs = ~[]; match stmt.node { - stmt_expr(e, stmt_id) => { // Expression without semicolon: + stmt_expr(e, stmt_id) => { + // Expression without semicolon match self.token { token::SEMI => { self.bump(); @@ -2297,9 +2298,11 @@ impl parser { } t => { if classify::stmt_ends_with_semi(*stmt) { - self.fatal(~"expected `;` or `}` after \ - expression but found `" - + token_to_str(self.reader, t) + ~"`"); + self.fatal( + ~"expected `;` or `}` after \ + expression but found `" + + token_to_str(self.reader, t) + + ~"`"); } stmts.push(stmt); } -- cgit 1.4.1-3-g733a5 From e8fe718bfd4d88b0bc59117326a14a10f2598568 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 26 Sep 2012 16:27:12 -0700 Subject: core: Replace map/map_default with map_ref/map_default_ref --- src/compiletest/compiletest.rs | 2 +- src/compiletest/header.rs | 2 +- src/libcore/dlist.rs | 4 ++-- src/libcore/iter.rs | 2 +- src/libcore/option.rs | 28 ++++------------------ src/libcore/os.rs | 2 +- src/libcore/task/local_data_priv.rs | 6 ++--- src/libcore/task/spawn.rs | 2 +- src/libcore/vec.rs | 4 ++-- src/libsyntax/diagnostic.rs | 2 +- src/libsyntax/fold.rs | 36 ++++++++++++++-------------- src/libsyntax/parse.rs | 2 +- src/libsyntax/parse/parser.rs | 4 ++-- src/libsyntax/visit.rs | 2 +- src/rustc/driver/driver.rs | 2 +- src/rustc/driver/rustc.rs | 6 ++--- src/rustc/front/config.rs | 2 +- src/rustc/metadata/cstore.rs | 2 +- src/rustc/metadata/decoder.rs | 4 ++-- src/rustc/middle/borrowck/check_loans.rs | 2 +- src/rustc/middle/liveness.rs | 6 ++--- src/rustc/middle/mem_categorization.rs | 14 +++++------ src/rustc/middle/trans/callee.rs | 2 +- src/rustc/middle/trans/common.rs | 2 +- src/rustc/middle/trans/glue.rs | 10 ++++---- src/rustc/middle/ty.rs | 10 ++++---- src/rustc/middle/typeck/check/regionmanip.rs | 6 ++--- src/rustc/middle/typeck/check/vtable.rs | 2 +- src/rustdoc/config.rs | 6 ++--- src/rustdoc/text_pass.rs | 2 +- 30 files changed, 79 insertions(+), 97 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 8d48669ab17..264ee61018b 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -58,7 +58,7 @@ fn parse_config(args: ~[~str]) -> config { } else { option::None }, logfile: option::map(&getopts::opt_maybe_str(matches, ~"logfile"), - |s| Path(s)), + |s| Path(*s)), runtool: getopts::opt_maybe_str(matches, ~"runtool"), rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"), jit: getopts::opt_present(matches, ~"jit"), diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 19a3c621d27..d72a9d65e05 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -103,7 +103,7 @@ fn parse_compile_flags(line: ~str) -> Option<~str> { fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> { do parse_name_value_directive(line, ~"exec-env").map |nv| { // nv is either FOO or FOO=BAR - let strs = str::splitn_char(nv, '=', 1u); + let strs = str::splitn_char(*nv, '=', 1u); match strs.len() { 1u => (strs[0], ~""), 2u => (strs[0], strs[1]), diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index d50abc64f2b..fcf8146200d 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -275,13 +275,13 @@ impl DList { /// Remove a node from the head of the list. O(1). fn pop_n() -> Option> { let hd = self.peek_n(); - hd.map(|nobe| self.unlink(nobe)); + hd.map(|nobe| self.unlink(*nobe)); hd } /// Remove a node from the tail of the list. O(1). fn pop_tail_n() -> Option> { let tl = self.peek_tail_n(); - tl.map(|nobe| self.unlink(nobe)); + tl.map(|nobe| self.unlink(*nobe)); tl } /// Get the node at the list's head. O(1). diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 00091d0ed41..bc1955698fc 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -290,7 +290,7 @@ pure fn from_elem>(n_elts: uint, t: T) -> BT { pure fn append,BT: Buildable>( lhs: IT, rhs: IT) -> BT { let size_opt = lhs.size_hint().chain( - |sz1| rhs.size_hint().map(|sz2| sz1+sz2)); + |sz1| rhs.size_hint().map(|sz2| sz1+*sz2)); do build_sized_opt(size_opt) |push| { for lhs.each |x| { push(*x); } for rhs.each |x| { push(*x); } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 518775ec751..ae28c6db083 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -61,13 +61,7 @@ pure fn expect(opt: &Option, +reason: ~str) -> T { match *opt { Some(x) => x, None => fail reason } } -pure fn map(opt: &Option, f: fn(T) -> U) -> Option { - //! Maps a `some` value from one type to another - - match *opt { Some(x) => Some(f(x)), None => None } -} - -pure fn map_ref(opt: &Option, f: fn(x: &T) -> U) -> Option { +pure fn map(opt: &Option, f: fn(x: &T) -> U) -> Option { //! Maps a `some` value by reference from one type to another match *opt { Some(ref x) => Some(f(x)), None => None } @@ -138,14 +132,7 @@ pure fn get_default(opt: &Option, +def: T) -> T { match *opt { Some(x) => x, None => def } } -pure fn map_default(opt: &Option, +def: U, f: fn(T) -> U) -> U { - //! Applies a function to the contained value or returns a default - - match *opt { None => move def, Some(t) => f(t) } -} - -// This should replace map_default. -pure fn map_default_ref(opt: &Option, +def: U, +pure fn map_default(opt: &Option, +def: U, f: fn(x: &T) -> U) -> U { //! Applies a function to the contained value or returns a default @@ -200,17 +187,12 @@ impl Option { * function that returns an option. */ pure fn chain(f: fn(T) -> Option) -> Option { chain(&self, f) } - /// Applies a function to the contained value or returns a default - pure fn map_default(+def: U, f: fn(T) -> U) -> U - { map_default(&self, move def, f) } /// Performs an operation on the contained value or does nothing pure fn iter(f: fn(T)) { iter(&self, f) } /// Returns true if the option equals `none` pure fn is_none() -> bool { is_none(&self) } /// Returns true if the option contains some value pure fn is_some() -> bool { is_some(&self) } - /// Maps a `some` value from one type to another - pure fn map(f: fn(T) -> U) -> Option { map(&self, f) } } impl &Option { @@ -222,12 +204,12 @@ impl &Option { chain_ref(self, f) } /// Applies a function to the contained value or returns a default - pure fn map_default_ref(+def: U, f: fn(x: &T) -> U) -> U - { map_default_ref(self, move def, f) } + pure fn map_default(+def: U, f: fn(x: &T) -> U) -> U + { map_default(self, move def, f) } /// Performs an operation on the contained value by reference pure fn iter_ref(f: fn(x: &T)) { iter_ref(self, f) } /// Maps a `some` value from one type to another by reference - pure fn map_ref(f: fn(x: &T) -> U) -> Option { map_ref(self, f) } + pure fn map(f: fn(x: &T) -> U) -> Option { map(self, f) } /// Gets an immutable reference to the value inside a `some`. pure fn get_ref() -> &self/T { get_ref(self) } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 0a2f00e3f2b..7803783ea66 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -439,7 +439,7 @@ fn self_exe_path() -> Option { } do load_self().map |pth| { - Path(pth).dir_path() + Path(*pth).dir_path() } } diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 2fbb88327ed..31369c47c64 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -75,8 +75,8 @@ unsafe fn local_data_lookup( ); do map_pos.map |index| { // .get() is guaranteed because of "None { false }" above. - let (_, data_ptr, _) = (*map)[index].get(); - (index, data_ptr) + let (_, data_ptr, _) = (*map)[*index].get(); + (*index, data_ptr) } } @@ -91,7 +91,7 @@ unsafe fn local_get_helper( // was referenced in the local_data box, though, not here, so before // overwriting the local_data_box we need to give an extra reference. // We must also give an extra reference when not removing. - let (index, data_ptr) = result; + let (index, data_ptr) = *result; let data: @T = cast::transmute(move data_ptr); cast::bump_box_refcount(data); if do_pop { diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 21f217d57f4..f2568414392 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -200,7 +200,7 @@ fn each_ancestor(list: &mut AncestorList, // the end of the list, which doesn't make sense to coalesce. return do (**ancestors).map_default((None,false)) |ancestor_arc| { // NB: Takes a lock! (this ancestor node) - do access_ancestors(&ancestor_arc) |nobe| { + do access_ancestors(ancestor_arc) |nobe| { // Check monotonicity assert last_generation > nobe.generation; /*##########################################################* diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 50011dbacec..a0516116bdf 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -969,7 +969,7 @@ pure fn find(v: &[T], f: fn(T) -> bool) -> Option { */ pure fn find_between(v: &[T], start: uint, end: uint, f: fn(T) -> bool) -> Option { - position_between(v, start, end, f).map(|i| v[i]) + position_between(v, start, end, f).map(|i| v[*i]) } /** @@ -992,7 +992,7 @@ pure fn rfind(v: &[T], f: fn(T) -> bool) -> Option { */ pure fn rfind_between(v: &[T], start: uint, end: uint, f: fn(T) -> bool) -> Option { - rposition_between(v, start, end, f).map(|i| v[i]) + rposition_between(v, start, end, f).map(|i| v[*i]) } /// Find the first index containing a matching value diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index ca9db6d25ad..1c12397568d 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -262,7 +262,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span, fn print_macro_backtrace(cm: codemap::codemap, sp: span) { do option::iter(&sp.expn_info) |ei| { let ss = option::map_default(&ei.callie.span, @~"", - |span| @codemap::span_to_str(span, cm)); + |span| @codemap::span_to_str(*span, cm)); print_diagnostic(*ss, note, fmt!("in expansion of #%s", ei.callie.name)); let ss = codemap::span_to_str(ei.call_site, cm); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 12c8dc2f7bb..3d9234df41e 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -114,7 +114,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac { match m.node { mac_invoc(pth, arg, body) => { mac_invoc(fld.fold_path(pth), - option::map(&arg, |x| fld.fold_expr(x)), body) + option::map(&arg, |x| fld.fold_expr(*x)), body) } mac_invoc_tt(*) => m.node, mac_ellipsis => mac_ellipsis, @@ -243,7 +243,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { variants: vec::map(enum_definition.variants, |x| fld.fold_variant(*x)), common: option::map(&enum_definition.common, - |x| fold_struct_def(x, fld)) + |x| fold_struct_def(*x, fld)) }), fold_ty_params(typms, fld)) } item_class(struct_def, typms) => { @@ -252,7 +252,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { } item_impl(tps, ifce, ty, methods) => { item_impl(fold_ty_params(tps, fld), - ifce.map(|p| fold_trait_ref(p, fld)), + ifce.map(|p| fold_trait_ref(*p, fld)), fld.fold_ty(ty), vec::map(methods, |x| fld.fold_method(*x))) } @@ -292,7 +292,7 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold) let dtor_id = fld.new_id(dtor.node.id); {node: {body: dtor_body, id: dtor_id,.. dtor.node}, - .. dtor}}; + .. *dtor}}; return @{ traits: vec::map(struct_def.traits, |p| fold_trait_ref(*p, fld)), fields: vec::map(struct_def.fields, |f| fold_struct_field(*f, fld)), @@ -332,7 +332,7 @@ fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method { fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ { return {view_items: vec::map(b.view_items, |x| fld.fold_view_item(*x)), stmts: vec::map(b.stmts, |x| fld.fold_stmt(*x)), - expr: option::map(&b.expr, |x| fld.fold_expr(x)), + expr: option::map(&b.expr, |x| fld.fold_expr(*x)), id: fld.new_id(b.id), rules: b.rules}; } @@ -347,7 +347,7 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ { fn noop_fold_arm(a: arm, fld: ast_fold) -> arm { return {pats: vec::map(a.pats, |x| fld.fold_pat(*x)), - guard: option::map(&a.guard, |x| fld.fold_expr(x)), + guard: option::map(&a.guard, |x| fld.fold_expr(*x)), body: fld.fold_block(a.body)}; } @@ -357,12 +357,12 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { pat_ident(binding_mode, pth, sub) => { pat_ident(binding_mode, fld.fold_path(pth), - option::map(&sub, |x| fld.fold_pat(x))) + option::map(&sub, |x| fld.fold_pat(*x))) } pat_lit(e) => pat_lit(fld.fold_expr(e)), pat_enum(pth, pats) => { pat_enum(fld.fold_path(pth), option::map(&pats, - |pats| vec::map(pats, |x| fld.fold_pat(*x)))) + |pats| vec::map(*pats, |x| fld.fold_pat(*x)))) } pat_rec(fields, etc) => { let mut fs = ~[]; @@ -432,7 +432,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { expr_repeat(fld.fold_expr(expr), fld.fold_expr(count), mutt), expr_rec(fields, maybe_expr) => { expr_rec(vec::map(fields, |x| fold_field(*x)), - option::map(&maybe_expr, |x| fld.fold_expr(x))) + option::map(&maybe_expr, |x| fld.fold_expr(*x))) } expr_tup(elts) => expr_tup(vec::map(elts, |x| fld.fold_expr(*x))), expr_call(f, args, blk) => { @@ -451,14 +451,14 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { expr_addr_of(m, ohs) => expr_addr_of(m, fld.fold_expr(ohs)), expr_if(cond, tr, fl) => { expr_if(fld.fold_expr(cond), fld.fold_block(tr), - option::map(&fl, |x| fld.fold_expr(x))) + option::map(&fl, |x| fld.fold_expr(*x))) } expr_while(cond, body) => { expr_while(fld.fold_expr(cond), fld.fold_block(body)) } expr_loop(body, opt_ident) => { expr_loop(fld.fold_block(body), - option::map(&opt_ident, |x| fld.fold_ident(x))) + option::map(&opt_ident, |x| fld.fold_ident(*x))) } expr_match(expr, arms) => { expr_match(fld.fold_expr(expr), @@ -500,12 +500,12 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { expr_index(fld.fold_expr(el), fld.fold_expr(er)) } expr_path(pth) => expr_path(fld.fold_path(pth)), - expr_fail(e) => expr_fail(option::map(&e, |x| fld.fold_expr(x))), + expr_fail(e) => expr_fail(option::map(&e, |x| fld.fold_expr(*x))), expr_break(opt_ident) => - expr_break(option::map(&opt_ident, |x| fld.fold_ident(x))), + expr_break(option::map(&opt_ident, |x| fld.fold_ident(*x))), expr_again(opt_ident) => - expr_again(option::map(&opt_ident, |x| fld.fold_ident(x))), - expr_ret(e) => expr_ret(option::map(&e, |x| fld.fold_expr(x))), + expr_again(option::map(&opt_ident, |x| fld.fold_ident(*x))), + expr_ret(e) => expr_ret(option::map(&e, |x| fld.fold_expr(*x))), expr_log(i, lv, e) => expr_log(i, fld.fold_expr(lv), fld.fold_expr(e)), expr_assert(e) => expr_assert(fld.fold_expr(e)), @@ -513,7 +513,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { expr_struct(path, fields, maybe_expr) => { expr_struct(fld.fold_path(path), vec::map(fields, |x| fold_field(*x)), - option::map(&maybe_expr, |x| fld.fold_expr(x))) + option::map(&maybe_expr, |x| fld.fold_expr(*x))) } } } @@ -577,7 +577,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { let dtor_id = fld.new_id(dtor.node.id); {node: {body: dtor_body, id: dtor_id,.. dtor.node}, - .. dtor}}; + .. *dtor}}; kind = struct_variant_kind(@{ traits: ~[], fields: vec::map(struct_def.fields, @@ -593,7 +593,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { let variants = vec::map(enum_definition.variants, |x| fld.fold_variant(*x)); let common = option::map(&enum_definition.common, - |x| fold_struct_def(x, fld)); + |x| fold_struct_def(*x, fld)); kind = enum_variant_kind(ast::enum_def({ variants: variants, common: common })); } diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 751b3ce62b9..2c04b2a1419 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -73,7 +73,7 @@ fn parse_crate_from_crate_file(input: &Path, cfg: ast::crate_cfg, sess.chpos = rdr.chpos; sess.byte_pos = sess.byte_pos + rdr.pos; let cx = @{sess: sess, cfg: /* FIXME (#2543) */ copy p.cfg}; - let companionmod = input.filestem().map(|s| Path(s)); + let companionmod = input.filestem().map(|s| Path(*s)); let (m, attrs) = eval::eval_crate_directives_to_mod( cx, cdirs, &prefix, &companionmod); let mut hi = p.span.hi; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b650a8890c5..f8ad6c541f6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2758,7 +2758,7 @@ impl parser { } let actual_dtor = do the_dtor.map |dtor| { - let (d_body, d_attrs, d_s) = dtor; + let (d_body, d_attrs, d_s) = *dtor; {node: {id: self.get_id(), attrs: d_attrs, self_id: self.get_id(), @@ -3126,7 +3126,7 @@ impl parser { } self.bump(); let mut actual_dtor = do the_dtor.map |dtor| { - let (d_body, d_attrs, d_s) = dtor; + let (d_body, d_attrs, d_s) = *dtor; {node: {id: self.get_id(), attrs: d_attrs, self_id: self.get_id(), diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index de9caf48b63..93ef9508610 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -395,7 +395,7 @@ fn visit_exprs(exprs: ~[@expr], e: E, v: vt) { fn visit_mac(m: mac, e: E, v: vt) { match m.node { ast::mac_invoc(_, arg, _) => { - option::map(&arg, |arg| v.visit_expr(arg, e, v)); } + option::map(&arg, |arg| v.visit_expr(*arg, e, v)); } ast::mac_invoc_tt(*) => { /* no user-serviceable parts inside */ } ast::mac_ellipsis => (), ast::mac_aq(*) => { /* FIXME: maybe visit (Issue #2340) */ } diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 3acacd3c0a5..e389f3a4bdf 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -507,7 +507,7 @@ fn build_session_options(binary: ~str, let extra_debuginfo = opt_present(matches, ~"xg"); let debuginfo = opt_present(matches, ~"g") || extra_debuginfo; let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot"); - let sysroot_opt = sysroot_opt.map(|m| Path(m)); + let sysroot_opt = sysroot_opt.map(|m| Path(*m)); let target_opt = getopts::opt_maybe_str(matches, ~"target"); let save_temps = getopts::opt_present(matches, ~"save-temps"); match output_type { diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 6ea5bb28023..38ce7a4fbac 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -172,14 +172,14 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { let sopts = build_session_options(binary, matches, demitter); let sess = build_session(sopts, demitter); let odir = getopts::opt_maybe_str(matches, ~"out-dir"); - let odir = odir.map(|o| Path(o)); + let odir = odir.map(|o| Path(*o)); let ofile = getopts::opt_maybe_str(matches, ~"o"); - let ofile = ofile.map(|o| Path(o)); + let ofile = ofile.map(|o| Path(*o)); let cfg = build_configuration(sess, binary, input); let pretty = option::map(&getopts::opt_default(matches, ~"pretty", ~"normal"), - |a| parse_pretty(sess, a) ); + |a| parse_pretty(sess, *a) ); match pretty { Some::(ppm) => { pretty_print_input(sess, cfg, input, ppm); diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index 4c262e3dc65..7e0d9ec2e86 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -104,7 +104,7 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) -> let filtered_stmts = vec::filter_map(b.stmts, filter); return {view_items: b.view_items, stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)), - expr: option::map(&b.expr, |x| fld.fold_expr(x)), + expr: option::map(&b.expr, |x| fld.fold_expr(*x)), id: b.id, rules: b.rules}; } diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index edf6a9612c7..49e79e009da 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -177,7 +177,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[~str] { fn get_path(cstore: cstore, d: ast::def_id) -> ~[~str] { option::map_default(&p(cstore).mod_path_map.find(d), ~[], - |ds| str::split_str(*ds, ~"::")) + |ds| str::split_str(**ds, ~"::")) } // Local Variables: // mode: rust diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index a6bb681bc16..bebf8344c08 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -196,7 +196,7 @@ fn field_mutability(d: ebml::Doc) -> ast::class_mutability { &ebml::maybe_get_doc(d, tag_class_mut), ast::class_immutable, |d| { - match ebml::doc_as_u8(d) as char { + match ebml::doc_as_u8(*d) as char { 'm' => ast::class_mutable, _ => ast::class_immutable } @@ -246,7 +246,7 @@ fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) fn item_ty_region_param(item: ebml::Doc) -> Option { ebml::maybe_get_doc(item, tag_region_param).map(|doc| { - let d = ebml::ebml_deserializer(doc); + let d = ebml::ebml_deserializer(*doc); ty::deserialize_region_variance(d) }) } diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index cedab91b04e..841d54c6b0d 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -183,7 +183,7 @@ impl check_loan_ctxt { debug!("check_pure_callee_or_arg(pc=%?, expr=%?, \ callee_id=%d, ty=%s)", pc, - opt_expr.map(|e| pprust::expr_to_str(e, tcx.sess.intr()) ), + opt_expr.map(|e| pprust::expr_to_str(*e, tcx.sess.intr()) ), callee_id, ty_to_str(self.tcx(), ty::node_id_to_type(tcx, callee_id))); diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index b39b7914905..ce998378fe5 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -659,7 +659,7 @@ impl Liveness { expr_path(_) => { let def = self.tcx.def_map.get(expr.id); relevant_def(def).map( - |rdef| self.variable_from_rdef(rdef, expr.span) + |rdef| self.variable_from_rdef(*rdef, expr.span) ) } _ => None @@ -675,7 +675,7 @@ impl Liveness { match self.tcx.def_map.find(node_id) { Some(def) => { relevant_def(def).map( - |rdef| self.variable_from_rdef(rdef, span) + |rdef| self.variable_from_rdef(*rdef, span) ) } None => { @@ -1396,7 +1396,7 @@ impl Liveness { // Note: the field_map is empty unless we are in a ctor return self.ir.field_map.find(fld).map(|var| { let ln = self.live_node(expr.id, expr.span); - (ln, var) + (ln, *var) }); } _ => return None diff --git a/src/rustc/middle/mem_categorization.rs b/src/rustc/middle/mem_categorization.rs index 03d453a84f5..a9f4c195765 100644 --- a/src/rustc/middle/mem_categorization.rs +++ b/src/rustc/middle/mem_categorization.rs @@ -612,7 +612,7 @@ impl &mem_categorization_ctxt { cmt: cmt) -> cmt { @{id: arg.id(), span: arg.span(), cat: cat_comp(cmt, comp_variant(enum_did)), - lp: cmt.lp.map(|l| @lp_comp(l, comp_variant(enum_did)) ), + lp: cmt.lp.map(|l| @lp_comp(*l, comp_variant(enum_did)) ), mutbl: cmt.mutbl, // imm iff in an immutable context ty: self.tcx.ty(arg)} } @@ -649,7 +649,7 @@ impl &mem_categorization_ctxt { }; let m = self.inherited_mutability(base_cmt.mutbl, f_mutbl); let f_comp = comp_field(f_name, f_mutbl); - let lp = base_cmt.lp.map(|lp| @lp_comp(lp, f_comp) ); + let lp = base_cmt.lp.map(|lp| @lp_comp(*lp, f_comp) ); @{id: node.id(), span: node.span(), cat: cat_comp(base_cmt, f_comp), lp:lp, mutbl: m, ty: self.tcx.ty(node)} @@ -699,7 +699,7 @@ impl &mem_categorization_ctxt { } deref_comp(comp) => { - let lp = base_cmt.lp.map(|l| @lp_comp(l, comp) ); + let lp = base_cmt.lp.map(|l| @lp_comp(*l, comp) ); let m = self.inherited_mutability(base_cmt.mutbl, mt.mutbl); @{id:node.id(), span:node.span(), cat:cat_comp(base_cmt, comp), lp:lp, @@ -724,7 +724,7 @@ impl &mem_categorization_ctxt { // (a) the contents are loanable if the base is loanable // and this is a *unique* vector let deref_lp = match ptr { - uniq_ptr => {base_cmt.lp.map(|lp| @lp_deref(lp, uniq_ptr))} + uniq_ptr => {base_cmt.lp.map(|lp| @lp_deref(*lp, uniq_ptr))} _ => {None} }; @@ -756,7 +756,7 @@ impl &mem_categorization_ctxt { fn comp(expr: @ast::expr, of_cmt: cmt, vect: ty::t, mutbl: ast::mutability, ty: ty::t) -> cmt { let comp = comp_index(vect, mutbl); - let index_lp = of_cmt.lp.map(|lp| @lp_comp(lp, comp) ); + let index_lp = of_cmt.lp.map(|lp| @lp_comp(*lp, comp) ); @{id:expr.id, span:expr.span, cat:cat_comp(of_cmt, comp), lp:index_lp, mutbl:mutbl, ty:ty} @@ -766,7 +766,7 @@ impl &mem_categorization_ctxt { fn cat_tuple_elt(elt: N, cmt: cmt) -> cmt { @{id: elt.id(), span: elt.span(), cat: cat_comp(cmt, comp_tuple), - lp: cmt.lp.map(|l| @lp_comp(l, comp_tuple) ), + lp: cmt.lp.map(|l| @lp_comp(*l, comp_tuple) ), mutbl: cmt.mutbl, // imm iff in an immutable context ty: self.tcx.ty(elt)} } @@ -958,7 +958,7 @@ impl &mem_categorization_ctxt { self.cat_to_repr(cmt.cat), cmt.id, self.mut_to_str(cmt.mutbl), - cmt.lp.map_default(~"none", |p| self.lp_to_str(p) ), + cmt.lp.map_default(~"none", |p| self.lp_to_str(*p) ), ty_to_str(self.tcx, cmt.ty)) } diff --git a/src/rustc/middle/trans/callee.rs b/src/rustc/middle/trans/callee.rs index 470d4dbb4ab..e7b4dd171e3 100644 --- a/src/rustc/middle/trans/callee.rs +++ b/src/rustc/middle/trans/callee.rs @@ -537,7 +537,7 @@ fn trans_arg_expr(bcx: block, ret_flag=%?)", formal_ty.mode, bcx.ty_to_str(formal_ty.ty), bcx.expr_to_str(arg_expr), - ret_flag.map(|v| bcx.val_str(v))); + ret_flag.map(|v| bcx.val_str(*v))); let _indenter = indenter(); // translate the arg expr to a datum diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 0df63e40acf..6f14b22d778 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -1222,7 +1222,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] { fn node_vtables(bcx: block, id: ast::node_id) -> Option { let raw_vtables = bcx.ccx().maps.vtable_map.find(id); raw_vtables.map( - |vts| meth::resolve_vtables_in_fn_ctxt(bcx.fcx, vts)) + |vts| meth::resolve_vtables_in_fn_ctxt(bcx.fcx, *vts)) } fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res) diff --git a/src/rustc/middle/trans/glue.rs b/src/rustc/middle/trans/glue.rs index 50a24a1a825..a8a750cd4be 100644 --- a/src/rustc/middle/trans/glue.rs +++ b/src/rustc/middle/trans/glue.rs @@ -192,16 +192,16 @@ fn lazily_emit_simplified_tydesc_glue(ccx: @crate_ctxt, field: uint, lazily_emit_tydesc_glue(ccx, field, simpl_ti); if field == abi::tydesc_field_take_glue { ti.take_glue = - simpl_ti.take_glue.map(|v| cast_glue(ccx, ti, v)); + simpl_ti.take_glue.map(|v| cast_glue(ccx, ti, *v)); } else if field == abi::tydesc_field_drop_glue { ti.drop_glue = - simpl_ti.drop_glue.map(|v| cast_glue(ccx, ti, v)); + simpl_ti.drop_glue.map(|v| cast_glue(ccx, ti, *v)); } else if field == abi::tydesc_field_free_glue { ti.free_glue = - simpl_ti.free_glue.map(|v| cast_glue(ccx, ti, v)); + simpl_ti.free_glue.map(|v| cast_glue(ccx, ti, *v)); } else if field == abi::tydesc_field_visit_glue { ti.visit_glue = - simpl_ti.visit_glue.map(|v| cast_glue(ccx, ti, v)); + simpl_ti.visit_glue.map(|v| cast_glue(ccx, ti, *v)); } return true; } @@ -398,7 +398,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { ty::ty_class(did, ref substs) => { // Call the dtor if there is one do option::map_default(&ty::ty_dtor(bcx.tcx(), did), bcx) |dt_id| { - trans_class_drop(bcx, v, dt_id, did, substs) + trans_class_drop(bcx, v, *dt_id, did, substs) } } _ => bcx diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index ed71d27451c..06eb26ec4e7 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -1177,7 +1177,7 @@ fn fold_sty_to_ty(tcx: ty::ctxt, sty: &sty, foldop: fn(t) -> t) -> t { fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty { fn fold_substs(substs: &substs, fldop: fn(t) -> t) -> substs { {self_r: substs.self_r, - self_ty: substs.self_ty.map(|t| fldop(t)), + self_ty: substs.self_ty.map(|t| fldop(*t)), tps: substs.tps.map(|t| fldop(*t))} } @@ -1273,8 +1273,8 @@ fn fold_regions_and_ty( fldr: fn(r: region) -> region, fldt: fn(t: t) -> t) -> substs { - {self_r: substs.self_r.map(|r| fldr(r)), - self_ty: substs.self_ty.map(|t| fldt(t)), + {self_r: substs.self_r.map(|r| fldr(*r)), + self_ty: substs.self_ty.map(|t| fldt(*t)), tps: substs.tps.map(|t| fldt(*t))} } @@ -1403,8 +1403,8 @@ fn substs_is_noop(substs: &substs) -> bool { fn substs_to_str(cx: ctxt, substs: &substs) -> ~str { fmt!("substs(self_r=%s, self_ty=%s, tps=%?)", - substs.self_r.map_default(~"none", |r| region_to_str(cx, r)), - substs.self_ty.map_default(~"none", |t| ty_to_str(cx, t)), + substs.self_r.map_default(~"none", |r| region_to_str(cx, *r)), + substs.self_ty.map_default(~"none", |t| ty_to_str(cx, *t)), tys_to_str(cx, substs.tps)) } diff --git a/src/rustc/middle/typeck/check/regionmanip.rs b/src/rustc/middle/typeck/check/regionmanip.rs index aec42f77048..29d4e9927ff 100644 --- a/src/rustc/middle/typeck/check/regionmanip.rs +++ b/src/rustc/middle/typeck/check/regionmanip.rs @@ -37,7 +37,7 @@ fn replace_bound_regions_in_fn_ty( debug!("replace_bound_regions_in_fn_ty(self_info.self_ty=%?, fn_ty=%s, \ all_tys=%?)", - self_ty.map(|t| ty_to_str(tcx, t)), + self_ty.map(|t| ty_to_str(tcx, *t)), ty_to_str(tcx, ty::mk_fn(tcx, *fn_ty)), all_tys.map(|t| ty_to_str(tcx, *t))); let _i = indenter(); @@ -50,11 +50,11 @@ fn replace_bound_regions_in_fn_ty( let t_fn = ty::fold_sty_to_ty(tcx, &ty_fn, |t| { replace_bound_regions(tcx, isr, t) }); - let t_self = self_ty.map(|t| replace_bound_regions(tcx, isr, t)); + let t_self = self_ty.map(|t| replace_bound_regions(tcx, isr, *t)); debug!("result of replace_bound_regions_in_fn_ty: self_info.self_ty=%?, \ fn_ty=%s", - t_self.map(|t| ty_to_str(tcx, t)), + t_self.map(|t| ty_to_str(tcx, *t)), ty_to_str(tcx, t_fn)); diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index 453559e5e42..38ca571dae5 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -69,7 +69,7 @@ fn fixup_substs(fcx: @fn_ctxt, expr: @ast::expr, // use a dummy type just to package up the substs that need fixing up let t = ty::mk_trait(tcx, id, substs, ty::vstore_slice(ty::re_static)); do fixup_ty(fcx, expr, t, is_early).map |t_f| { - match ty::get(t_f).sty { + match ty::get(*t_f).sty { ty::ty_trait(_, substs_f, _) => substs_f, _ => fail ~"t_f should be a trait" } diff --git a/src/rustdoc/config.rs b/src/rustdoc/config.rs index d8e79182506..c57e712c020 100644 --- a/src/rustdoc/config.rs +++ b/src/rustdoc/config.rs @@ -141,7 +141,7 @@ fn config_from_opts( let result = result::Ok(config); let result = do result::chain(result) |config| { let output_dir = getopts::opt_maybe_str(matches, opt_output_dir()); - let output_dir = output_dir.map(|s| Path(s)); + let output_dir = output_dir.map(|s| Path(*s)); result::Ok({ output_dir: output_dir.get_default(config.output_dir), .. config @@ -152,7 +152,7 @@ fn config_from_opts( matches, opt_output_format()); do output_format.map_default(result::Ok(config)) |output_format| { - do result::chain(parse_output_format(output_format)) + do result::chain(parse_output_format(*output_format)) |output_format| { result::Ok({ @@ -167,7 +167,7 @@ fn config_from_opts( getopts::opt_maybe_str(matches, opt_output_style()); do output_style.map_default(result::Ok(config)) |output_style| { - do result::chain(parse_output_style(output_style)) + do result::chain(parse_output_style(*output_style)) |output_style| { result::Ok({ output_style: output_style, diff --git a/src/rustdoc/text_pass.rs b/src/rustdoc/text_pass.rs index 76ae3192cef..0da3491c364 100644 --- a/src/rustdoc/text_pass.rs +++ b/src/rustdoc/text_pass.rs @@ -32,7 +32,7 @@ fn run( } fn maybe_apply_op(op: Op, s: Option<~str>) -> Option<~str> { - s.map(|s| op(s) ) + s.map(|s| op(*s) ) } fn fold_item(fold: fold::Fold, doc: doc::ItemDoc) -> doc::ItemDoc { -- cgit 1.4.1-3-g733a5 From 459fe6ad558e58db68d622ceacb79e3e8f95c35b Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 27 Sep 2012 15:03:44 -0400 Subject: factor out common lines --- src/libsyntax/parse/parser.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f8ad6c541f6..243f01c1e3a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2227,17 +2227,11 @@ impl parser { } let lo = self.span.lo; - if self.eat_keyword(~"unsafe") { - self.expect(token::LBRACE); - let {inner, next} = maybe_parse_inner_attrs_and_next(self, - parse_attrs); - return (inner, self.parse_block_tail_(lo, unsafe_blk, next)); - } else { - self.expect(token::LBRACE); - let {inner, next} = maybe_parse_inner_attrs_and_next(self, - parse_attrs); - return (inner, self.parse_block_tail_(lo, default_blk, next)); - } + let us = self.eat_keyword(~"unsafe"); + self.expect(token::LBRACE); + let {inner, next} = maybe_parse_inner_attrs_and_next(self, + parse_attrs); + return (inner, self.parse_block_tail_(lo, if us { unsafe_blk } else { default_blk }, next)); } fn parse_block_no_value() -> blk { -- cgit 1.4.1-3-g733a5 From 0bcb3bc536ec30a7a15c276de8e3c3c1e4643e1e Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 27 Sep 2012 11:52:36 -0700 Subject: libsyntax: Parse visibility modifiers before foreign items --- src/libsyntax/ast.rs | 3 ++- src/libsyntax/fold.rs | 3 ++- src/libsyntax/parse/parser.rs | 17 +++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 24dc3660faf..3e62d0b3ab7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1485,7 +1485,8 @@ type foreign_item = attrs: ~[attribute], node: foreign_item_, id: node_id, - span: span}; + span: span, + vis: visibility}; #[auto_serialize] enum foreign_item_ { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 3d9234df41e..4f3dafcb21b 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -203,7 +203,8 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) } }, id: fld.new_id(ni.id), - span: fld.new_span(ni.span)}; + span: fld.new_span(ni.span), + vis: ni.vis}; } fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f8ad6c541f6..513dce193cc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2940,7 +2940,8 @@ impl parser { (id, item_mod(m), Some(inner_attrs.inner)) } - fn parse_item_foreign_fn(+attrs: ~[attribute]) -> @foreign_item { + fn parse_item_foreign_fn(vis: ast::visibility, + +attrs: ~[attribute]) -> @foreign_item { let lo = self.span.lo; let purity = self.parse_fn_purity(); let t = self.parse_fn_header(); @@ -2951,10 +2952,12 @@ impl parser { attrs: attrs, node: foreign_item_fn(decl, purity, t.tps), id: self.get_id(), - span: mk_sp(lo, hi)}; + span: mk_sp(lo, hi), + vis: vis}; } - fn parse_item_foreign_const(+attrs: ~[attribute]) -> @foreign_item { + fn parse_item_foreign_const(vis: ast::visibility, + +attrs: ~[attribute]) -> @foreign_item { let lo = self.span.lo; self.expect_keyword(~"const"); let ident = self.parse_ident(); @@ -2966,7 +2969,8 @@ impl parser { attrs: attrs, node: foreign_item_const(move ty), id: self.get_id(), - span: mk_sp(lo, hi)}; + span: mk_sp(lo, hi), + vis: vis}; } fn parse_fn_purity() -> purity { @@ -2982,10 +2986,11 @@ impl parser { } fn parse_foreign_item(+attrs: ~[attribute]) -> @foreign_item { + let vis = self.parse_visibility(); if self.is_keyword(~"const") { - self.parse_item_foreign_const(move attrs) + self.parse_item_foreign_const(vis, move attrs) } else { - self.parse_item_foreign_fn(move attrs) + self.parse_item_foreign_fn(vis, move attrs) } } -- cgit 1.4.1-3-g733a5 From b68d287780899dfb73083dff78241e02c7772f7e Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Thu, 27 Sep 2012 19:24:11 -0700 Subject: libsyntax: Fix long line --- src/libsyntax/parse/parser.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c079645ff37..d81bd09f37a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2231,7 +2231,8 @@ impl parser { self.expect(token::LBRACE); let {inner, next} = maybe_parse_inner_attrs_and_next(self, parse_attrs); - return (inner, self.parse_block_tail_(lo, if us { unsafe_blk } else { default_blk }, next)); + let blk_check_mode = if us { unsafe_blk } else { default_blk }; + return (inner, self.parse_block_tail_(lo, blk_check_mode, next)); } fn parse_block_no_value() -> blk { -- cgit 1.4.1-3-g733a5 From 92841793114d7e60e3227d9087dc8741e7592789 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 2 Oct 2012 12:19:04 -0700 Subject: libstd: Switch off legacy modes in both core and std. --- src/cargo/cargo.rs | 4 +- src/fuzzer/fuzzer.rs | 2 +- src/libcore/cast.rs | 2 +- src/libcore/comm.rs | 4 +- src/libcore/core.rc | 1 - src/libcore/os.rs | 4 +- src/libcore/ptr.rs | 2 +- src/libcore/rand.rs | 4 +- src/libcore/stackwalk.rs | 7 ++- src/libstd/ebml.rs | 8 +-- src/libstd/serialization.rs | 72 +++++++++++----------- src/libstd/std.rc | 1 - src/libsyntax/ast.rs | 24 ++++---- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/parse/obsolete.rs | 2 +- src/rt/rust_builtin.cpp | 10 +++ src/rt/rustrt.def.in | 2 + src/rustc/middle/borrowck.rs | 2 +- src/rustc/middle/trans/common.rs | 4 +- src/rustc/middle/trans/datum.rs | 2 +- src/rustc/middle/ty.rs | 38 ++++++------ .../middle/typeck/infer/region_var_bindings.rs | 4 +- src/test/bench/graph500-bfs.rs | 2 +- src/test/bench/shootout-mandelbrot.rs | 2 +- 24 files changed, 108 insertions(+), 97 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 6136652c873..81c0ce9a5b7 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -144,7 +144,7 @@ fn is_uuid(id: ~str) -> bool { if vec::len(parts) == 5u { let mut correct = 0u; for vec::eachi(parts) |i, part| { - fn is_hex_digit(ch: char) -> bool { + fn is_hex_digit(+ch: char) -> bool { ('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F') @@ -402,7 +402,7 @@ fn need_dir(s: &Path) { } fn valid_pkg_name(s: &str) -> bool { - fn is_valid_digit(c: char) -> bool { + fn is_valid_digit(+c: char) -> bool { ('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index ace96c389ef..cd312362d6a 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -221,7 +221,7 @@ fn under(n: uint, it: fn(uint)) { while i < n { it(i); i += 1u; } } -fn as_str(f: fn@(io::Writer)) -> ~str { +fn as_str(f: fn@(+x: io::Writer)) -> ~str { io::with_str_writer(f) } diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 714c85c75c3..21f5861b89e 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -3,7 +3,7 @@ #[abi = "rust-intrinsic"] extern mod rusti { fn forget(-x: T); - fn reinterpret_cast(e: T) -> U; + fn reinterpret_cast(&&e: T) -> U; } /// Casts the value at `src` to U. The two types must have the same length. diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 81b648d9840..ff9f9498a98 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -33,7 +33,7 @@ will once again be the preferred module for intertask communication. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +#[warn(deprecated_mode)]; #[forbid(deprecated_pattern)]; use either::Either; @@ -166,7 +166,7 @@ fn as_raw_port(ch: comm::Chan, f: fn(*rust_port) -> U) -> U { * Constructs a channel. The channel is bound to the port used to * construct it. */ -pub fn Chan(p: Port) -> Chan { +pub fn Chan(&&p: Port) -> Chan { Chan_(rustrt::get_port_id((**p).po)) } diff --git a/src/libcore/core.rc b/src/libcore/core.rc index c781a26185a..6cada58fa02 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -36,7 +36,6 @@ Implicitly, all crates behave as if they included the following prologue: // Don't link to core. We are core. #[no_core]; -#[legacy_modes]; #[legacy_exports]; #[warn(deprecated_mode)]; diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 1b53a163ad5..1cf4fbab6c9 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -35,7 +35,7 @@ extern mod rustrt { fn rust_getcwd() -> ~str; fn rust_path_is_dir(path: *libc::c_char) -> c_int; fn rust_path_exists(path: *libc::c_char) -> c_int; - fn rust_list_files(path: ~str) -> ~[~str]; + fn rust_list_files2(&&path: ~str) -> ~[~str]; fn rust_process_wait(handle: c_int) -> c_int; fn last_os_error() -> ~str; fn rust_set_exit_status(code: libc::intptr_t); @@ -582,7 +582,7 @@ pub fn list_dir(p: &Path) -> ~[~str] { #[cfg(windows)] fn star(p: &Path) -> Path { p.push("*") } - do rustrt::rust_list_files(star(p).to_str()).filter |filename| { + do rustrt::rust_list_files2(star(p).to_str()).filter |filename| { *filename != ~"." && *filename != ~".." } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 550b0121e45..fad7eddd2d8 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -21,7 +21,7 @@ extern mod libc_ { #[abi = "rust-intrinsic"] extern mod rusti { - fn addr_of(val: T) -> *T; + fn addr_of(&&val: T) -> *T; } /// Get an unsafe pointer to a value diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 501afc0c4bc..f6b7dfa568c 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -11,7 +11,7 @@ enum rctx {} extern mod rustrt { fn rand_seed() -> ~[u8]; fn rand_new() -> *rctx; - fn rand_new_seeded(seed: ~[u8]) -> *rctx; + fn rand_new_seeded2(&&seed: ~[u8]) -> *rctx; fn rand_next(c: *rctx) -> u32; fn rand_free(c: *rctx); } @@ -276,7 +276,7 @@ pub fn Rng() -> Rng { * length. */ pub fn seeded_rng(seed: &~[u8]) -> Rng { - @RandRes(rustrt::rand_new_seeded(*seed)) as Rng + @RandRes(rustrt::rand_new_seeded2(*seed)) as Rng } type XorShiftState = { diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 4cc91b8b425..d0f8de136e2 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -1,7 +1,8 @@ #[doc(hidden)]; // FIXME #3538 // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// XXX: Can't do this because frame_address needs a deprecated mode. +//#[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; use cast::reinterpret_cast; @@ -74,7 +75,7 @@ fn breakpoint() { rustrt::rust_dbg_breakpoint() } -fn frame_address(f: fn(*u8)) { +fn frame_address(f: fn(++x: *u8)) { rusti::frame_address(f) } @@ -86,5 +87,5 @@ extern mod rustrt { #[abi = "rust-intrinsic"] extern mod rusti { #[legacy_exports]; - fn frame_address(f: fn(*u8)); + fn frame_address(f: fn(++x: *u8)); } diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index b88142e9502..7c5b7929f84 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -588,11 +588,11 @@ impl EbmlDeserializer: serialization::Deserializer { #[test] fn test_option_int() { - fn serialize_1(s: S, v: int) { + fn serialize_1(&&s: S, v: int) { s.emit_i64(v as i64); } - fn serialize_0(s: S, v: Option) { + fn serialize_0(&&s: S, v: Option) { do s.emit_enum(~"core::option::t") { match v { None => s.emit_enum_variant( @@ -606,11 +606,11 @@ fn test_option_int() { } } - fn deserialize_1(s: S) -> int { + fn deserialize_1(&&s: S) -> int { s.read_i64() as int } - fn deserialize_0(s: S) -> Option { + fn deserialize_0(&&s: S) -> Option { do s.read_enum(~"core::option::t") { do s.read_enum_variant |i| { match i { diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs index 7cf7779f13d..e9067bc6404 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -81,7 +81,7 @@ trait Deserializer { // // In some cases, these should eventually be coded as traits. -fn emit_from_vec(s: S, v: ~[T], f: fn(T)) { +fn emit_from_vec(&&s: S, &&v: ~[T], f: fn(&&x: T)) { do s.emit_vec(vec::len(v)) { for vec::eachi(v) |i,e| { do s.emit_vec_elt(i) { @@ -91,7 +91,7 @@ fn emit_from_vec(s: S, v: ~[T], f: fn(T)) { } } -fn read_to_vec(d: D, f: fn() -> T) -> ~[T] { +fn read_to_vec(&&d: D, f: fn() -> T) -> ~[T] { do d.read_vec |len| { do vec::from_fn(len) |i| { d.read_vec_elt(i, || f()) @@ -100,11 +100,11 @@ fn read_to_vec(d: D, f: fn() -> T) -> ~[T] { } trait SerializerHelpers { - fn emit_from_vec(v: ~[T], f: fn(T)); + fn emit_from_vec(&&v: ~[T], f: fn(&&x: T)); } impl S: SerializerHelpers { - fn emit_from_vec(v: ~[T], f: fn(T)) { + fn emit_from_vec(&&v: ~[T], f: fn(&&x: T)) { emit_from_vec(self, v, f) } } @@ -119,127 +119,127 @@ impl D: DeserializerHelpers { } } -fn serialize_uint(s: S, v: uint) { +fn serialize_uint(&&s: S, v: uint) { s.emit_uint(v); } -fn deserialize_uint(d: D) -> uint { +fn deserialize_uint(&&d: D) -> uint { d.read_uint() } -fn serialize_u8(s: S, v: u8) { +fn serialize_u8(&&s: S, v: u8) { s.emit_u8(v); } -fn deserialize_u8(d: D) -> u8 { +fn deserialize_u8(&&d: D) -> u8 { d.read_u8() } -fn serialize_u16(s: S, v: u16) { +fn serialize_u16(&&s: S, v: u16) { s.emit_u16(v); } -fn deserialize_u16(d: D) -> u16 { +fn deserialize_u16(&&d: D) -> u16 { d.read_u16() } -fn serialize_u32(s: S, v: u32) { +fn serialize_u32(&&s: S, v: u32) { s.emit_u32(v); } -fn deserialize_u32(d: D) -> u32 { +fn deserialize_u32(&&d: D) -> u32 { d.read_u32() } -fn serialize_u64(s: S, v: u64) { +fn serialize_u64(&&s: S, v: u64) { s.emit_u64(v); } -fn deserialize_u64(d: D) -> u64 { +fn deserialize_u64(&&d: D) -> u64 { d.read_u64() } -fn serialize_int(s: S, v: int) { +fn serialize_int(&&s: S, v: int) { s.emit_int(v); } -fn deserialize_int(d: D) -> int { +fn deserialize_int(&&d: D) -> int { d.read_int() } -fn serialize_i8(s: S, v: i8) { +fn serialize_i8(&&s: S, v: i8) { s.emit_i8(v); } -fn deserialize_i8(d: D) -> i8 { +fn deserialize_i8(&&d: D) -> i8 { d.read_i8() } -fn serialize_i16(s: S, v: i16) { +fn serialize_i16(&&s: S, v: i16) { s.emit_i16(v); } -fn deserialize_i16(d: D) -> i16 { +fn deserialize_i16(&&d: D) -> i16 { d.read_i16() } -fn serialize_i32(s: S, v: i32) { +fn serialize_i32(&&s: S, v: i32) { s.emit_i32(v); } -fn deserialize_i32(d: D) -> i32 { +fn deserialize_i32(&&d: D) -> i32 { d.read_i32() } -fn serialize_i64(s: S, v: i64) { +fn serialize_i64(&&s: S, v: i64) { s.emit_i64(v); } -fn deserialize_i64(d: D) -> i64 { +fn deserialize_i64(&&d: D) -> i64 { d.read_i64() } -fn serialize_str(s: S, v: &str) { +fn serialize_str(&&s: S, v: &str) { s.emit_str(v); } -fn deserialize_str(d: D) -> ~str { +fn deserialize_str(&&d: D) -> ~str { d.read_str() } -fn serialize_float(s: S, v: float) { +fn serialize_float(&&s: S, v: float) { s.emit_float(v); } -fn deserialize_float(d: D) -> float { +fn deserialize_float(&&d: D) -> float { d.read_float() } -fn serialize_f32(s: S, v: f32) { +fn serialize_f32(&&s: S, v: f32) { s.emit_f32(v); } -fn deserialize_f32(d: D) -> f32 { +fn deserialize_f32(&&d: D) -> f32 { d.read_f32() } -fn serialize_f64(s: S, v: f64) { +fn serialize_f64(&&s: S, v: f64) { s.emit_f64(v); } -fn deserialize_f64(d: D) -> f64 { +fn deserialize_f64(&&d: D) -> f64 { d.read_f64() } -fn serialize_bool(s: S, v: bool) { +fn serialize_bool(&&s: S, v: bool) { s.emit_bool(v); } -fn deserialize_bool(d: D) -> bool { +fn deserialize_bool(&&d: D) -> bool { d.read_bool() } -fn serialize_Option(s: S, v: Option, st: fn(T)) { +fn serialize_Option(&&s: S, &&v: Option, st: fn(&&x: T)) { do s.emit_enum(~"option") { match v { None => do s.emit_enum_variant(~"none", 0u, 0u) { @@ -254,7 +254,7 @@ fn serialize_Option(s: S, v: Option, st: fn(T)) { } } -fn deserialize_Option(d: D, st: fn() -> T) +fn deserialize_Option(&&d: D, st: fn() -> T) -> Option { do d.read_enum(~"option") { do d.read_enum_variant |i| { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 4831ac993a2..aa26c4af29c 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -18,7 +18,6 @@ not required in or otherwise suitable for the core library. #[no_core]; -#[legacy_modes]; #[legacy_exports]; #[allow(vecs_implicitly_copyable)]; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 67841158ce1..e17b52fb27d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -69,7 +69,7 @@ impl ident: cmp::Eq { } impl ident: to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { self.repr.iter_bytes(lsb0, f) } } @@ -328,7 +328,7 @@ enum binding_mode { } impl binding_mode : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { bind_by_value => 0u8.iter_bytes(lsb0, f), @@ -402,7 +402,7 @@ enum pat_ { enum mutability { m_mutbl, m_imm, m_const, } impl mutability : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -541,7 +541,7 @@ enum inferable { } impl inferable : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { expl(ref t) => to_bytes::iter_bytes_2(&0u8, t, lsb0, f), @@ -577,7 +577,7 @@ impl inferable : cmp::Eq { enum rmode { by_ref, by_val, by_mutbl_ref, by_move, by_copy } impl rmode : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -937,7 +937,7 @@ enum trait_method { enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, } impl int_ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -966,7 +966,7 @@ impl int_ty : cmp::Eq { enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, } impl uint_ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -993,7 +993,7 @@ impl uint_ty : cmp::Eq { enum float_ty { ty_f, ty_f32, ty_f64, } impl float_ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -1102,7 +1102,7 @@ impl ty : cmp::Eq { } impl ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f); } } @@ -1126,7 +1126,7 @@ enum purity { } impl purity : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -1146,7 +1146,7 @@ enum ret_style { } impl ret_style : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -1443,7 +1443,7 @@ enum item_ { enum class_mutability { class_mutable, class_immutable } impl class_mutability : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 2431947184d..e8099de246c 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -254,7 +254,7 @@ pure fn is_call_expr(e: @expr) -> bool { // This makes def_id hashable impl def_id : core::to_bytes::IterBytes { #[inline(always)] - pure fn iter_bytes(lsb0: bool, f: core::to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: core::to_bytes::Cb) { core::to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f); } } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 9cfa84ad9e0..782535f5c2b 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -36,7 +36,7 @@ impl ObsoleteSyntax : cmp::Eq { impl ObsoleteSyntax: to_bytes::IterBytes { #[inline(always)] - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as uint).iter_bytes(lsb0, f); } } diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 91c5760d3e9..6f985601f8b 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -180,6 +180,11 @@ rand_new_seeded(rust_vec_box* seed) { return rctx; } +extern "C" CDECL void * +rand_new_seeded2(rust_vec_box** seed) { + return rand_new_seeded(*seed); +} + extern "C" CDECL size_t rand_next(randctx *rctx) { return isaac_rand(rctx); @@ -371,6 +376,11 @@ rust_list_files(rust_str *path) { return vec; } +extern "C" CDECL rust_vec_box* +rust_list_files2(rust_str **path) { + return rust_list_files(*path); +} + extern "C" CDECL int rust_path_is_dir(char *path) { struct stat buf; diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 43f24f4dd4f..551378a3d6c 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -27,6 +27,7 @@ rust_port_select rand_free rand_new rand_new_seeded +rand_new_seeded2 rand_next rand_seed rust_get_sched_id @@ -40,6 +41,7 @@ rust_get_stdin rust_get_stdout rust_get_stderr rust_list_files +rust_list_files2 rust_log_console_on rust_log_console_off rust_port_begin_detach diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 4906eb4a0a3..414890cbd7c 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -415,7 +415,7 @@ impl root_map_key : cmp::Eq { } impl root_map_key : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f); } } diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index d68bdb08221..6768f3e71a0 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -1142,7 +1142,7 @@ impl mono_id_ : cmp::Eq { } impl mono_param_id : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { mono_precise(t, mids) => to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), &mids, lsb0, f), @@ -1156,7 +1156,7 @@ impl mono_param_id : to_bytes::IterBytes { } impl mono_id_ : core::to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f); } } diff --git a/src/rustc/middle/trans/datum.rs b/src/rustc/middle/trans/datum.rs index 59e8cd72025..241fa5e53af 100644 --- a/src/rustc/middle/trans/datum.rs +++ b/src/rustc/middle/trans/datum.rs @@ -146,7 +146,7 @@ impl DatumMode: cmp::Eq { } impl DatumMode: to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as uint).iter_bytes(lsb0, f) } } diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 973db90ff66..a96388e9d77 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -248,7 +248,7 @@ impl creader_cache_key : cmp::Eq { } impl creader_cache_key : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f); } } @@ -263,7 +263,7 @@ impl intern_key : cmp::Eq { } impl intern_key : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.sty, &self.o_def_id, lsb0, f); } } @@ -406,7 +406,7 @@ enum closure_kind { } impl closure_kind : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -424,7 +424,7 @@ enum fn_proto { } impl fn_proto : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { proto_bare => 0u8.iter_bytes(lsb0, f), @@ -502,7 +502,7 @@ impl param_ty : cmp::Eq { } impl param_ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.idx, &self.def_id, lsb0, f) } } @@ -676,7 +676,7 @@ enum InferTy { } impl InferTy : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f), IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f) @@ -685,7 +685,7 @@ impl InferTy : to_bytes::IterBytes { } impl param_bound : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { bound_copy => 0u8.iter_bytes(lsb0, f), bound_owned => 1u8.iter_bytes(lsb0, f), @@ -749,25 +749,25 @@ impl purity: purity_to_str { } impl RegionVid : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (*self).iter_bytes(lsb0, f) } } impl TyVid : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (*self).iter_bytes(lsb0, f) } } impl IntVid : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (*self).iter_bytes(lsb0, f) } } impl FnVid : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (*self).iter_bytes(lsb0, f) } } @@ -2505,7 +2505,7 @@ fn index_sty(cx: ctxt, sty: &sty) -> Option { } impl bound_region : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { ty::br_self => 0u8.iter_bytes(lsb0, f), @@ -2522,7 +2522,7 @@ impl bound_region : to_bytes::IterBytes { } impl region : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { re_bound(ref br) => to_bytes::iter_bytes_2(&0u8, br, lsb0, f), @@ -2542,7 +2542,7 @@ impl region : to_bytes::IterBytes { } impl vstore : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { vstore_fixed(ref u) => to_bytes::iter_bytes_2(&0u8, u, lsb0, f), @@ -2557,7 +2557,7 @@ impl vstore : to_bytes::IterBytes { } impl substs : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_3(&self.self_r, &self.self_ty, &self.tps, lsb0, f) @@ -2565,28 +2565,28 @@ impl substs : to_bytes::IterBytes { } impl mt : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.ty, &self.mutbl, lsb0, f) } } impl field : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.ident, &self.mt, lsb0, f) } } impl arg : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.mode, &self.ty, lsb0, f) } } impl sty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { ty_nil => 0u8.iter_bytes(lsb0, f), ty_bool => 1u8.iter_bytes(lsb0, f), diff --git a/src/rustc/middle/typeck/infer/region_var_bindings.rs b/src/rustc/middle/typeck/infer/region_var_bindings.rs index c86850e19d2..8bbdab74d23 100644 --- a/src/rustc/middle/typeck/infer/region_var_bindings.rs +++ b/src/rustc/middle/typeck/infer/region_var_bindings.rs @@ -350,7 +350,7 @@ impl Constraint : cmp::Eq { } impl Constraint : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { ConstrainVarSubVar(ref v0, ref v1) => to_bytes::iter_bytes_3(&0u8, v0, v1, lsb0, f), @@ -377,7 +377,7 @@ impl TwoRegions : cmp::Eq { } impl TwoRegions : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.a, &self.b, lsb0, f) } } diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index f35a3ce735f..a34fcc89c04 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -251,7 +251,7 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { colors = do par::mapi_factory(*color_vec) { let colors = arc::clone(&color); let graph = arc::clone(&graph); - fn~(i: uint, c: color) -> color { + fn~(+i: uint, +c: color) -> color { let c : color = c; let colors = arc::get(&colors); let graph = arc::get(&graph); diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index d9859d54648..ee38b957b0c 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -94,7 +94,7 @@ type devnull = {dn: int}; impl devnull: io::Writer { fn write(_b: &[const u8]) {} - fn seek(_i: int, _s: io::SeekStyle) {} + fn seek(+_i: int, +_s: io::SeekStyle) {} fn tell() -> uint {0_u} fn flush() -> int {0} fn get_type() -> io::WriterType { io::File } -- cgit 1.4.1-3-g733a5 From 2f451a7bd7d856daad1e487f7bc7a14c40840c2d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 2 Oct 2012 18:13:56 -0700 Subject: rustc: Only allow imports marked with "pub" to be imported from other modules --- src/libcore/gc.rs | 2 +- src/libcore/os.rs | 8 ++++---- src/libcore/repr.rs | 3 ++- src/libsyntax/parse/parser.rs | 6 +++--- src/rustc/middle/resolve.rs | 23 +++++++++++++++++++---- 5 files changed, 29 insertions(+), 13 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index de2e4412812..464600b9469 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -29,7 +29,7 @@ with destructors. #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; -use stackwalk::Word; +pub use stackwalk::Word; use libc::size_t; use libc::uintptr_t; use send_map::linear::LinearMap; diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 1ffb27aaa36..d37bdabd48a 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -22,7 +22,7 @@ use libc::{c_char, c_void, c_int, c_uint, size_t, ssize_t, mode_t, pid_t, FILE}; -use libc::{close, fclose}; +pub use libc::{close, fclose}; use option::{Some, None}; @@ -225,7 +225,7 @@ mod global_env { pub fn setenv(n: &str, v: &str) { do str::as_c_str(n) |nbuf| { do str::as_c_str(v) |vbuf| { - libc::setenv(nbuf, vbuf, 1i32); + libc::funcs::posix01::unistd::setenv(nbuf, vbuf, 1i32); } } } @@ -384,8 +384,8 @@ pub fn self_exe_path() -> Option { #[cfg(target_os = "macos")] fn load_self() -> Option<~str> { do fill_charp_buf() |buf, sz| { - libc::_NSGetExecutablePath(buf, ptr::mut_addr_of(&(sz as u32))) - == (0 as c_int) + libc::funcs::extra::_NSGetExecutablePath( + buf, ptr::mut_addr_of(&(sz as u32))) == (0 as c_int) } } diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index 30b43dd7f84..ff82ed3fb41 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -13,7 +13,8 @@ use cast::transmute; use intrinsic::{TyDesc, TyVisitor, visit_tydesc}; use reflect::{MovePtr, MovePtrAdaptor}; use vec::raw::{VecRepr, UnboxedVecRepr, SliceRepr}; -use box::raw::{BoxRepr, BoxHeaderRepr}; +pub use box::raw::BoxRepr; +use box::raw::BoxHeaderRepr; /// Helpers diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d81bd09f37a..8860d1b5cea 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3511,8 +3511,8 @@ impl parser { self.token_is_keyword(~"mod", next_tok)) } - fn parse_view_item(+attrs: ~[attribute]) -> @view_item { - let lo = self.span.lo, vis = self.parse_visibility(); + fn parse_view_item(+attrs: ~[attribute], vis: visibility) -> @view_item { + let lo = self.span.lo; let node = if self.eat_keyword(~"use") { self.parse_use() } else if self.eat_keyword(~"export") { @@ -3644,7 +3644,7 @@ impl parser { _ => self.unexpected() } } else if self.is_view_item() { - let vi = self.parse_view_item(outer_attrs); + let vi = self.parse_view_item(outer_attrs, vis); return spanned(lo, vi.span.hi, cdir_view_item(vi)); } return self.fatal(~"expected crate directive"); diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index fc66b5dc7a1..eca0687f2fd 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -367,8 +367,7 @@ struct ImportResolution { mut used: bool, } -fn ImportResolution(privacy: Privacy, - span: span) -> ImportResolution { +fn ImportResolution(privacy: Privacy, span: span) -> ImportResolution { ImportResolution { privacy: privacy, span: span, @@ -1639,11 +1638,20 @@ impl Resolver { match *subclass { SingleImport(target, _, _) => { + debug!("(building import directive) building import \ + directive: privacy %? %s::%s", + privacy, + self.idents_to_str(module_path.get()), + self.session.str_of(target)); + match module_.import_resolutions.find(target) { Some(resolution) => { + debug!("(building import directive) bumping \ + reference"); resolution.outstanding_references += 1u; } None => { + debug!("(building import directive) creating new"); let resolution = @ImportResolution(privacy, span); resolution.outstanding_references = 1u; module_.import_resolutions.insert(target, resolution); @@ -1967,6 +1975,12 @@ impl Resolver { namespace: Namespace) -> NamespaceResult { + // Import resolutions must be declared with "pub" + // in order to be exported. + if import_resolution.privacy == Private { + return UnboundResult; + } + match (*import_resolution). target_for_namespace(namespace) { None => { @@ -4229,7 +4243,8 @@ impl Resolver { // Next, search import resolutions. match containing_module.import_resolutions.find(name) { - Some(import_resolution) => { + Some(import_resolution) if import_resolution.privacy == Public || + xray == Xray => { match (*import_resolution).target_for_namespace(namespace) { Some(target) => { match (*target.bindings) @@ -4252,7 +4267,7 @@ impl Resolver { } } } - None => { + Some(_) | None => { return NoNameDefinition; } } -- cgit 1.4.1-3-g733a5