From 14f656d1a79fb36ce5435976dd33f57dd09cb9ce Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 20 Mar 2014 03:35:51 -0400 Subject: rename std::vec_ng -> std::vec Closes #12771 --- src/libcollections/hashmap.rs | 6 +- src/liblog/directive.rs | 2 +- src/liblog/lib.rs | 2 +- src/libnative/io/file_unix.rs | 2 +- src/libnum/bigint.rs | 10 +- src/libnum/rational.rs | 2 +- src/librustc/back/archive.rs | 2 +- src/librustc/back/link.rs | 4 +- src/librustc/back/mips.rs | 2 +- src/librustc/back/rpath.rs | 2 +- src/librustc/back/target_strs.rs | 2 +- src/librustc/driver/driver.rs | 8 +- src/librustc/driver/session.rs | 4 +- src/librustc/front/config.rs | 2 +- src/librustc/front/feature_gate.rs | 2 +- src/librustc/front/std_inject.rs | 6 +- src/librustc/front/test.rs | 6 +- src/librustc/lib.rs | 6 +- src/librustc/metadata/creader.rs | 2 +- src/librustc/metadata/csearch.rs | 6 +- src/librustc/metadata/cstore.rs | 2 +- src/librustc/metadata/decoder.rs | 2 +- src/librustc/metadata/encoder.rs | 2 +- src/librustc/metadata/filesearch.rs | 2 +- src/librustc/metadata/loader.rs | 2 +- src/librustc/metadata/tydecode.rs | 2 +- src/librustc/metadata/tyencode.rs | 2 +- src/librustc/middle/astencode.rs | 2 +- src/librustc/middle/borrowck/check_loans.rs | 2 +- src/librustc/middle/borrowck/gather_loans/mod.rs | 2 +- .../middle/borrowck/gather_loans/restrictions.rs | 6 +- src/librustc/middle/borrowck/mod.rs | 2 +- src/librustc/middle/borrowck/move_data.rs | 2 +- src/librustc/middle/cfg/construct.rs | 2 +- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_match.rs | 22 +- src/librustc/middle/const_eval.rs | 2 +- src/librustc/middle/dataflow.rs | 2 +- src/librustc/middle/dead.rs | 2 +- src/librustc/middle/entry.rs | 2 +- src/librustc/middle/freevars.rs | 2 +- src/librustc/middle/graph.rs | 2 +- src/librustc/middle/kind.rs | 2 +- src/librustc/middle/lang_items.rs | 2 +- src/librustc/middle/lint.rs | 4 +- src/librustc/middle/liveness.rs | 2 +- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc/middle/moves.rs | 2 +- src/librustc/middle/pat_util.rs | 2 +- src/librustc/middle/privacy.rs | 2 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/region.rs | 2 +- src/librustc/middle/resolve.rs | 2 +- src/librustc/middle/resolve_lifetime.rs | 2 +- src/librustc/middle/subst.rs | 2 +- src/librustc/middle/trans/_match.rs | 26 +- src/librustc/middle/trans/adt.rs | 10 +- src/librustc/middle/trans/asm.rs | 2 +- src/librustc/middle/trans/base.rs | 2 +- src/librustc/middle/trans/builder.rs | 2 +- src/librustc/middle/trans/cabi.rs | 2 +- src/librustc/middle/trans/cabi_arm.rs | 2 +- src/librustc/middle/trans/cabi_mips.rs | 2 +- src/librustc/middle/trans/cabi_x86.rs | 2 +- src/librustc/middle/trans/cabi_x86_64.rs | 2 +- src/librustc/middle/trans/callee.rs | 6 +- src/librustc/middle/trans/closure.rs | 2 +- src/librustc/middle/trans/common.rs | 2 +- src/librustc/middle/trans/consts.rs | 6 +- src/librustc/middle/trans/context.rs | 2 +- src/librustc/middle/trans/debuginfo.rs | 2 +- src/librustc/middle/trans/expr.rs | 2 +- src/librustc/middle/trans/foreign.rs | 2 +- src/librustc/middle/trans/intrinsic.rs | 2 +- src/librustc/middle/trans/meth.rs | 8 +- src/librustc/middle/trans/monomorphize.rs | 2 +- src/librustc/middle/trans/reflect.rs | 16 +- src/librustc/middle/trans/type_.rs | 2 +- src/librustc/middle/trans/type_of.rs | 2 +- src/librustc/middle/ty.rs | 8 +- src/librustc/middle/ty_fold.rs | 2 +- src/librustc/middle/typeck/astconv.rs | 2 +- src/librustc/middle/typeck/check/_match.rs | 2 +- src/librustc/middle/typeck/check/method.rs | 6 +- src/librustc/middle/typeck/check/mod.rs | 8 +- src/librustc/middle/typeck/check/regionmanip.rs | 2 +- src/librustc/middle/typeck/check/vtable.rs | 2 +- src/librustc/middle/typeck/check/writeback.rs | 2 +- src/librustc/middle/typeck/coherence.rs | 6 +- src/librustc/middle/typeck/collect.rs | 10 +- src/librustc/middle/typeck/infer/combine.rs | 2 +- .../middle/typeck/infer/error_reporting.rs | 2 +- src/librustc/middle/typeck/infer/lattice.rs | 2 +- src/librustc/middle/typeck/infer/mod.rs | 2 +- .../middle/typeck/infer/region_inference/mod.rs | 2 +- src/librustc/middle/typeck/infer/resolve.rs | 2 +- src/librustc/middle/typeck/infer/unify.rs | 2 +- src/librustc/middle/typeck/mod.rs | 2 +- src/librustc/middle/typeck/rscope.rs | 2 +- src/librustc/middle/typeck/variance.rs | 2 +- src/librustc/util/common.rs | 2 +- src/librustc/util/ppaux.rs | 2 +- src/librustc/util/sha2.rs | 4 +- src/librustdoc/clean.rs | 2 +- src/librustdoc/html/render.rs | 2 +- src/librustdoc/html/toc.rs | 2 +- src/librustdoc/markdown.rs | 2 +- src/librustdoc/visit_ast.rs | 2 +- src/libsemver/lib.rs | 2 +- src/libserialize/serialize.rs | 2 +- src/libstd/ascii.rs | 4 +- src/libstd/hash/mod.rs | 2 +- src/libstd/io/fs.rs | 2 +- src/libstd/lib.rs | 5 +- src/libstd/macros.rs | 4 +- src/libstd/rt/local_heap.rs | 2 +- src/libstd/str.rs | 2 +- src/libstd/vec.rs | 1353 ++++++++++++++++++++ src/libstd/vec_ng.rs | 1353 -------------------- src/libsyntax/abi.rs | 2 +- src/libsyntax/ast.rs | 4 +- src/libsyntax/ast_map.rs | 2 +- src/libsyntax/ast_util.rs | 4 +- src/libsyntax/attr.rs | 2 +- src/libsyntax/codemap.rs | 2 +- src/libsyntax/crateid.rs | 2 +- src/libsyntax/ext/asm.rs | 2 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/build.rs | 4 +- src/libsyntax/ext/bytes.rs | 2 +- src/libsyntax/ext/cfg.rs | 2 +- src/libsyntax/ext/concat_idents.rs | 2 +- src/libsyntax/ext/deriving/clone.rs | 2 +- src/libsyntax/ext/deriving/cmp/eq.rs | 2 +- src/libsyntax/ext/deriving/cmp/ord.rs | 2 +- src/libsyntax/ext/deriving/cmp/totaleq.rs | 2 +- src/libsyntax/ext/deriving/cmp/totalord.rs | 2 +- src/libsyntax/ext/deriving/decodable.rs | 2 +- src/libsyntax/ext/deriving/default.rs | 2 +- src/libsyntax/ext/deriving/encodable.rs | 2 +- src/libsyntax/ext/deriving/generic.rs | 6 +- src/libsyntax/ext/deriving/hash.rs | 2 +- src/libsyntax/ext/deriving/primitive.rs | 2 +- src/libsyntax/ext/deriving/rand.rs | 2 +- src/libsyntax/ext/deriving/show.rs | 2 +- src/libsyntax/ext/deriving/ty.rs | 2 +- src/libsyntax/ext/deriving/zero.rs | 2 +- src/libsyntax/ext/env.rs | 2 +- src/libsyntax/ext/expand.rs | 4 +- src/libsyntax/ext/format.rs | 2 +- src/libsyntax/ext/mtwt.rs | 4 +- src/libsyntax/ext/quote.rs | 4 +- src/libsyntax/ext/registrar.rs | 2 +- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/ext/tt/macro_rules.rs | 2 +- src/libsyntax/ext/tt/transcribe.rs | 2 +- src/libsyntax/fold.rs | 2 +- src/libsyntax/opt_vec.rs | 2 +- src/libsyntax/parse/attr.rs | 2 +- src/libsyntax/parse/comments.rs | 2 +- src/libsyntax/parse/lexer.rs | 2 +- src/libsyntax/parse/mod.rs | 4 +- src/libsyntax/parse/parser.rs | 26 +- src/libsyntax/parse/token.rs | 2 +- src/libsyntax/print/pp.rs | 2 +- src/libsyntax/print/pprust.rs | 4 +- src/libsyntax/util/interner.rs | 2 +- src/libsyntax/util/parser_testing.rs | 2 +- src/libsyntax/util/small_vector.rs | 8 +- src/libsyntax/visit.rs | 2 +- src/liburl/lib.rs | 2 +- src/test/compile-fail/issue-11873.rs | 2 +- src/test/run-pass/overloaded-autoderef-count.rs | 2 +- src/test/run-pass/overloaded-deref-count.rs | 2 +- src/test/run-pass/typeck_type_placeholder_1.rs | 2 +- 175 files changed, 1633 insertions(+), 1630 deletions(-) create mode 100644 src/libstd/vec.rs delete mode 100644 src/libstd/vec_ng.rs (limited to 'src') diff --git a/src/libcollections/hashmap.rs b/src/libcollections/hashmap.rs index ba87e2106e4..a1f815df72e 100644 --- a/src/libcollections/hashmap.rs +++ b/src/libcollections/hashmap.rs @@ -1575,7 +1575,7 @@ mod test_map { use super::HashMap; use std::iter::{Iterator,range_inclusive,range_step_inclusive}; use std::local_data; - use std::vec_ng; + use std::vec; #[test] fn test_create_capacity_zero() { @@ -1599,7 +1599,7 @@ mod test_map { assert_eq!(*m.find(&2).unwrap(), 4); } - local_data_key!(drop_vector: vec_ng::Vec) + local_data_key!(drop_vector: vec::Vec) #[deriving(Hash, Eq)] struct Dropable { @@ -1625,7 +1625,7 @@ mod test_map { #[test] fn test_drops() { - local_data::set(drop_vector, vec_ng::Vec::from_elem(200, 0)); + local_data::set(drop_vector, vec::Vec::from_elem(200, 0)); { let mut m = HashMap::new(); diff --git a/src/liblog/directive.rs b/src/liblog/directive.rs index d33ad0c8185..9d5e1a8f9ed 100644 --- a/src/liblog/directive.rs +++ b/src/liblog/directive.rs @@ -9,7 +9,7 @@ // except according to those terms. use std::cmp; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Show, Clone)] pub struct LogDirective { diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 7d635b80dad..fa8daf79812 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -126,7 +126,7 @@ use std::local_data; use std::os; use std::rt; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use sync::one::{Once, ONCE_INIT}; diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index 123a0414c9c..a55dedd594d 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -19,7 +19,7 @@ use std::libc; use std::mem; use std::rt::rtio; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use io::{IoResult, retry, keep_going}; diff --git a/src/libnum/bigint.rs b/src/libnum/bigint.rs index 8861f90b928..cba24b478fc 100644 --- a/src/libnum/bigint.rs +++ b/src/libnum/bigint.rs @@ -28,8 +28,8 @@ use rand::Rng; use std::str; use std::uint; use std::{i64, u64}; -use std::vec_ng; -use std::vec_ng::Vec; +use std::vec; +use std::vec::Vec; /** A `BigDigit` is a `BigUint`'s composing element. @@ -753,7 +753,7 @@ impl BigUint { fn shl_unit(&self, n_unit: uint) -> BigUint { if n_unit == 0 || self.is_zero() { return (*self).clone(); } - return BigUint::new(vec_ng::append(Vec::from_elem(n_unit, ZERO_BIG_DIGIT), + return BigUint::new(vec::append(Vec::from_elem(n_unit, ZERO_BIG_DIGIT), self.data.as_slice())); } @@ -1461,7 +1461,7 @@ mod biguint_tests { use std::num::CheckedDiv; use rand::{task_rng}; use std::u64; - use std::vec_ng::Vec; + use std::vec::Vec; #[test] fn test_from_slice() { @@ -2195,7 +2195,7 @@ mod bigint_tests { use std::num::{ToPrimitive, FromPrimitive}; use rand::{task_rng}; use std::u64; - use std::vec_ng::Vec; + use std::vec::Vec; #[test] fn test_from_biguint() { diff --git a/src/libnum/rational.rs b/src/libnum/rational.rs index 6d0b6128f88..1e97d85aa17 100644 --- a/src/libnum/rational.rs +++ b/src/libnum/rational.rs @@ -16,7 +16,7 @@ use std::cmp; use std::fmt; use std::from_str::FromStr; use std::num::{Zero,One,ToStrRadix,FromStrRadix,Round}; -use std::vec_ng::Vec; +use std::vec::Vec; use bigint::{BigInt, BigUint, Sign, Plus, Minus}; /// Represents the ratio between 2 numbers. diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs index 863b91f9b32..e684c8b6528 100644 --- a/src/librustc/back/archive.rs +++ b/src/librustc/back/archive.rs @@ -16,7 +16,7 @@ use metadata::filesearch; use lib::llvm::{ArchiveRef, llvm}; use std::cast; -use std::vec_ng::Vec; +use std::vec::Vec; use std::io; use std::io::{fs, TempDir}; use std::libc; diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index edb9d11b11a..25802ac9d51 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -33,7 +33,7 @@ use std::ptr; use std::str; use std::io; use std::io::{fs, TempDir, Process}; -use std::vec_ng::Vec; +use std::vec::Vec; use flate; use serialize::hex::ToHex; use syntax::abi; @@ -105,7 +105,7 @@ pub mod write { use std::io::Process; use std::libc::{c_uint, c_int}; use std::str; - use std::vec_ng::Vec; + use std::vec::Vec; // On android, we by default compile for armv7 processors. This enables // things like double word CAS instructions (rather than emulating them) diff --git a/src/librustc/back/mips.rs b/src/librustc/back/mips.rs index 0de256ba8d8..c870e69b324 100644 --- a/src/librustc/back/mips.rs +++ b/src/librustc/back/mips.rs @@ -11,7 +11,7 @@ use back::target_strs; use driver::session::sess_os_to_meta_os; use metadata::loader::meta_section_name; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi; pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::t { diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 1d5448cea04..ede7b7f3d42 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -15,7 +15,7 @@ use metadata::filesearch; use collections::HashSet; use std::{os, slice}; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi; fn not_win32(os: abi::Os) -> bool { diff --git a/src/librustc/back/target_strs.rs b/src/librustc/back/target_strs.rs index c2a1a5598d5..b07c0b2136f 100644 --- a/src/librustc/back/target_strs.rs +++ b/src/librustc/back/target_strs.rs @@ -10,7 +10,7 @@ #[allow(non_camel_case_types)]; -use std::vec_ng::Vec; +use std::vec::Vec; pub struct t { module_asm: ~str, diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 1dc9e6b6545..0156ca12084 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -37,8 +37,8 @@ use std::io::fs; use std::io::MemReader; use std::mem::drop; use std::os; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use getopts::{optopt, optmulti, optflag, optflagopt}; use getopts; use syntax::ast; @@ -138,7 +138,7 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig { } else { InternedString::new("nogc") }); - return vec_ng::append(user_cfg.move_iter().collect(), + return vec::append(user_cfg.move_iter().collect(), default_cfg.as_slice()); } @@ -835,7 +835,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> session::Options { let level_short = level_name.slice_chars(0, 1); let level_short = level_short.to_ascii().to_upper().into_str(); - let flags = vec_ng::append(matches.opt_strs(level_short) + let flags = vec::append(matches.opt_strs(level_short) .move_iter() .collect(), matches.opt_strs(level_name)); diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 8d3048a80b2..b7b7019a28b 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -28,7 +28,7 @@ use syntax::{abi, ast, codemap}; use syntax; use std::cell::{Cell, RefCell}; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashSet; pub struct Config { @@ -407,7 +407,7 @@ macro_rules! cgoptions( } } - fn parse_list(slot: &mut ::std::vec_ng::Vec<~str>, v: Option<&str>) + fn parse_list(slot: &mut ::std::vec::Vec<~str>, v: Option<&str>) -> bool { match v { Some(s) => { diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 514d2a4a6e1..349451b4205 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::fold::Folder; use syntax::{ast, fold, attr}; use syntax::codemap; diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index 99de2060eee..bb6d3fe3b10 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -31,7 +31,7 @@ use syntax::parse::token; use driver::session::Session; use std::cell::Cell; -use std::vec_ng::Vec; +use std::vec::Vec; /// This is a list of all known features since the beginning of time. This list /// can never shrink, it may only be expanded (in order to prevent old programs diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs index 40747646167..8b403628f77 100644 --- a/src/librustc/front/std_inject.rs +++ b/src/librustc/front/std_inject.rs @@ -11,8 +11,8 @@ use driver::session::Session; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast; use syntax::attr; use syntax::codemap::DUMMY_SP; @@ -182,7 +182,7 @@ impl<'a> fold::Folder for PreludeInjector<'a> { span: DUMMY_SP, }; - let vis = vec_ng::append(vec!(vi2), module.view_items.as_slice()); + let vis = vec::append(vec!(vi2), module.view_items.as_slice()); // FIXME #2543: Bad copy. let new_module = ast::Mod { diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 27aba271127..2b71b0919c6 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -20,8 +20,8 @@ use metadata::creader::Loader; use std::cell::RefCell; use std::slice; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast_util::*; use syntax::attr::AttrMetaMethods; use syntax::attr; @@ -281,7 +281,7 @@ fn should_fail(i: @ast::Item) -> bool { fn add_test_module(cx: &TestCtxt, m: &ast::Mod) -> ast::Mod { let testmod = mk_test_module(cx); ast::Mod { - items: vec_ng::append_one(m.items.clone(), testmod), + items: vec::append_one(m.items.clone(), testmod), ..(*m).clone() } } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 9409d8c457f..ba2760afe5d 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -55,8 +55,8 @@ use std::io; use std::os; use std::str; use std::task; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast; use syntax::diagnostic::Emitter; use syntax::diagnostic; @@ -241,7 +241,7 @@ pub fn run_compiler(args: &[~str]) { return; } - let lint_flags = vec_ng::append(matches.opt_strs("W") + let lint_flags = vec::append(matches.opt_strs("W") .move_iter() .collect(), matches.opt_strs("warn")); diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 74e180072fa..4133a742c60 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -23,7 +23,7 @@ use metadata::loader; use metadata::loader::Os; use std::cell::RefCell; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashMap; use syntax::ast; use syntax::abi; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index d41d01f3c85..5ee01322913 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -20,8 +20,8 @@ use middle::typeck; use reader = serialize::ebml::reader; use std::rc::Rc; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast; use syntax::ast_map; use syntax::diagnostic::expect; @@ -94,7 +94,7 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec // FIXME #1920: This path is not always correct if the crate is not linked // into the root namespace. - vec_ng::append(vec!(ast_map::PathMod(token::intern(cdata.name))), + vec::append(vec!(ast_map::PathMod(token::intern(cdata.name))), path.as_slice()) } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index deadfb42904..886e46dc2a0 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -18,7 +18,7 @@ use metadata::decoder; use metadata::loader; use std::cell::RefCell; -use std::vec_ng::Vec; +use std::vec::Vec; use std::c_vec::CVec; use collections::HashMap; use syntax::ast; diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 8f785268ae0..449bda1eb5f 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -33,7 +33,7 @@ use std::io; use std::io::extensions::u64_from_be_bytes; use std::option; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; use serialize::ebml::reader; use serialize::ebml; use serialize::Decodable; diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index b869e0a7d91..a50cb1cbdba 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -32,7 +32,7 @@ use std::hash; use std::hash::Hash; use std::io::MemWriter; use std::str; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashMap; use syntax::abi::AbiSet; use syntax::ast::*; diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index f73a3f35c2b..666f44c685f 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -13,7 +13,7 @@ use std::cell::RefCell; use std::os; use std::io::fs; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashSet; pub enum FileMatch { FileMatches, FileDoesntMatch } diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 1181f0d0928..6a1e3663a54 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -31,7 +31,7 @@ use std::io; use std::os::consts::{macos, freebsd, linux, android, win32}; use std::str; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::{HashMap, HashSet}; use flate; diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 1abbf1307c1..029edd73e9f 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -20,7 +20,7 @@ use middle::ty; use std::str; use std::uint; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi::AbiSet; use syntax::abi; use syntax::ast; diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 0934b6407fb..7cec6532699 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -19,7 +19,7 @@ use std::io; use std::io::MemWriter; use std::str; use std::fmt; -use std::vec_ng::Vec; +use std::vec::Vec; use middle::ty::param_ty; use middle::ty; diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 883883e5046..5fea567fc7d 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -37,7 +37,7 @@ use std::cast; use std::cell::RefCell; use std::io::Seek; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; use serialize::ebml::reader; use serialize::ebml; diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 841123906cc..0399ce5954f 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -23,7 +23,7 @@ use middle::borrowck::*; use middle::moves; use middle::ty; use middle::typeck::MethodCall; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index 3c3c4371ebb..66be482eaef 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -27,7 +27,7 @@ use middle::typeck::MethodCall; use util::common::indenter; use util::ppaux::{Repr}; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_util; use syntax::ast_util::IdRange; diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc/middle/borrowck/gather_loans/restrictions.rs index 228e02fa0ac..fc5763b8841 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc/middle/borrowck/gather_loans/restrictions.rs @@ -12,8 +12,8 @@ * Computes the restrictions that result from a borrow. */ -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use middle::borrowck::*; use mc = middle::mem_categorization; use middle::ty; @@ -174,7 +174,7 @@ impl<'a> RestrictionsContext<'a> { Safe => Safe, SafeIf(base_lp, base_vec) => { let lp = @LpExtend(base_lp, mc, elem); - SafeIf(lp, vec_ng::append_one(base_vec, + SafeIf(lp, vec::append_one(base_vec, Restriction { loan_path: lp, set: restrictions diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index bb6956556b5..99e0ff6472f 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -25,7 +25,7 @@ use std::cell::{Cell, RefCell}; use collections::HashMap; use std::ops::{BitOr, BitAnd}; use std::result::{Result}; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_map; use syntax::ast_util; diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index 66e92583edb..5b2cca047cc 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -17,7 +17,7 @@ comments in the section "Moves and initialization" and in `doc.rs`. use std::cell::RefCell; use std::uint; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::{HashMap, HashSet}; use middle::borrowck::*; use middle::dataflow::DataFlowContext; diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index 1c3f62df73f..8fee8b1bf9d 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -12,7 +12,7 @@ use middle::cfg::*; use middle::graph; use middle::typeck; use middle::ty; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_util; use syntax::opt_vec; diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index e980712d1aa..c6f114cfbc5 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -15,7 +15,7 @@ use middle::ty; use middle::typeck; use util::ppaux; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::*; use syntax::{ast_util, ast_map}; use syntax::visit::Visitor; diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index ee759e65240..fe4a58a62eb 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -21,8 +21,8 @@ use util::ppaux::ty_to_str; use std::cmp; use std::iter; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast::*; use syntax::ast_util::{unguarded_pat, walk_pat}; use syntax::codemap::{DUMMY_SP, Span}; @@ -569,10 +569,10 @@ fn specialize(cx: &MatchCheckCtxt, Pat{id: pat_id, node: n, span: pat_span} => match n { PatWild => { - Some(vec_ng::append(Vec::from_elem(arity, wild()), r.tail())) + Some(vec::append(Vec::from_elem(arity, wild()), r.tail())) } PatWildMulti => { - Some(vec_ng::append(Vec::from_elem(arity, wild_multi()), + Some(vec::append(Vec::from_elem(arity, wild_multi()), r.tail())) } PatIdent(_, _, _) => { @@ -628,7 +628,7 @@ fn specialize(cx: &MatchCheckCtxt, } _ => { Some( - vec_ng::append( + vec::append( Vec::from_elem(arity, wild()), r.tail() ) @@ -682,7 +682,7 @@ fn specialize(cx: &MatchCheckCtxt, Some(args) => args.iter().map(|x| *x).collect(), None => Vec::from_elem(arity, wild()) }; - Some(vec_ng::append(args, r.tail())) + Some(vec::append(args, r.tail())) } DefVariant(_, _, _) => None, @@ -695,7 +695,7 @@ fn specialize(cx: &MatchCheckCtxt, } None => new_args = Vec::from_elem(arity, wild()) } - Some(vec_ng::append(new_args, r.tail())) + Some(vec::append(new_args, r.tail())) } _ => None } @@ -716,7 +716,7 @@ fn specialize(cx: &MatchCheckCtxt, _ => wild() } }); - Some(vec_ng::append(args, r.tail())) + Some(vec::append(args, r.tail())) } else { None } @@ -747,15 +747,15 @@ fn specialize(cx: &MatchCheckCtxt, _ => wild() } }).collect(); - Some(vec_ng::append(args, r.tail())) + Some(vec::append(args, r.tail())) } } } PatTup(args) => { - Some(vec_ng::append(args.iter().map(|x| *x).collect(), r.tail())) + Some(vec::append(args.iter().map(|x| *x).collect(), r.tail())) } PatUniq(a) | PatRegion(a) => { - Some(vec_ng::append(vec!(a), r.tail())) + Some(vec::append(vec!(a), r.tail())) } PatLit(expr) => { let e_v = eval_const_expr(cx.tcx, expr); diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index c5a466f599d..0507c2541d6 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -26,7 +26,7 @@ use syntax::{ast, ast_map, ast_util}; use std::cell::RefCell; use collections::HashMap; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; // // This pass classifies expressions by their constant-ness. diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index ac188557463..949eabb30de 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -20,7 +20,7 @@ use std::io; use std::uint; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_util; use syntax::ast_util::IdRange; diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 03d51f06ab5..58b8b55a2a0 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -19,7 +19,7 @@ use middle::typeck; use util::nodemap::NodeSet; use collections::HashSet; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_map; use syntax::ast_util::{local_def, def_id_of_def, is_local}; diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 88a6f7aa1e2..62e578886c5 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -11,7 +11,7 @@ use driver::session; use driver::session::Session; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::{Crate, Name, NodeId, Item, ItemFn}; use syntax::ast_map; use syntax::attr; diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index 1ccc5e51487..af1d0c57237 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -17,7 +17,7 @@ use middle::resolve; use middle::ty; use util::nodemap::{NodeMap, NodeSet}; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::codemap::Span; use syntax::{ast, ast_util}; use syntax::visit; diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 160a541bc34..8f2cbb4d241 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -35,7 +35,7 @@ be indexed by the direction (see the type `Direction`). */ use std::uint; -use std::vec_ng::Vec; +use std::vec::Vec; pub struct Graph { priv nodes: Vec> , diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 0f7106c3898..5c79020505a 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -16,7 +16,7 @@ use middle::typeck; use util::ppaux::{Repr, ty_to_str}; use util::ppaux::UserString; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::*; use syntax::attr; use syntax::codemap::Span; diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 3b322d02787..6362bb93246 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -33,7 +33,7 @@ use syntax::visit; use collections::HashMap; use std::iter::Enumerate; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; // The actual lang items defined come at the end of this file in one handy table. // So you probably just want to nip down to the end. diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 907d5fa621e..0bdc8384b04 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -58,7 +58,7 @@ use std::u16; use std::u32; use std::u64; use std::u8; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::SmallIntMap; use syntax::ast_map; use syntax::ast_util::IdVisitingOperation; @@ -1121,7 +1121,7 @@ fn check_deprecated_owned_vector(cx: &Context, e: &ast::Expr) { match ty::get(t).sty { ty::ty_vec(_, ty::vstore_uniq) => { cx.span_lint(DeprecatedOwnedVector, e.span, - "use of deprecated `~[]` vector; replaced by `std::vec_ng::Vec`") + "use of deprecated `~[]` vector; replaced by `std::vec::Vec`") } _ => {} } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 62998186ba3..ee526f81c28 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -116,7 +116,7 @@ use std::io; use std::rc::Rc; use std::str; use std::uint; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::*; use syntax::codemap::Span; use syntax::parse::token::special_idents; diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 7c95815af54..9efbd3a32d8 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -66,7 +66,7 @@ use middle::ty; use middle::typeck; use util::ppaux::{ty_to_str, region_ptr_to_str, Repr}; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 3d476832fd6..0135b8d360b 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -138,7 +138,7 @@ use util::ppaux::UserString; use util::nodemap::{NodeMap, NodeSet}; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::*; use syntax::ast_util; use syntax::visit; diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 3e645491699..431f2820d6e 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -12,7 +12,7 @@ use middle::resolve; use collections::HashMap; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::*; use syntax::ast_util::{path_to_ident, walk_pat}; use syntax::codemap::Span; diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 1de38d8a461..e4f5b175836 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -13,7 +13,7 @@ //! which are available for use externally when compiled as a library. use std::mem::replace; -use std::vec_ng::Vec; +use std::vec::Vec; use metadata::csearch; use middle::lint; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 44a0fb61b24..a0ca416380f 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -20,7 +20,7 @@ use middle::typeck; use middle::privacy; use util::nodemap::NodeSet; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashSet; use syntax::ast; use syntax::ast_map; diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index a13dce65f51..c0218429bb1 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -27,7 +27,7 @@ use middle::ty; use util::nodemap::NodeMap; use std::cell::RefCell; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::{HashMap, HashSet}; use syntax::codemap::Span; use syntax::{ast, visit}; diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 7a14452158f..10f0002ea46 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -34,7 +34,7 @@ use syntax::visit::Visitor; use std::cell::{Cell, RefCell}; use std::uint; use std::mem::replace; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::{HashMap, HashSet}; // Definition mapping diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index da424ea2e15..5d77d437bb9 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -18,7 +18,7 @@ */ use driver::session::Session; -use std::vec_ng::Vec; +use std::vec::Vec; use util::nodemap::NodeMap; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index f82b43adc43..25a2763ed2b 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -16,7 +16,7 @@ use middle::ty_fold::TypeFolder; use util::ppaux::Repr; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::codemap::Span; use syntax::opt_vec::OptVec; diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 7d69db92af2..060cb692bce 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -225,8 +225,8 @@ use util::ppaux::{Repr, vec_map_to_str}; use collections::HashMap; use std::cell::Cell; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast; use syntax::ast::Ident; use syntax::ast_util::path_to_ident; @@ -463,9 +463,9 @@ fn expand_nested_bindings<'r,'b>( m.iter().map(|br| { match br.pats.get(col).node { ast::PatIdent(_, ref path, Some(inner)) => { - let pats = vec_ng::append( + let pats = vec::append( Vec::from_slice(br.pats.slice(0u, col)), - vec_ng::append(vec!(inner), + vec::append(vec!(inner), br.pats.slice(col + 1u, br.pats.len())).as_slice()); @@ -513,8 +513,8 @@ fn enter_match<'r,'b>( match e(*br.pats.get(col)) { Some(sub) => { let pats = - vec_ng::append( - vec_ng::append(sub, br.pats.slice(0u, col)), + vec::append( + vec::append(sub, br.pats.slice(0u, col)), br.pats.slice(col + 1u, br.pats.len())); let this = *br.pats.get(col); @@ -1537,7 +1537,7 @@ fn compile_submatch_continue<'r, let tcx = bcx.tcx(); let dm = tcx.def_map; - let vals_left = vec_ng::append(Vec::from_slice(vals.slice(0u, col)), + let vals_left = vec::append(Vec::from_slice(vals.slice(0u, col)), vals.slice(col + 1u, vals.len())); let ccx = bcx.fcx.ccx; let mut pat_id = 0; @@ -1570,7 +1570,7 @@ fn compile_submatch_continue<'r, col, rec_fields.as_slice(), val).as_slice(), - vec_ng::append(rec_vals, + vec::append(rec_vals, vals_left.as_slice()).as_slice(), chk); }); @@ -1596,7 +1596,7 @@ fn compile_submatch_continue<'r, col, val, n_tup_elts).as_slice(), - vec_ng::append(tup_vals, + vec::append(tup_vals, vals_left.as_slice()).as_slice(), chk); return; @@ -1622,7 +1622,7 @@ fn compile_submatch_continue<'r, compile_submatch(bcx, enter_tuple_struct(bcx, dm, m, col, val, struct_element_count).as_slice(), - vec_ng::append(llstructvals, + vec::append(llstructvals, vals_left.as_slice()).as_slice(), chk); return; @@ -1632,7 +1632,7 @@ fn compile_submatch_continue<'r, let llbox = Load(bcx, val); compile_submatch(bcx, enter_uniq(bcx, dm, m, col, val).as_slice(), - vec_ng::append(vec!(llbox), + vec::append(vec!(llbox), vals_left.as_slice()).as_slice(), chk); return; @@ -1642,7 +1642,7 @@ fn compile_submatch_continue<'r, let loaded_val = Load(bcx, val); compile_submatch(bcx, enter_region(bcx, dm, m, col, val).as_slice(), - vec_ng::append(vec!(loaded_val), + vec::append(vec!(loaded_val), vals_left.as_slice()).as_slice(), chk); return; @@ -1824,7 +1824,7 @@ fn compile_submatch_continue<'r, lit(_) | range(_, _) => () } let opt_ms = enter_opt(opt_cx, m, opt, col, size, val); - let opt_vals = vec_ng::append(unpacked, vals_left.as_slice()); + let opt_vals = vec::append(unpacked, vals_left.as_slice()); match branch_chk { None => { diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index eb57ad022b6..7248792a51f 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -57,8 +57,8 @@ use middle::trans::type_::Type; use middle::trans::type_of; use middle::ty; use middle::ty::Disr; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::abi::{X86, X86_64, Arm, Mips}; use syntax::ast; use syntax::attr; @@ -226,7 +226,7 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { return General(ity, cases.map(|c| { let discr = vec!(ty_of_inttype(ity)); mk_struct(cx, - vec_ng::append(discr, c.tys.as_slice()).as_slice(), + vec::append(discr, c.tys.as_slice()).as_slice(), false) })) } @@ -758,10 +758,10 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr, let lldiscr = C_integral(ll_inttype(ccx, ity), discr as u64, true); let contents = build_const_struct(ccx, case, - vec_ng::append( + vec::append( vec!(lldiscr), vals).as_slice()); - C_struct(ccx, vec_ng::append( + C_struct(ccx, vec::append( contents, &[padding(ccx, max_sz - case.size)]).as_slice(), false) diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index 7b04b519101..9624b58f566 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -23,7 +23,7 @@ use middle::trans::type_of; use middle::trans::type_::Type; use std::c_str::ToCStr; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; // Take an inline assembly expression and splat it out via LLVM diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 7cdb4b07d03..20881eb243a 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -76,7 +76,7 @@ use std::c_str::ToCStr; use std::cell::{Cell, RefCell}; use std::libc::c_uint; use std::local_data; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi::{X86, X86_64, Arm, Mips, Rust, RustIntrinsic, OsWin32}; use syntax::ast_map::PathName; use syntax::ast_util::{local_def, is_local}; diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index c403d323bf4..9b071807429 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -20,7 +20,7 @@ use middle::trans::type_::Type; use collections::HashMap; use std::libc::{c_uint, c_ulonglong, c_char}; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::codemap::Span; pub struct Builder<'a> { diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs index 7e67673d160..79fdd737135 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc/middle/trans/cabi.rs @@ -16,7 +16,7 @@ use middle::trans::cabi_x86_64; use middle::trans::cabi_arm; use middle::trans::cabi_mips; use middle::trans::type_::Type; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi::{X86, X86_64, Arm, Mips}; #[deriving(Clone, Eq)] diff --git a/src/librustc/middle/trans/cabi_arm.rs b/src/librustc/middle/trans/cabi_arm.rs index 83805cf844f..94e2a50c620 100644 --- a/src/librustc/middle/trans/cabi_arm.rs +++ b/src/librustc/middle/trans/cabi_arm.rs @@ -18,7 +18,7 @@ use middle::trans::type_::Type; use std::cmp; use std::option::{None, Some}; -use std::vec_ng::Vec; +use std::vec::Vec; fn align_up_to(off: uint, a: uint) -> uint { return (off + a - 1u) / a * a; diff --git a/src/librustc/middle/trans/cabi_mips.rs b/src/librustc/middle/trans/cabi_mips.rs index 68d9bb82a6c..7e94bf8e666 100644 --- a/src/librustc/middle/trans/cabi_mips.rs +++ b/src/librustc/middle/trans/cabi_mips.rs @@ -18,7 +18,7 @@ use middle::trans::context::CrateContext; use middle::trans::cabi::*; use middle::trans::type_::Type; -use std::vec_ng::Vec; +use std::vec::Vec; fn align_up_to(off: uint, a: uint) -> uint { return (off + a - 1u) / a * a; diff --git a/src/librustc/middle/trans/cabi_x86.rs b/src/librustc/middle/trans/cabi_x86.rs index 85a7c14968f..243a9dffdc6 100644 --- a/src/librustc/middle/trans/cabi_x86.rs +++ b/src/librustc/middle/trans/cabi_x86.rs @@ -15,7 +15,7 @@ use super::cabi::*; use super::common::*; use super::machine::*; use middle::trans::type_::Type; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn compute_abi_info(ccx: &CrateContext, atys: &[Type], diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index c1ae28005d9..bf9c969b7ef 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -21,7 +21,7 @@ use middle::trans::context::CrateContext; use middle::trans::type_::Type; use std::cmp; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Clone, Eq)] enum RegClass { diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index c29f1082a11..5af126615a1 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -49,8 +49,8 @@ use util::ppaux::Repr; use middle::trans::type_::Type; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast; use syntax::abi::AbiSet; use syntax::ast_map; @@ -233,7 +233,7 @@ fn resolve_default_method_vtables(bcx: &Block, None => slice::from_elem(num_method_vtables, @Vec::new()) }; - let param_vtables = @(vec_ng::append((*trait_vtables_fixed).clone(), + let param_vtables = @(vec::append((*trait_vtables_fixed).clone(), method_vtables)); let self_vtables = resolve_param_vtables_under_param_substs( diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 05375ebeb31..daeafe4c897 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -27,7 +27,7 @@ use util::ppaux::Repr; use util::ppaux::ty_to_str; use arena::TypedArena; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_util; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index e812f36e85d..cb01d187957 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -35,7 +35,7 @@ use collections::HashMap; use std::c_str::ToCStr; use std::cell::{Cell, RefCell}; use std::libc::{c_uint, c_longlong, c_ulonglong, c_char}; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::Ident; use syntax::ast; use syntax::ast_map::{PathElem, PathName}; diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 61d6cac5250..49f07e140a3 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -34,8 +34,8 @@ use util::ppaux::{Repr, ty_to_str}; use std::c_str::ToCStr; use std::libc::c_uint; use std::slice; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::{ast, ast_util}; pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit) @@ -304,7 +304,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, exprs.iter().map(|&e| const_expr(cx, e, is_local)) .fold((Vec::new(), true), |(l, all_inlineable), (val, inlineable)| { - (vec_ng::append_one(l, val), all_inlineable && inlineable) + (vec::append_one(l, val), all_inlineable && inlineable) }) }; unsafe { diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 4ed4f0fb310..73869aa4622 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -33,7 +33,7 @@ use std::cell::{Cell, RefCell}; use std::c_str::ToCStr; use std::libc::c_uint; use std::ptr; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::{HashMap, HashSet}; use syntax::ast; use syntax::parse::token::InternedString; diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index d507d6d2db4..dc4a6e37c3e 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -149,7 +149,7 @@ use std::libc::{c_uint, c_ulonglong, c_longlong}; use std::ptr; use std::sync::atomics; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::codemap::{Span, Pos}; use syntax::{abi, ast, codemap, ast_util, ast_map, opt_vec}; use syntax::parse::token; diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 6e74b82f85c..75b14c081f9 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -71,7 +71,7 @@ use middle::trans::machine::llsize_of; use middle::trans::type_::Type; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::codemap; use syntax::print::pprust::{expr_to_str}; diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 74bed116806..be9888a61d7 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -27,7 +27,7 @@ use middle::ty::FnSig; use middle::ty; use std::cmp; use std::libc::c_uint; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi::{Cdecl, Aapcs, C, AbiSet, Win64}; use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall, System}; use syntax::codemap::Span; diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index 98e63641c12..e7ccb52108f 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -25,7 +25,7 @@ use middle::trans::machine; use middle::trans::machine::llsize_of; use middle::trans::type_::Type; use middle::ty; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_map; use syntax::parse::token; diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index cd33bcf6031..b248bf39645 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -34,8 +34,8 @@ use util::common::indenter; use util::ppaux::Repr; use std::c_str::ToCStr; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::parse::token; use syntax::{ast, ast_map, visit}; @@ -324,7 +324,7 @@ fn combine_impl_and_methods_tps(bcx: &Block, let node_substs = node_id_type_params(bcx, node); debug!("rcvr_substs={:?}", rcvr_substs.repr(ccx.tcx())); let ty_substs - = vec_ng::append(Vec::from_slice(rcvr_substs), + = vec::append(Vec::from_slice(rcvr_substs), node_substs.tailn(node_substs.len() - n_m_tps)); debug!("n_m_tps={:?}", n_m_tps); debug!("node_substs={:?}", node_substs.repr(ccx.tcx())); @@ -348,7 +348,7 @@ fn combine_impl_and_methods_tps(bcx: &Block, None => @Vec::from_elem(node_substs.len(), @Vec::new()) }; let vtables - = @vec_ng::append(Vec::from_slice(rcvr_origins.as_slice()), + = @vec::append(Vec::from_slice(rcvr_origins.as_slice()), r_m_origins.tailn(r_m_origins.len() - n_m_tps)); (ty_substs, vtables) diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 0d9b6a087f9..aed1f1b24d0 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -23,7 +23,7 @@ use middle::ty; use middle::typeck; use util::ppaux::Repr; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_map; use syntax::ast_util::local_def; diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 707cb2c8806..833f33c720a 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -28,8 +28,8 @@ use util::ppaux::ty_to_str; use arena::TypedArena; use std::libc::c_uint; use std::option::{Some,None}; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast::DefId; use syntax::ast; use syntax::ast_map; @@ -134,7 +134,7 @@ impl<'a> Reflector<'a> { -> (~str, Vec ) { match vstore { ty::vstore_fixed(n) => { - let extra = vec_ng::append(vec!(self.c_uint(n)), + let extra = vec::append(vec!(self.c_uint(n)), self.c_size_and_align(t) .as_slice()); (~"fixed", extra) @@ -184,7 +184,7 @@ impl<'a> Reflector<'a> { } ty::ty_vec(ref mt, vst) => { let (name, extra) = self.vstore_name_and_extra(t, vst); - let extra = vec_ng::append(extra, self.c_mt(mt).as_slice()); + let extra = vec::append(extra, self.c_mt(mt).as_slice()); self.visit(~"evec_" + name, extra.as_slice()) } // Should remove mt from box and uniq. @@ -212,7 +212,7 @@ impl<'a> Reflector<'a> { } ty::ty_tup(ref tys) => { - let extra = vec_ng::append(vec!(self.c_uint(tys.len())), + let extra = vec::append(vec!(self.c_uint(tys.len())), self.c_size_and_align(t).as_slice()); self.bracketed("tup", extra.as_slice(), |this| { for (i, t) in tys.iter().enumerate() { @@ -260,7 +260,7 @@ impl<'a> Reflector<'a> { special_idents::unnamed_field.name; } - let extra = vec_ng::append(vec!( + let extra = vec::append(vec!( self.c_slice(token::intern_and_get_ident(ty_to_str(tcx, t))), self.c_bool(named_fields), @@ -268,7 +268,7 @@ impl<'a> Reflector<'a> { ), self.c_size_and_align(t).as_slice()); self.bracketed("class", extra.as_slice(), |this| { for (i, field) in fields.iter().enumerate() { - let extra = vec_ng::append(vec!( + let extra = vec::append(vec!( this.c_uint(i), this.c_slice(token::get_ident(field.ident)), this.c_bool(named_fields) @@ -321,7 +321,7 @@ impl<'a> Reflector<'a> { llfdecl }; - let enum_args = vec_ng::append(vec!(self.c_uint(variants.len()), + let enum_args = vec::append(vec!(self.c_uint(variants.len()), make_get_disr()), self.c_size_and_align(t) .as_slice()); diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs index cf64e6048b3..2a0c65216a7 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc/middle/trans/type_.rs @@ -21,7 +21,7 @@ use syntax::abi::{X86, X86_64, Arm, Mips}; use std::c_str::ToCStr; use std::cast; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use std::libc::{c_uint}; diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 32821f32df5..c8f8df17a74 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -19,7 +19,7 @@ use util::ppaux::Repr; use middle::trans::type_::Type; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::opt_vec; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 61371cec49e..afdd9b55812 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -40,8 +40,8 @@ use std::fmt; use std::hash::{Hash, sip}; use std::ops; use std::rc::Rc; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use collections::{HashMap, HashSet}; use syntax::ast::*; use syntax::ast_util::{is_local, lit_is_str}; @@ -2901,7 +2901,7 @@ pub fn replace_closure_return_type(tcx: &ctxt, fn_type: t, ret_type: t) -> t { // Returns a vec of all the input and output types of fty. pub fn tys_in_fn_sig(sig: &FnSig) -> Vec { - vec_ng::append_one(sig.inputs.map(|a| *a), sig.output) + vec::append_one(sig.inputs.map(|a| *a), sig.output) } // Type accessors for AST nodes @@ -3234,7 +3234,7 @@ pub fn method_call_type_param_defs(tcx: &ctxt, origin: typeck::MethodOrigin) // trait itself. This ought to be harmonized. let trait_type_param_defs = lookup_trait_def(tcx, trt_id).generics.type_param_defs(); - Rc::new(vec_ng::append( + Rc::new(vec::append( Vec::from_slice(trait_type_param_defs), ty::trait_method(tcx, trt_id, diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index f75d707b0f3..caec263389f 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -13,7 +13,7 @@ use middle::ty; use util::ppaux::Repr; -use std::vec_ng::Vec; +use std::vec::Vec; pub trait TypeFolder { fn tcx<'a>(&'a self) -> &'a ty::ctxt; diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 658538bcec8..177cadbce46 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -60,7 +60,7 @@ use middle::typeck::rscope::{RegionScope}; use middle::typeck::lookup_def_tcx; use util::ppaux::Repr; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi::AbiSet; use syntax::{ast, ast_util}; use syntax::codemap::Span; diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index bfb0ab6400d..8ba2c63ecb1 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -20,7 +20,7 @@ use middle::typeck::infer; use middle::typeck::require_same_types; use collections::{HashMap, HashSet}; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_util; use syntax::parse::token; diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 06a2c0b17b5..0a95a891398 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -97,8 +97,8 @@ use util::ppaux::Repr; use collections::HashSet; use std::result; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::ast::{DefId, SelfValue, SelfRegion}; use syntax::ast::{SelfUniq, SelfStatic}; use syntax::ast::{MutMutable, MutImmutable}; @@ -1118,7 +1118,7 @@ impl<'a> LookupContext<'a> { // Construct the full set of type parameters for the method, // which is equal to the class tps + the method tps. let all_substs = substs { - tps: vec_ng::append(candidate.rcvr_substs.tps.clone(), + tps: vec::append(candidate.rcvr_substs.tps.clone(), m_substs.as_slice()), regions: NonerasedRegions(all_regions), self_ty: candidate.rcvr_substs.self_ty, diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 4cf8f139d5a..13808d6df13 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -119,8 +119,8 @@ use collections::HashMap; use std::mem::replace; use std::result; use std::slice; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use syntax::abi::AbiSet; use syntax::ast::{Provided, Required}; use syntax::ast; @@ -910,7 +910,7 @@ fn compare_impl_method(tcx: &ty::ctxt, bound_region: ty::BrNamed(l.def_id, l.name)})). collect(); let dummy_substs = ty::substs { - tps: vec_ng::append(dummy_impl_tps, dummy_method_tps.as_slice()), + tps: vec::append(dummy_impl_tps, dummy_method_tps.as_slice()), regions: ty::NonerasedRegions(dummy_impl_regions), self_ty: None }; @@ -937,7 +937,7 @@ fn compare_impl_method(tcx: &ty::ctxt, self_ty: self_ty } = trait_substs.subst(tcx, &dummy_substs); let substs = substs { regions: trait_regions, - tps: vec_ng::append(trait_tps, dummy_method_tps.as_slice()), + tps: vec::append(trait_tps, dummy_method_tps.as_slice()), self_ty: self_ty, }; debug!("trait_fty (pre-subst): {} substs={}", diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index 45eab7c7e62..479a1e94b67 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -15,7 +15,7 @@ use middle::ty_fold; use middle::ty_fold::TypeFolder; use collections::HashMap; -use std::vec_ng::Vec; +use std::vec::Vec; use util::ppaux::Repr; use util::ppaux; diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 890ed033b38..9d181b27b4f 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -30,7 +30,7 @@ use util::ppaux::Repr; use collections::HashSet; use std::cell::RefCell; use std::result; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 1c03328bcea..e68fb5c7f13 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -28,7 +28,7 @@ use middle::typeck::write_ty_to_tcx; use util::ppaux; use util::ppaux::Repr; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::codemap::Span; use syntax::print::pprust::pat_to_str; diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index ac77ac20a7a..c50f15ed816 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -48,8 +48,8 @@ use syntax::visit; use collections::HashSet; use std::cell::RefCell; use std::rc::Rc; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; struct UniversalQuantificationResult { monotype: t, @@ -347,7 +347,7 @@ impl<'a> CoherenceChecker<'a> { // construct the polytype for the method based on the method_ty let new_generics = ty::Generics { type_param_defs: - Rc::new(vec_ng::append( + Rc::new(vec::append( Vec::from_slice(impl_poly_type.generics .type_param_defs()), new_method_ty.generics.type_param_defs())), diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index f65c168f382..6d15b3fd1f0 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -46,8 +46,8 @@ use util::ppaux; use util::ppaux::Repr; use std::rc::Rc; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; use collections::HashSet; use syntax::abi::AbiSet; @@ -330,7 +330,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, trait_id: ast::NodeId) { let substs = substs { regions: ty::NonerasedRegions(rps_from_trait), self_ty: Some(self_param), - tps: vec_ng::append(non_shifted_trait_tps, + tps: vec::append(non_shifted_trait_tps, shifted_method_tps.as_slice()) }; @@ -510,11 +510,11 @@ fn convert_methods(ccx: &CrateCtxt, // itself ty_param_bounds_and_ty { generics: ty::Generics { - type_param_defs: Rc::new(vec_ng::append( + type_param_defs: Rc::new(vec::append( Vec::from_slice( rcvr_ty_generics.type_param_defs()), m_ty_generics.type_param_defs())), - region_param_defs: Rc::new(vec_ng::append( + region_param_defs: Rc::new(vec::append( Vec::from_slice(rcvr_ty_generics.region_param_defs()), m_ty_generics.region_param_defs())), }, diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index b05e168e943..5b52a3551dd 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -63,7 +63,7 @@ use util::common::indent; use util::ppaux::Repr; use std::result; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::{Onceness, Purity}; use syntax::ast; use syntax::opt_vec; diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index b0cd5e361e9..1f6708a6f5c 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -76,7 +76,7 @@ use middle::typeck::infer::region_inference::ProcessedErrors; use middle::typeck::infer::region_inference::SameRegions; use std::cell::{Cell, RefCell}; use std::char::from_u32; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_map; use syntax::ast_util; diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index a97f1561c8d..ce344c9d561 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -46,7 +46,7 @@ use middle::typeck::infer::to_str::InferStr; use util::common::indenter; use collections::HashMap; -use std::vec_ng::Vec; +use std::vec::Vec; pub trait LatticeValue { fn sub(cf: &CombineFields, a: &Self, b: &Self) -> ures; diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index fc1970b09d4..ccc589f0eef 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -39,7 +39,7 @@ use middle::typeck::infer::unify::{ValsAndBindings, Root}; use middle::typeck::infer::error_reporting::ErrorReporting; use std::cell::{Cell, RefCell}; use std::result; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; use syntax::codemap; diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 4e570edcaef..6019de0b2d9 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -27,7 +27,7 @@ use util::ppaux::{Repr}; use std::cell::{Cell, RefCell}; use std::uint; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::{HashMap, HashSet}; use syntax::ast; use syntax::opt_vec; diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index f91e20a649b..929b4ac433c 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -58,7 +58,7 @@ use middle::typeck::infer::unify::{Root, UnifyInferCtxtMethods}; use util::common::{indent, indenter}; use util::ppaux::ty_to_str; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; pub static resolve_nested_tvar: uint = 0b0000000001; diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 57a08d211c7..a5c95bbfd5a 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -17,7 +17,7 @@ use middle::typeck::infer::{Bounds, uok, ures}; use middle::typeck::infer::InferCtxt; use middle::typeck::infer::to_str::InferStr; use std::cell::RefCell; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; #[deriving(Clone)] diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index bf34e7c1351..28e5559b32b 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -72,7 +72,7 @@ use util::nodemap::{DefIdMap, FnvHashMap, NodeMap}; use std::cell::RefCell; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::List; use syntax::codemap::Span; use syntax::print::pprust::*; diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index 078415bc644..3ead54ee9f5 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -12,7 +12,7 @@ use middle::ty; use std::cell::Cell; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::codemap::Span; use syntax::opt_vec::OptVec; diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index f9c336a4994..90bb1eb59a9 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -197,7 +197,7 @@ use arena; use arena::Arena; use middle::ty; use std::fmt; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::ast; use syntax::ast_util; use syntax::opt_vec; diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index fb417390905..03f73f9ae9e 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -16,7 +16,7 @@ use syntax::visit; use syntax::visit::Visitor; use std::local_data; -use std::vec_ng::Vec; +use std::vec::Vec; use time; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 7c03c1dc45d..b6ddcd01950 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -23,7 +23,7 @@ use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_unboxed_vec, ty_infer}; use middle::ty; use middle::typeck; -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi::AbiSet; use syntax::ast_map; use syntax::codemap::{Span, Pos}; diff --git a/src/librustc/util/sha2.rs b/src/librustc/util/sha2.rs index 8518b11ecf1..afc061ba813 100644 --- a/src/librustc/util/sha2.rs +++ b/src/librustc/util/sha2.rs @@ -15,7 +15,7 @@ use std::iter::range_step; use std::num::Zero; use std::slice::bytes::{MutableByteVector, copy_memory}; -use std::vec_ng::Vec; +use std::vec::Vec; use serialize::hex::ToHex; /// Write a u32 into a vector, which must be 4 bytes long. The value is written in big-endian @@ -529,7 +529,7 @@ mod tests { use super::{Digest, Sha256, FixedBuffer}; use std::num::Bounded; use std::slice; - use std::vec_ng::Vec; + use std::vec::Vec; use self::rand::isaac::IsaacRng; use self::rand::Rng; use serialize::hex::FromHex; diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 2ac3834ea49..6402ed1c9f8 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -30,7 +30,7 @@ use core; use doctree; use visit_ast; use std::local_data; -use std::vec_ng::Vec; +use std::vec::Vec; pub trait Clean { fn clean(&self) -> T; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index c77c666e3c0..bfc3555f16a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -39,7 +39,7 @@ use std::io; use std::io::{fs, File, BufferedWriter, MemWriter, BufferedReader}; use std::str; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::{HashMap, HashSet}; use sync::Arc; diff --git a/src/librustdoc/html/toc.rs b/src/librustdoc/html/toc.rs index 61031c222e7..db694a26a56 100644 --- a/src/librustdoc/html/toc.rs +++ b/src/librustdoc/html/toc.rs @@ -11,7 +11,7 @@ //! Table-of-contents creation. use std::fmt; -use std::vec_ng::Vec; +use std::vec::Vec; /// A (recursive) table of contents #[deriving(Eq)] diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index bd15d1b1331..1ed0c57b854 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -9,7 +9,7 @@ // except according to those terms. use std::{str, io}; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashSet; diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index c0a39112b69..1398926827d 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -11,7 +11,7 @@ //! Rust AST Visitor. Extracts useful information and massages it into a form //! usable for clean -use std::vec_ng::Vec; +use std::vec::Vec; use syntax::abi::AbiSet; use syntax::ast; use syntax::ast_util; diff --git a/src/libsemver/lib.rs b/src/libsemver/lib.rs index 6cbfeee6aa7..4ff19393790 100644 --- a/src/libsemver/lib.rs +++ b/src/libsemver/lib.rs @@ -41,7 +41,7 @@ use std::cmp; use std::fmt; use std::fmt::Show; use std::option::{Option, Some, None}; -use std::vec_ng::Vec; +use std::vec::Vec; /// An identifier in the pre-release or build metadata. If the identifier can /// be parsed as a decimal value, it will be represented with `Numeric`. diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index a103d0f4964..18692de2cb4 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -17,7 +17,7 @@ Core encoding and decoding interfaces. use std::path; use std::rc::Rc; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; pub trait Encoder { // Primitive types: diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 33638fffc6d..63632770230 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -20,7 +20,7 @@ use cast; use fmt; use iter::Iterator; use slice::{ImmutableVector, MutableVector, Vector}; -use vec_ng::Vec; +use vec::Vec; use option::{Option, Some, None}; /// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero. @@ -482,7 +482,7 @@ mod tests { use super::*; use str::from_char; use char::from_u32; - use vec_ng::Vec; + use vec::Vec; macro_rules! v2ascii ( ( [$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); diff --git a/src/libstd/hash/mod.rs b/src/libstd/hash/mod.rs index d329c15a7d7..3791aa38b82 100644 --- a/src/libstd/hash/mod.rs +++ b/src/libstd/hash/mod.rs @@ -71,7 +71,7 @@ use option::{Option, Some, None}; use rc::Rc; use str::{Str, StrSlice}; use slice::{Vector, ImmutableVector}; -use vec_ng::Vec; +use vec::Vec; /// Reexport the `sip::hash` function as our default hasher. pub use hash = self::sip::hash; diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index aab2f8c887c..870f33733f4 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -63,7 +63,7 @@ use result::{Ok, Err}; use path; use path::{Path, GenericPath}; use slice::{OwnedVector, ImmutableVector}; -use vec_ng::Vec; +use vec::Vec; /// Unconstrained file access type that exposes read and write operations /// diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index c6a1d710a52..302f899efda 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -84,6 +84,9 @@ #[cfg(test)] pub use ops = realstd::ops; #[cfg(test)] pub use cmp = realstd::cmp; +#[cfg(stage0)] +pub use vec_ng = vec; + pub mod macros; mod rtdeps; @@ -120,7 +123,7 @@ pub mod char; pub mod tuple; pub mod slice; -pub mod vec_ng; +pub mod vec; pub mod str; pub mod ascii; diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 6d96ea94d31..d183fae3ac6 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -265,12 +265,12 @@ macro_rules! try( ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) }) ) -/// Create a `std::vec_ng::Vec` containing the arguments. +/// Create a `std::vec::Vec` containing the arguments. #[macro_export] macro_rules! vec( ($($e:expr),*) => ({ // leading _ to allow empty construction without a warning. - let mut _temp = ::std::vec_ng::Vec::new(); + let mut _temp = ::std::vec::Vec::new(); $(_temp.push($e);)* _temp }) diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index 91452f5aa0d..a682a6141b1 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -22,7 +22,7 @@ use rt::local::Local; use rt::task::Task; use raw; use slice::ImmutableVector; -use vec_ng::Vec; +use vec::Vec; // This has no meaning with out rtdebug also turned on. #[cfg(rtdebug)] diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 92e86a5cccb..37aad3f9411 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -101,7 +101,7 @@ use ptr::RawPtr; use from_str::FromStr; use slice; use slice::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector}; -use vec_ng::Vec; +use vec::Vec; use default::Default; use raw::Repr; diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs new file mode 100644 index 00000000000..7a4a7da2a68 --- /dev/null +++ b/src/libstd/vec.rs @@ -0,0 +1,1353 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +//! A growable, owned vector + +use cast::{forget, transmute}; +use clone::Clone; +use cmp::{Ord, Eq, Ordering, TotalEq, TotalOrd}; +use container::{Container, Mutable}; +use default::Default; +use fmt; +use iter::{DoubleEndedIterator, FromIterator, Extendable, Iterator}; +use libc::{free, c_void}; +use mem::{size_of, move_val_init}; +use mem; +use num; +use num::{CheckedMul, CheckedAdd}; +use ops::Drop; +use option::{None, Option, Some}; +use ptr::RawPtr; +use ptr; +use rt::global_heap::{malloc_raw, realloc_raw}; +use raw::Slice; +use slice::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector}; +use slice::{MutableTotalOrdVector}; + +/// An owned, growable vector +/// +/// `Vec` is the replacement for the deprecated `~[T]` type. The API is +/// largely the same. The `vec!` macro is provided to make initialization +/// easier. +/// +/// # Example +/// +/// ```rust +/// let mut vec = vec!(1, 2, 3); +/// vec.push(4); +/// println!("{}", vec); // prints [1, 2, 3, 4] +/// ``` +#[unsafe_no_drop_flag] +pub struct Vec { + priv len: uint, + priv cap: uint, + priv ptr: *mut T +} + +impl Vec { + /// Constructs a new, empty `Vec`. + /// + /// The vector will not allocate until elements are pushed onto it. + /// + /// # Example + /// + /// ```rust + /// # use std::vec::Vec; + /// let mut vec: Vec = Vec::new(); + /// ``` + #[inline] + pub fn new() -> Vec { + Vec { len: 0, cap: 0, ptr: 0 as *mut T } + } + + /// Constructs a new, empty `Vec` with the specified capacity. + /// + /// The vector will be able to hold exactly `capacity` elements without + /// reallocating. If `capacity` is 0, the vector will not allocate. + /// + /// # Example + /// + /// ```rust + /// # use std::vec::Vec; + /// let vec: Vec = Vec::with_capacity(10); + /// ``` + pub fn with_capacity(capacity: uint) -> Vec { + if capacity == 0 { + Vec::new() + } else { + let size = capacity.checked_mul(&size_of::()).expect("capacity overflow"); + let ptr = unsafe { malloc_raw(size) }; + Vec { len: 0, cap: capacity, ptr: ptr as *mut T } + } + } + + + /// Creates and initializes a `Vec`. + /// + /// Creates a `Vec` of size `length` and initializes the elements to the + /// value returned by the closure `op`. + /// + /// # Example + /// + /// ```rust + /// # use std::vec::Vec; + /// let vec = Vec::from_fn(3, |idx| idx * 2); + /// assert_eq!(vec, vec!(0, 2, 4)); + /// ``` + pub fn from_fn(length: uint, op: |uint| -> T) -> Vec { + unsafe { + let mut xs = Vec::with_capacity(length); + while xs.len < length { + move_val_init(xs.as_mut_slice().unsafe_mut_ref(xs.len), op(xs.len)); + xs.len += 1; + } + xs + } + } + + /// Consumes the `Vec`, partitioning it based on a predcate. + /// + /// Partitions the `Vec` into two `Vec`s `(A,B)`, where all elements of `A` + /// satisfy `f` and all elements of `B` do not. The order of elements is + /// preserved. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3, 4); + /// let (even, odd) = vec.partition(|&n| n % 2 == 0); + /// assert_eq!(even, vec!(2, 4)); + /// assert_eq!(odd, vec!(1, 3)); + /// ``` + #[inline] + pub fn partition(self, f: |&T| -> bool) -> (Vec, Vec) { + let mut lefts = Vec::new(); + let mut rights = Vec::new(); + + for elt in self.move_iter() { + if f(&elt) { + lefts.push(elt); + } else { + rights.push(elt); + } + } + + (lefts, rights) + } +} + +impl Vec { + /// Constructs a `Vec` by cloning elements of a slice. + /// + /// # Example + /// + /// ```rust + /// # use std::vec::Vec; + /// let slice = [1, 2, 3]; + /// let vec = Vec::from_slice(slice); + /// ``` + pub fn from_slice(values: &[T]) -> Vec { + values.iter().map(|x| x.clone()).collect() + } + + /// Constructs a `Vec` with copies of a value. + /// + /// Creates a `Vec` with `length` copies of `value`. + /// + /// # Example + /// ```rust + /// # use std::vec::Vec; + /// let vec = Vec::from_elem(3, "hi"); + /// println!("{}", vec); // prints [hi, hi, hi] + /// ``` + pub fn from_elem(length: uint, value: T) -> Vec { + unsafe { + let mut xs = Vec::with_capacity(length); + while xs.len < length { + move_val_init(xs.as_mut_slice().unsafe_mut_ref(xs.len), value.clone()); + xs.len += 1; + } + xs + } + } + + /// Appends all elements in a slice to the `Vec`. + /// + /// Iterates over the slice `other`, clones each element, and then appends + /// it to this `Vec`. The `other` vector is traversed in-order. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1); + /// vec.push_all([2, 3, 4]); + /// assert_eq!(vec, vec!(1, 2, 3, 4)); + /// ``` + #[inline] + pub fn push_all(&mut self, other: &[T]) { + for element in other.iter() { + self.push((*element).clone()) + } + } + + /// Grows the `Vec` in-place. + /// + /// Adds `n` copies of `value` to the `Vec`. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!("hello"); + /// vec.grow(2, & &"world"); + /// assert_eq!(vec, vec!("hello", "world", "world")); + /// ``` + pub fn grow(&mut self, n: uint, value: &T) { + let new_len = self.len() + n; + self.reserve(new_len); + let mut i: uint = 0u; + + while i < n { + self.push((*value).clone()); + i += 1u; + } + } + + /// Sets the value of a vector element at a given index, growing the vector + /// as needed. + /// + /// Sets the element at position `index` to `value`. If `index` is past the + /// end of the vector, expands the vector by replicating `initval` to fill + /// the intervening space. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!("a", "b", "c"); + /// vec.grow_set(1, & &"fill", "d"); + /// vec.grow_set(4, & &"fill", "e"); + /// assert_eq!(vec, vec!("a", "d", "c", "fill", "e")); + /// ``` + pub fn grow_set(&mut self, index: uint, initval: &T, value: T) { + let l = self.len(); + if index >= l { + self.grow(index - l + 1u, initval); + } + *self.get_mut(index) = value; + } + + /// Partitions a vector based on a predcate. + /// + /// Clones the elements of the vector, partitioning them into two `Vec`s + /// `(A,B)`, where all elements of `A` satisfy `f` and all elements of `B` + /// do not. The order of elements is preserved. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3, 4); + /// let (even, odd) = vec.partitioned(|&n| n % 2 == 0); + /// assert_eq!(even, vec!(2, 4)); + /// assert_eq!(odd, vec!(1, 3)); + /// ``` + pub fn partitioned(&self, f: |&T| -> bool) -> (Vec, Vec) { + let mut lefts = Vec::new(); + let mut rights = Vec::new(); + + for elt in self.iter() { + if f(elt) { + lefts.push(elt.clone()); + } else { + rights.push(elt.clone()); + } + } + + (lefts, rights) + } +} + +impl Clone for Vec { + fn clone(&self) -> Vec { + let mut vector = Vec::with_capacity(self.len()); + for element in self.iter() { + vector.push((*element).clone()) + } + vector + } +} + +impl FromIterator for Vec { + fn from_iterator>(iterator: &mut I) -> Vec { + let (lower, _) = iterator.size_hint(); + let mut vector = Vec::with_capacity(lower); + for element in *iterator { + vector.push(element) + } + vector + } +} + +impl Extendable for Vec { + fn extend>(&mut self, iterator: &mut I) { + let (lower, _) = iterator.size_hint(); + self.reserve_additional(lower); + for element in *iterator { + self.push(element) + } + } +} + +impl Eq for Vec { + #[inline] + fn eq(&self, other: &Vec) -> bool { + self.as_slice() == other.as_slice() + } +} + +impl Ord for Vec { + #[inline] + fn lt(&self, other: &Vec) -> bool { + self.as_slice() < other.as_slice() + } +} + +impl TotalEq for Vec { + #[inline] + fn equals(&self, other: &Vec) -> bool { + self.as_slice().equals(&other.as_slice()) + } +} + +impl TotalOrd for Vec { + #[inline] + fn cmp(&self, other: &Vec) -> Ordering { + self.as_slice().cmp(&other.as_slice()) + } +} + +impl Container for Vec { + #[inline] + fn len(&self) -> uint { + self.len + } +} + +impl Vec { + /// Returns the number of elements the vector can hold without + /// reallocating. + /// + /// # Example + /// + /// ```rust + /// # use std::vec::Vec; + /// let vec: Vec = Vec::with_capacity(10); + /// assert_eq!(vec.capacity(), 10); + /// ``` + #[inline] + pub fn capacity(&self) -> uint { + self.cap + } + + /// Reserves capacity for at least `n` additional elements in the given + /// vector. + /// + /// # Failure + /// + /// Fails if the new capacity overflows `uint`. + /// + /// # Example + /// + /// ```rust + /// # use std::vec::Vec; + /// let mut vec: Vec = vec!(1); + /// vec.reserve_additional(10); + /// assert!(vec.capacity() >= 11); + /// ``` + pub fn reserve_additional(&mut self, extra: uint) { + if self.cap - self.len < extra { + match self.len.checked_add(&extra) { + None => fail!("Vec::reserve_additional: `uint` overflow"), + Some(new_cap) => self.reserve(new_cap) + } + } + } + + /// Reserves capacity for at least `n` elements in the given vector. + /// + /// This function will over-allocate in order to amortize the allocation + /// costs in scenarios where the caller may need to repeatedly reserve + /// additional space. + /// + /// If the capacity for `self` is already equal to or greater than the + /// requested capacity, then no action is taken. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// vec.reserve(10); + /// assert!(vec.capacity() >= 10); + /// ``` + pub fn reserve(&mut self, capacity: uint) { + if capacity >= self.len { + self.reserve_exact(num::next_power_of_two(capacity)) + } + } + + /// Reserves capacity for exactly `capacity` elements in the given vector. + /// + /// If the capacity for `self` is already equal to or greater than the + /// requested capacity, then no action is taken. + /// + /// # Example + /// + /// ```rust + /// # use std::vec::Vec; + /// let mut vec: Vec = Vec::with_capacity(10); + /// vec.reserve_exact(11); + /// assert_eq!(vec.capacity(), 11); + /// ``` + pub fn reserve_exact(&mut self, capacity: uint) { + if capacity >= self.len { + let size = capacity.checked_mul(&size_of::()).expect("capacity overflow"); + self.cap = capacity; + unsafe { + self.ptr = realloc_raw(self.ptr as *mut u8, size) as *mut T; + } + } + } + + /// Shrink the capacity of the vector to match the length + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// vec.shrink_to_fit(); + /// assert_eq!(vec.capacity(), vec.len()); + /// ``` + pub fn shrink_to_fit(&mut self) { + if self.len == 0 { + unsafe { free(self.ptr as *mut c_void) }; + self.cap = 0; + self.ptr = 0 as *mut T; + } else { + unsafe { + // Overflow check is unnecessary as the vector is already at least this large. + self.ptr = realloc_raw(self.ptr as *mut u8, self.len * size_of::()) as *mut T; + } + self.cap = self.len; + } + } + + /// Remove the last element from a vector and return it, or `None` if it is + /// empty. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// assert_eq!(vec.pop(), Some(3)); + /// assert_eq!(vec, vec!(1, 2)); + /// ``` + #[inline] + pub fn pop(&mut self) -> Option { + if self.len == 0 { + None + } else { + unsafe { + self.len -= 1; + Some(ptr::read(self.as_slice().unsafe_ref(self.len()))) + } + } + } + + /// Append an element to a vector. + /// + /// # Failure + /// + /// Fails if the number of elements in the vector overflows a `uint`. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2); + /// vec.push(3); + /// assert_eq!(vec, vec!(1, 2, 3)); + /// ``` + #[inline] + pub fn push(&mut self, value: T) { + if self.len == self.cap { + if self.cap == 0 { self.cap += 2 } + let old_size = self.cap * size_of::(); + self.cap = self.cap * 2; + let size = old_size * 2; + if old_size > size { fail!("capacity overflow") } + unsafe { + self.ptr = realloc_raw(self.ptr as *mut u8, size) as *mut T; + } + } + + unsafe { + let end = (self.ptr as *T).offset(self.len as int) as *mut T; + move_val_init(&mut *end, value); + self.len += 1; + } + } + + /// Shorten a vector, dropping excess elements. + /// + /// If `len` is greater than the vector's current length, this has no + /// effect. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3, 4); + /// vec.truncate(2); + /// assert_eq!(vec, vec!(1, 2)); + /// ``` + pub fn truncate(&mut self, len: uint) { + unsafe { + let mut i = len; + // drop any extra elements + while i < self.len { + ptr::read(self.as_slice().unsafe_ref(i)); + i += 1; + } + } + self.len = len; + } + + /// Work with `self` as a slice. + /// + /// # Example + /// + /// ```rust + /// fn foo(slice: &[int]) {} + /// + /// let vec = vec!(1, 2); + /// foo(vec.as_slice()); + /// ``` + #[inline] + pub fn as_slice<'a>(&'a self) -> &'a [T] { + let slice = Slice { data: self.ptr as *T, len: self.len }; + unsafe { transmute(slice) } + } + + /// Work with `self` as a mutable slice. + /// + /// # Example + /// + /// ```rust + /// fn foo(slice: &mut [int]) {} + /// + /// let mut vec = vec!(1, 2); + /// foo(vec.as_mut_slice()); + /// ``` + #[inline] + pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] { + let slice = Slice { data: self.ptr as *T, len: self.len }; + unsafe { transmute(slice) } + } + + /// Creates a consuming iterator, that is, one that moves each + /// value out of the vector (from start to end). The vector cannot + /// be used after calling this. + /// + /// # Example + /// + /// ```rust + /// let v = vec!(~"a", ~"b"); + /// for s in v.move_iter() { + /// // s has type ~str, not &~str + /// println!("{}", s); + /// } + /// ``` + #[inline] + pub fn move_iter(self) -> MoveItems { + unsafe { + let iter = transmute(self.as_slice().iter()); + let ptr = self.ptr as *mut c_void; + forget(self); + MoveItems { allocation: ptr, iter: iter } + } + } + + + /// Sets the length of a vector. + /// + /// This will explicitly set the size of the vector, without actually + /// modifying its buffers, so it is up to the caller to ensure that the + /// vector is actually the specified size. + #[inline] + pub unsafe fn set_len(&mut self, len: uint) { + self.len = len; + } + + /// Returns a reference to the value at index `index`. + /// + /// # Failure + /// + /// Fails if `index` is out of bounds + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3); + /// assert!(vec.get(1) == &2); + /// ``` + #[inline] + pub fn get<'a>(&'a self, index: uint) -> &'a T { + &self.as_slice()[index] + } + + /// Returns a mutable reference to the value at index `index`. + /// + /// # Failure + /// + /// Fails if `index` is out of bounds + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// *vec.get_mut(1) = 4; + /// assert_eq!(vec, vec!(1, 4, 3)); + /// ``` + #[inline] + pub fn get_mut<'a>(&'a mut self, index: uint) -> &'a mut T { + &mut self.as_mut_slice()[index] + } + + /// Returns an iterator over references to the elements of the vector in + /// order. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3); + /// for num in vec.iter() { + /// println!("{}", *num); + /// } + /// ``` + #[inline] + pub fn iter<'a>(&'a self) -> Items<'a,T> { + self.as_slice().iter() + } + + + /// Returns an iterator over mutable references to the elements of the + /// vector in order. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// for num in vec.mut_iter() { + /// *num = 0; + /// } + /// ``` + #[inline] + pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a,T> { + self.as_mut_slice().mut_iter() + } + + /// Sort the vector, in place, using `compare` to compare elements. + /// + /// This sort is `O(n log n)` worst-case and stable, but allocates + /// approximately `2 * n`, where `n` is the length of `self`. + /// + /// # Example + /// + /// ```rust + /// let mut v = vec!(5i, 4, 1, 3, 2); + /// v.sort_by(|a, b| a.cmp(b)); + /// assert_eq!(v, vec!(1, 2, 3, 4, 5)); + /// + /// // reverse sorting + /// v.sort_by(|a, b| b.cmp(a)); + /// assert_eq!(v, vec!(5, 4, 3, 2, 1)); + /// ``` + #[inline] + pub fn sort_by(&mut self, compare: |&T, &T| -> Ordering) { + self.as_mut_slice().sort_by(compare) + } + + /// Returns a slice of `self` between `start` and `end`. + /// + /// # Failure + /// + /// Fails when `start` or `end` point outside the bounds of `self`, or when + /// `start` > `end`. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3, 4); + /// assert!(vec.slice(0, 2) == [1, 2]); + /// ``` + #[inline] + pub fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [T] { + self.as_slice().slice(start, end) + } + + /// Returns a slice containing all but the first element of the vector. + /// + /// # Failure + /// + /// Fails when the vector is empty. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3); + /// assert!(vec.tail() == [2, 3]); + /// ``` + #[inline] + pub fn tail<'a>(&'a self) -> &'a [T] { + self.as_slice().tail() + } + + /// Returns all but the first `n' elements of a vector. + /// + /// # Failure + /// + /// Fails when there are fewer than `n` elements in the vector. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3, 4); + /// assert!(vec.tailn(2) == [3, 4]); + /// ``` + #[inline] + pub fn tailn<'a>(&'a self, n: uint) -> &'a [T] { + self.as_slice().tailn(n) + } + + /// Returns a reference to the last element of a vector, or `None` if it is + /// empty. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3); + /// assert!(vec.last() == Some(&3)); + /// ``` + #[inline] + pub fn last<'a>(&'a self) -> Option<&'a T> { + self.as_slice().last() + } + + /// Returns a mutable reference to the last element of a vector, or `None` + /// if it is empty. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// *vec.mut_last().unwrap() = 4; + /// assert_eq!(vec, vec!(1, 2, 4)); + /// ``` + #[inline] + pub fn mut_last<'a>(&'a mut self) -> Option<&'a mut T> { + self.as_mut_slice().mut_last() + } + + /// Remove an element from anywhere in the vector and return it, replacing + /// it with the last element. This does not preserve ordering, but is O(1). + /// + /// Returns `None` if `index` is out of bounds. + /// + /// # Example + /// ```rust + /// let mut v = ~[~"foo", ~"bar", ~"baz", ~"qux"]; + /// + /// assert_eq!(v.swap_remove(1), Some(~"bar")); + /// assert_eq!(v, ~[~"foo", ~"qux", ~"baz"]); + /// + /// assert_eq!(v.swap_remove(0), Some(~"foo")); + /// assert_eq!(v, ~[~"baz", ~"qux"]); + /// + /// assert_eq!(v.swap_remove(2), None); + /// ``` + #[inline] + pub fn swap_remove(&mut self, index: uint) -> Option { + let length = self.len(); + if index < length - 1 { + self.as_mut_slice().swap(index, length - 1); + } else if index >= length { + return None + } + self.pop() + } + + /// Prepend an element to the vector. + /// + /// # Warning + /// + /// This is an O(n) operation as it requires copying every element in the + /// vector. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// vec.unshift(4); + /// assert_eq!(vec, vec!(4, 1, 2, 3)); + /// ``` + #[inline] + pub fn unshift(&mut self, element: T) { + self.insert(0, element) + } + + /// Removes the first element from a vector and returns it, or `None` if + /// the vector is empty. + /// + /// # Warning + /// + /// This is an O(n) operation as it requires copying every element in the + /// vector. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// assert!(vec.shift() == Some(1)); + /// assert_eq!(vec, vec!(2, 3)); + /// ``` + #[inline] + pub fn shift(&mut self) -> Option { + self.remove(0) + } + + /// Insert an element at position `index` within the vector, shifting all + /// elements after position i one position to the right. + /// + /// # Failure + /// + /// Fails if `index` is out of bounds of the vector. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3); + /// vec.insert(1, 4); + /// assert_eq!(vec, vec!(1, 4, 2, 3)); + /// ``` + pub fn insert(&mut self, index: uint, element: T) { + let len = self.len(); + assert!(index <= len); + // space for the new element + self.reserve(len + 1); + + unsafe { // infallible + // The spot to put the new value + { + let p = self.as_mut_ptr().offset(index as int); + // Shift everything over to make space. (Duplicating the + // `index`th element into two consecutive places.) + ptr::copy_memory(p.offset(1), &*p, len - index); + // Write it in, overwriting the first copy of the `index`th + // element. + move_val_init(&mut *p, element); + } + self.set_len(len + 1); + } + } + + /// Remove and return the element at position `index` within the vector, + /// shifting all elements after position `index` one position to the left. + /// Returns `None` if `i` is out of bounds. + /// + /// # Example + /// + /// ```rust + /// let mut v = ~[1, 2, 3]; + /// assert_eq!(v.remove(1), Some(2)); + /// assert_eq!(v, ~[1, 3]); + /// + /// assert_eq!(v.remove(4), None); + /// // v is unchanged: + /// assert_eq!(v, ~[1, 3]); + /// ``` + pub fn remove(&mut self, index: uint) -> Option { + let len = self.len(); + if index < len { + unsafe { // infallible + let ret; + { + // the place we are taking from. + let ptr = self.as_mut_ptr().offset(index as int); + // copy it out, unsafely having a copy of the value on + // the stack and in the vector at the same time. + ret = Some(ptr::read(ptr as *T)); + + // Shift everything down to fill in that spot. + ptr::copy_memory(ptr, &*ptr.offset(1), len - index - 1); + } + self.set_len(len - 1); + ret + } + } else { + None + } + } + + ///Apply a function to each element of a vector and return the results. + #[inline] + #[deprecated="Use `xs.iter().map(closure)` instead."] + pub fn map(&self, f: |t: &T| -> U) -> Vec { + self.iter().map(f).collect() + } + + /// Takes ownership of the vector `other`, moving all elements into + /// the current vector. This does not copy any elements, and it is + /// illegal to use the `other` vector after calling this method + /// (because it is moved here). + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(~1); + /// vec.push_all_move(vec!(~2, ~3, ~4)); + /// assert_eq!(vec, vec!(~1, ~2, ~3, ~4)); + /// ``` + pub fn push_all_move(&mut self, other: Vec) { + for element in other.move_iter() { + self.push(element) + } + } + + /// Returns a mutable slice of `self` between `start` and `end`. + /// + /// # Failure + /// + /// Fails when `start` or `end` point outside the bounds of `self`, or when + /// `start` > `end`. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 3, 4); + /// assert!(vec.mut_slice(0, 2) == [1, 2]); + /// ``` + #[inline] + pub fn mut_slice<'a>(&'a mut self, start: uint, end: uint) + -> &'a mut [T] { + self.as_mut_slice().mut_slice(start, end) + } + + /// Reverse the order of elements in a vector, in place. + /// + /// # Example + /// + /// ```rust + /// let mut v = vec!(1, 2, 3); + /// v.reverse(); + /// assert_eq!(v, vec!(3, 2, 1)); + /// ``` + #[inline] + pub fn reverse(&mut self) { + self.as_mut_slice().reverse() + } + + /// Returns a slice of `self` from `start` to the end of the vec. + /// + /// # Failure + /// + /// Fails when `start` points outside the bounds of self. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3); + /// assert!(vec.slice_from(1) == [2, 3]); + /// ``` + #[inline] + pub fn slice_from<'a>(&'a self, start: uint) -> &'a [T] { + self.as_slice().slice_from(start) + } + + /// Returns a slice of self from the start of the vec to `end`. + /// + /// # Failure + /// + /// Fails when `end` points outside the bounds of self. + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3); + /// assert!(vec.slice_to(2) == [1, 2]); + /// ``` + #[inline] + pub fn slice_to<'a>(&'a self, end: uint) -> &'a [T] { + self.as_slice().slice_to(end) + } + + /// Returns a slice containing all but the last element of the vector. + /// + /// # Failure + /// + /// Fails if the vector is empty + #[inline] + pub fn init<'a>(&'a self) -> &'a [T] { + self.slice(0, self.len() - 1) + } + + + /// Returns an unsafe pointer to the vector's buffer. + /// + /// The caller must ensure that the vector outlives the pointer this + /// function returns, or else it will end up pointing to garbage. + /// + /// Modifying the vector may cause its buffer to be reallocated, which + /// would also make any pointers to it invalid. + #[inline] + pub fn as_ptr(&self) -> *T { + self.as_slice().as_ptr() + } + + /// Returns a mutable unsafe pointer to the vector's buffer. + /// + /// The caller must ensure that the vector outlives the pointer this + /// function returns, or else it will end up pointing to garbage. + /// + /// Modifying the vector may cause its buffer to be reallocated, which + /// would also make any pointers to it invalid. + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self.as_mut_slice().as_mut_ptr() + } +} + +impl Vec { + /// Sorts the vector in place. + /// + /// This sort is `O(n log n)` worst-case and stable, but allocates + /// approximately `2 * n`, where `n` is the length of `self`. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(3i, 1, 2); + /// vec.sort(); + /// assert_eq!(vec, vec!(1, 2, 3)); + /// ``` + pub fn sort(&mut self) { + self.as_mut_slice().sort() + } +} + +impl Mutable for Vec { + #[inline] + fn clear(&mut self) { + self.truncate(0) + } +} + +impl Vec { + /// Return true if a vector contains an element with the given value + /// + /// # Example + /// + /// ```rust + /// let vec = vec!(1, 2, 3); + /// assert!(vec.contains(&1)); + /// ``` + pub fn contains(&self, x: &T) -> bool { + self.as_slice().contains(x) + } + + /// Remove consecutive repeated elements in the vector. + /// + /// If the vector is sorted, this removes all duplicates. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1, 2, 2, 3, 2); + /// vec.dedup(); + /// assert_eq!(vec, vec!(1, 2, 3, 2)); + /// ``` + pub fn dedup(&mut self) { + unsafe { + // Although we have a mutable reference to `self`, we cannot make + // *arbitrary* changes. The `Eq` comparisons could fail, so we + // must ensure that the vector is in a valid state at all time. + // + // The way that we handle this is by using swaps; we iterate + // over all the elements, swapping as we go so that at the end + // the elements we wish to keep are in the front, and those we + // wish to reject are at the back. We can then truncate the + // vector. This operation is still O(n). + // + // Example: We start in this state, where `r` represents "next + // read" and `w` represents "next_write`. + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 1 | 2 | 3 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Comparing self[r] against self[w-1], tis is not a duplicate, so + // we swap self[r] and self[w] (no effect as r==w) and then increment both + // r and w, leaving us with: + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 1 | 2 | 3 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Comparing self[r] against self[w-1], this value is a duplicate, + // so we increment `r` but leave everything else unchanged: + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 1 | 2 | 3 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Comparing self[r] against self[w-1], this is not a duplicate, + // so swap self[r] and self[w] and advance r and w: + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 2 | 1 | 3 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Not a duplicate, repeat: + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 2 | 3 | 1 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Duplicate, advance r. End of vec. Truncate to w. + + let ln = self.len(); + if ln < 1 { return; } + + // Avoid bounds checks by using unsafe pointers. + let p = self.as_mut_slice().as_mut_ptr(); + let mut r = 1; + let mut w = 1; + + while r < ln { + let p_r = p.offset(r as int); + let p_wm1 = p.offset((w - 1) as int); + if *p_r != *p_wm1 { + if r != w { + let p_w = p_wm1.offset(1); + mem::swap(&mut *p_r, &mut *p_w); + } + w += 1; + } + r += 1; + } + + self.truncate(w); + } + } +} + +/// Iterates over the `second` vector, copying each element and appending it to +/// the `first`. Afterwards, the `first` is then returned for use again. +/// +/// # Example +/// +/// ```rust +/// let vec = vec!(1, 2); +/// let vec = std::vec::append(vec, [3, 4]); +/// assert_eq!(vec, vec!(1, 2, 3, 4)); +/// ``` +#[inline] +pub fn append(mut first: Vec, second: &[T]) -> Vec { + first.push_all(second); + first +} + +/// Appends one element to the vector provided. The vector itself is then +/// returned for use again. +/// +/// # Example +/// +/// ```rust +/// let vec = vec!(1, 2); +/// let vec = std::vec::append_one(vec, 3); +/// assert_eq!(vec, vec!(1, 2, 3)); +/// ``` +#[inline] +pub fn append_one(mut lhs: Vec, x: T) -> Vec { + lhs.push(x); + lhs +} + +#[unsafe_destructor] +impl Drop for Vec { + fn drop(&mut self) { + // This is (and should always remain) a no-op if the fields are + // zeroed (when moving out, because of #[unsafe_no_drop_flag]). + unsafe { + for x in self.as_mut_slice().iter() { + ptr::read(x); + } + free(self.ptr as *mut c_void) + } + } +} + +impl Default for Vec { + fn default() -> Vec { + Vec::new() + } +} + +impl fmt::Show for Vec { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.as_slice().fmt(f) + } +} + +/// An iterator that moves out of a vector. +pub struct MoveItems { + priv allocation: *mut c_void, // the block of memory allocated for the vector + priv iter: Items<'static, T> +} + +impl Iterator for MoveItems { + #[inline] + fn next(&mut self) -> Option { + unsafe { + self.iter.next().map(|x| ptr::read(x)) + } + } + + #[inline] + fn size_hint(&self) -> (uint, Option) { + self.iter.size_hint() + } +} + +impl DoubleEndedIterator for MoveItems { + #[inline] + fn next_back(&mut self) -> Option { + unsafe { + self.iter.next_back().map(|x| ptr::read(x)) + } + } +} + +#[unsafe_destructor] +impl Drop for MoveItems { + fn drop(&mut self) { + // destroy the remaining elements + for _x in *self {} + unsafe { + free(self.allocation) + } + } +} + +#[cfg(test)] +mod tests { + use super::Vec; + use iter::{Iterator, range, Extendable}; + use mem::{drop, size_of}; + use ops::Drop; + use option::{Some, None}; + use ptr; + + #[test] + fn test_small_vec_struct() { + assert!(size_of::>() == size_of::() * 3); + } + + #[test] + fn test_double_drop() { + struct TwoVec { + x: Vec, + y: Vec + } + + struct DropCounter<'a> { + count: &'a mut int + } + + #[unsafe_destructor] + impl<'a> Drop for DropCounter<'a> { + fn drop(&mut self) { + *self.count += 1; + } + } + + let mut count_x @ mut count_y = 0; + { + let mut tv = TwoVec { + x: Vec::new(), + y: Vec::new() + }; + tv.x.push(DropCounter {count: &mut count_x}); + tv.y.push(DropCounter {count: &mut count_y}); + + // If Vec had a drop flag, here is where it would be zeroed. + // Instead, it should rely on its internal state to prevent + // doing anything significant when dropped multiple times. + drop(tv.x); + + // Here tv goes out of scope, tv.y should be dropped, but not tv.x. + } + + assert_eq!(count_x, 1); + assert_eq!(count_y, 1); + } + + #[test] + fn test_reserve_additional() { + let mut v = Vec::new(); + assert_eq!(v.capacity(), 0); + + v.reserve_additional(2); + assert!(v.capacity() >= 2); + + for i in range(0, 16) { + v.push(i); + } + + assert!(v.capacity() >= 16); + v.reserve_additional(16); + assert!(v.capacity() >= 32); + + v.push(16); + + v.reserve_additional(16); + assert!(v.capacity() >= 33) + } + + #[test] + fn test_extend() { + let mut v = Vec::new(); + let mut w = Vec::new(); + + v.extend(&mut range(0, 3)); + for i in range(0, 3) { w.push(i) } + + assert_eq!(v, w); + + v.extend(&mut range(3, 10)); + for i in range(3, 10) { w.push(i) } + + assert_eq!(v, w); + } +} diff --git a/src/libstd/vec_ng.rs b/src/libstd/vec_ng.rs deleted file mode 100644 index 553f528745b..00000000000 --- a/src/libstd/vec_ng.rs +++ /dev/null @@ -1,1353 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -//! A growable, owned vector - -use cast::{forget, transmute}; -use clone::Clone; -use cmp::{Ord, Eq, Ordering, TotalEq, TotalOrd}; -use container::{Container, Mutable}; -use default::Default; -use fmt; -use iter::{DoubleEndedIterator, FromIterator, Extendable, Iterator}; -use libc::{free, c_void}; -use mem::{size_of, move_val_init}; -use mem; -use num; -use num::{CheckedMul, CheckedAdd}; -use ops::Drop; -use option::{None, Option, Some}; -use ptr::RawPtr; -use ptr; -use rt::global_heap::{malloc_raw, realloc_raw}; -use raw::Slice; -use slice::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector}; -use slice::{MutableTotalOrdVector}; - -/// An owned, growable vector -/// -/// `Vec` is the replacement for the deprecated `~[T]` type. The API is -/// largely the same. The `vec!` macro is provided to make initialization -/// easier. -/// -/// # Example -/// -/// ```rust -/// let mut vec = vec!(1, 2, 3); -/// vec.push(4); -/// println!("{}", vec); // prints [1, 2, 3, 4] -/// ``` -#[unsafe_no_drop_flag] -pub struct Vec { - priv len: uint, - priv cap: uint, - priv ptr: *mut T -} - -impl Vec { - /// Constructs a new, empty `Vec`. - /// - /// The vector will not allocate until elements are pushed onto it. - /// - /// # Example - /// - /// ```rust - /// # use std::vec_ng::Vec; - /// let mut vec: Vec = Vec::new(); - /// ``` - #[inline] - pub fn new() -> Vec { - Vec { len: 0, cap: 0, ptr: 0 as *mut T } - } - - /// Constructs a new, empty `Vec` with the specified capacity. - /// - /// The vector will be able to hold exactly `capacity` elements without - /// reallocating. If `capacity` is 0, the vector will not allocate. - /// - /// # Example - /// - /// ```rust - /// # use std::vec_ng::Vec; - /// let vec: Vec = Vec::with_capacity(10); - /// ``` - pub fn with_capacity(capacity: uint) -> Vec { - if capacity == 0 { - Vec::new() - } else { - let size = capacity.checked_mul(&size_of::()).expect("capacity overflow"); - let ptr = unsafe { malloc_raw(size) }; - Vec { len: 0, cap: capacity, ptr: ptr as *mut T } - } - } - - - /// Creates and initializes a `Vec`. - /// - /// Creates a `Vec` of size `length` and initializes the elements to the - /// value returned by the closure `op`. - /// - /// # Example - /// - /// ```rust - /// # use std::vec_ng::Vec; - /// let vec = Vec::from_fn(3, |idx| idx * 2); - /// assert_eq!(vec, vec!(0, 2, 4)); - /// ``` - pub fn from_fn(length: uint, op: |uint| -> T) -> Vec { - unsafe { - let mut xs = Vec::with_capacity(length); - while xs.len < length { - move_val_init(xs.as_mut_slice().unsafe_mut_ref(xs.len), op(xs.len)); - xs.len += 1; - } - xs - } - } - - /// Consumes the `Vec`, partitioning it based on a predcate. - /// - /// Partitions the `Vec` into two `Vec`s `(A,B)`, where all elements of `A` - /// satisfy `f` and all elements of `B` do not. The order of elements is - /// preserved. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3, 4); - /// let (even, odd) = vec.partition(|&n| n % 2 == 0); - /// assert_eq!(even, vec!(2, 4)); - /// assert_eq!(odd, vec!(1, 3)); - /// ``` - #[inline] - pub fn partition(self, f: |&T| -> bool) -> (Vec, Vec) { - let mut lefts = Vec::new(); - let mut rights = Vec::new(); - - for elt in self.move_iter() { - if f(&elt) { - lefts.push(elt); - } else { - rights.push(elt); - } - } - - (lefts, rights) - } -} - -impl Vec { - /// Constructs a `Vec` by cloning elements of a slice. - /// - /// # Example - /// - /// ```rust - /// # use std::vec_ng::Vec; - /// let slice = [1, 2, 3]; - /// let vec = Vec::from_slice(slice); - /// ``` - pub fn from_slice(values: &[T]) -> Vec { - values.iter().map(|x| x.clone()).collect() - } - - /// Constructs a `Vec` with copies of a value. - /// - /// Creates a `Vec` with `length` copies of `value`. - /// - /// # Example - /// ```rust - /// # use std::vec_ng::Vec; - /// let vec = Vec::from_elem(3, "hi"); - /// println!("{}", vec); // prints [hi, hi, hi] - /// ``` - pub fn from_elem(length: uint, value: T) -> Vec { - unsafe { - let mut xs = Vec::with_capacity(length); - while xs.len < length { - move_val_init(xs.as_mut_slice().unsafe_mut_ref(xs.len), value.clone()); - xs.len += 1; - } - xs - } - } - - /// Appends all elements in a slice to the `Vec`. - /// - /// Iterates over the slice `other`, clones each element, and then appends - /// it to this `Vec`. The `other` vector is traversed in-order. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1); - /// vec.push_all([2, 3, 4]); - /// assert_eq!(vec, vec!(1, 2, 3, 4)); - /// ``` - #[inline] - pub fn push_all(&mut self, other: &[T]) { - for element in other.iter() { - self.push((*element).clone()) - } - } - - /// Grows the `Vec` in-place. - /// - /// Adds `n` copies of `value` to the `Vec`. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!("hello"); - /// vec.grow(2, & &"world"); - /// assert_eq!(vec, vec!("hello", "world", "world")); - /// ``` - pub fn grow(&mut self, n: uint, value: &T) { - let new_len = self.len() + n; - self.reserve(new_len); - let mut i: uint = 0u; - - while i < n { - self.push((*value).clone()); - i += 1u; - } - } - - /// Sets the value of a vector element at a given index, growing the vector - /// as needed. - /// - /// Sets the element at position `index` to `value`. If `index` is past the - /// end of the vector, expands the vector by replicating `initval` to fill - /// the intervening space. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!("a", "b", "c"); - /// vec.grow_set(1, & &"fill", "d"); - /// vec.grow_set(4, & &"fill", "e"); - /// assert_eq!(vec, vec!("a", "d", "c", "fill", "e")); - /// ``` - pub fn grow_set(&mut self, index: uint, initval: &T, value: T) { - let l = self.len(); - if index >= l { - self.grow(index - l + 1u, initval); - } - *self.get_mut(index) = value; - } - - /// Partitions a vector based on a predcate. - /// - /// Clones the elements of the vector, partitioning them into two `Vec`s - /// `(A,B)`, where all elements of `A` satisfy `f` and all elements of `B` - /// do not. The order of elements is preserved. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3, 4); - /// let (even, odd) = vec.partitioned(|&n| n % 2 == 0); - /// assert_eq!(even, vec!(2, 4)); - /// assert_eq!(odd, vec!(1, 3)); - /// ``` - pub fn partitioned(&self, f: |&T| -> bool) -> (Vec, Vec) { - let mut lefts = Vec::new(); - let mut rights = Vec::new(); - - for elt in self.iter() { - if f(elt) { - lefts.push(elt.clone()); - } else { - rights.push(elt.clone()); - } - } - - (lefts, rights) - } -} - -impl Clone for Vec { - fn clone(&self) -> Vec { - let mut vector = Vec::with_capacity(self.len()); - for element in self.iter() { - vector.push((*element).clone()) - } - vector - } -} - -impl FromIterator for Vec { - fn from_iterator>(iterator: &mut I) -> Vec { - let (lower, _) = iterator.size_hint(); - let mut vector = Vec::with_capacity(lower); - for element in *iterator { - vector.push(element) - } - vector - } -} - -impl Extendable for Vec { - fn extend>(&mut self, iterator: &mut I) { - let (lower, _) = iterator.size_hint(); - self.reserve_additional(lower); - for element in *iterator { - self.push(element) - } - } -} - -impl Eq for Vec { - #[inline] - fn eq(&self, other: &Vec) -> bool { - self.as_slice() == other.as_slice() - } -} - -impl Ord for Vec { - #[inline] - fn lt(&self, other: &Vec) -> bool { - self.as_slice() < other.as_slice() - } -} - -impl TotalEq for Vec { - #[inline] - fn equals(&self, other: &Vec) -> bool { - self.as_slice().equals(&other.as_slice()) - } -} - -impl TotalOrd for Vec { - #[inline] - fn cmp(&self, other: &Vec) -> Ordering { - self.as_slice().cmp(&other.as_slice()) - } -} - -impl Container for Vec { - #[inline] - fn len(&self) -> uint { - self.len - } -} - -impl Vec { - /// Returns the number of elements the vector can hold without - /// reallocating. - /// - /// # Example - /// - /// ```rust - /// # use std::vec_ng::Vec; - /// let vec: Vec = Vec::with_capacity(10); - /// assert_eq!(vec.capacity(), 10); - /// ``` - #[inline] - pub fn capacity(&self) -> uint { - self.cap - } - - /// Reserves capacity for at least `n` additional elements in the given - /// vector. - /// - /// # Failure - /// - /// Fails if the new capacity overflows `uint`. - /// - /// # Example - /// - /// ```rust - /// # use std::vec_ng::Vec; - /// let mut vec: Vec = vec!(1); - /// vec.reserve_additional(10); - /// assert!(vec.capacity() >= 11); - /// ``` - pub fn reserve_additional(&mut self, extra: uint) { - if self.cap - self.len < extra { - match self.len.checked_add(&extra) { - None => fail!("Vec::reserve_additional: `uint` overflow"), - Some(new_cap) => self.reserve(new_cap) - } - } - } - - /// Reserves capacity for at least `n` elements in the given vector. - /// - /// This function will over-allocate in order to amortize the allocation - /// costs in scenarios where the caller may need to repeatedly reserve - /// additional space. - /// - /// If the capacity for `self` is already equal to or greater than the - /// requested capacity, then no action is taken. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// vec.reserve(10); - /// assert!(vec.capacity() >= 10); - /// ``` - pub fn reserve(&mut self, capacity: uint) { - if capacity >= self.len { - self.reserve_exact(num::next_power_of_two(capacity)) - } - } - - /// Reserves capacity for exactly `capacity` elements in the given vector. - /// - /// If the capacity for `self` is already equal to or greater than the - /// requested capacity, then no action is taken. - /// - /// # Example - /// - /// ```rust - /// # use std::vec_ng::Vec; - /// let mut vec: Vec = Vec::with_capacity(10); - /// vec.reserve_exact(11); - /// assert_eq!(vec.capacity(), 11); - /// ``` - pub fn reserve_exact(&mut self, capacity: uint) { - if capacity >= self.len { - let size = capacity.checked_mul(&size_of::()).expect("capacity overflow"); - self.cap = capacity; - unsafe { - self.ptr = realloc_raw(self.ptr as *mut u8, size) as *mut T; - } - } - } - - /// Shrink the capacity of the vector to match the length - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// vec.shrink_to_fit(); - /// assert_eq!(vec.capacity(), vec.len()); - /// ``` - pub fn shrink_to_fit(&mut self) { - if self.len == 0 { - unsafe { free(self.ptr as *mut c_void) }; - self.cap = 0; - self.ptr = 0 as *mut T; - } else { - unsafe { - // Overflow check is unnecessary as the vector is already at least this large. - self.ptr = realloc_raw(self.ptr as *mut u8, self.len * size_of::()) as *mut T; - } - self.cap = self.len; - } - } - - /// Remove the last element from a vector and return it, or `None` if it is - /// empty. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// assert_eq!(vec.pop(), Some(3)); - /// assert_eq!(vec, vec!(1, 2)); - /// ``` - #[inline] - pub fn pop(&mut self) -> Option { - if self.len == 0 { - None - } else { - unsafe { - self.len -= 1; - Some(ptr::read(self.as_slice().unsafe_ref(self.len()))) - } - } - } - - /// Append an element to a vector. - /// - /// # Failure - /// - /// Fails if the number of elements in the vector overflows a `uint`. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2); - /// vec.push(3); - /// assert_eq!(vec, vec!(1, 2, 3)); - /// ``` - #[inline] - pub fn push(&mut self, value: T) { - if self.len == self.cap { - if self.cap == 0 { self.cap += 2 } - let old_size = self.cap * size_of::(); - self.cap = self.cap * 2; - let size = old_size * 2; - if old_size > size { fail!("capacity overflow") } - unsafe { - self.ptr = realloc_raw(self.ptr as *mut u8, size) as *mut T; - } - } - - unsafe { - let end = (self.ptr as *T).offset(self.len as int) as *mut T; - move_val_init(&mut *end, value); - self.len += 1; - } - } - - /// Shorten a vector, dropping excess elements. - /// - /// If `len` is greater than the vector's current length, this has no - /// effect. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3, 4); - /// vec.truncate(2); - /// assert_eq!(vec, vec!(1, 2)); - /// ``` - pub fn truncate(&mut self, len: uint) { - unsafe { - let mut i = len; - // drop any extra elements - while i < self.len { - ptr::read(self.as_slice().unsafe_ref(i)); - i += 1; - } - } - self.len = len; - } - - /// Work with `self` as a slice. - /// - /// # Example - /// - /// ```rust - /// fn foo(slice: &[int]) {} - /// - /// let vec = vec!(1, 2); - /// foo(vec.as_slice()); - /// ``` - #[inline] - pub fn as_slice<'a>(&'a self) -> &'a [T] { - let slice = Slice { data: self.ptr as *T, len: self.len }; - unsafe { transmute(slice) } - } - - /// Work with `self` as a mutable slice. - /// - /// # Example - /// - /// ```rust - /// fn foo(slice: &mut [int]) {} - /// - /// let mut vec = vec!(1, 2); - /// foo(vec.as_mut_slice()); - /// ``` - #[inline] - pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] { - let slice = Slice { data: self.ptr as *T, len: self.len }; - unsafe { transmute(slice) } - } - - /// Creates a consuming iterator, that is, one that moves each - /// value out of the vector (from start to end). The vector cannot - /// be used after calling this. - /// - /// # Example - /// - /// ```rust - /// let v = vec!(~"a", ~"b"); - /// for s in v.move_iter() { - /// // s has type ~str, not &~str - /// println!("{}", s); - /// } - /// ``` - #[inline] - pub fn move_iter(self) -> MoveItems { - unsafe { - let iter = transmute(self.as_slice().iter()); - let ptr = self.ptr as *mut c_void; - forget(self); - MoveItems { allocation: ptr, iter: iter } - } - } - - - /// Sets the length of a vector. - /// - /// This will explicitly set the size of the vector, without actually - /// modifying its buffers, so it is up to the caller to ensure that the - /// vector is actually the specified size. - #[inline] - pub unsafe fn set_len(&mut self, len: uint) { - self.len = len; - } - - /// Returns a reference to the value at index `index`. - /// - /// # Failure - /// - /// Fails if `index` is out of bounds - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3); - /// assert!(vec.get(1) == &2); - /// ``` - #[inline] - pub fn get<'a>(&'a self, index: uint) -> &'a T { - &self.as_slice()[index] - } - - /// Returns a mutable reference to the value at index `index`. - /// - /// # Failure - /// - /// Fails if `index` is out of bounds - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// *vec.get_mut(1) = 4; - /// assert_eq!(vec, vec!(1, 4, 3)); - /// ``` - #[inline] - pub fn get_mut<'a>(&'a mut self, index: uint) -> &'a mut T { - &mut self.as_mut_slice()[index] - } - - /// Returns an iterator over references to the elements of the vector in - /// order. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3); - /// for num in vec.iter() { - /// println!("{}", *num); - /// } - /// ``` - #[inline] - pub fn iter<'a>(&'a self) -> Items<'a,T> { - self.as_slice().iter() - } - - - /// Returns an iterator over mutable references to the elements of the - /// vector in order. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// for num in vec.mut_iter() { - /// *num = 0; - /// } - /// ``` - #[inline] - pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a,T> { - self.as_mut_slice().mut_iter() - } - - /// Sort the vector, in place, using `compare` to compare elements. - /// - /// This sort is `O(n log n)` worst-case and stable, but allocates - /// approximately `2 * n`, where `n` is the length of `self`. - /// - /// # Example - /// - /// ```rust - /// let mut v = vec!(5i, 4, 1, 3, 2); - /// v.sort_by(|a, b| a.cmp(b)); - /// assert_eq!(v, vec!(1, 2, 3, 4, 5)); - /// - /// // reverse sorting - /// v.sort_by(|a, b| b.cmp(a)); - /// assert_eq!(v, vec!(5, 4, 3, 2, 1)); - /// ``` - #[inline] - pub fn sort_by(&mut self, compare: |&T, &T| -> Ordering) { - self.as_mut_slice().sort_by(compare) - } - - /// Returns a slice of `self` between `start` and `end`. - /// - /// # Failure - /// - /// Fails when `start` or `end` point outside the bounds of `self`, or when - /// `start` > `end`. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3, 4); - /// assert!(vec.slice(0, 2) == [1, 2]); - /// ``` - #[inline] - pub fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [T] { - self.as_slice().slice(start, end) - } - - /// Returns a slice containing all but the first element of the vector. - /// - /// # Failure - /// - /// Fails when the vector is empty. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3); - /// assert!(vec.tail() == [2, 3]); - /// ``` - #[inline] - pub fn tail<'a>(&'a self) -> &'a [T] { - self.as_slice().tail() - } - - /// Returns all but the first `n' elements of a vector. - /// - /// # Failure - /// - /// Fails when there are fewer than `n` elements in the vector. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3, 4); - /// assert!(vec.tailn(2) == [3, 4]); - /// ``` - #[inline] - pub fn tailn<'a>(&'a self, n: uint) -> &'a [T] { - self.as_slice().tailn(n) - } - - /// Returns a reference to the last element of a vector, or `None` if it is - /// empty. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3); - /// assert!(vec.last() == Some(&3)); - /// ``` - #[inline] - pub fn last<'a>(&'a self) -> Option<&'a T> { - self.as_slice().last() - } - - /// Returns a mutable reference to the last element of a vector, or `None` - /// if it is empty. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// *vec.mut_last().unwrap() = 4; - /// assert_eq!(vec, vec!(1, 2, 4)); - /// ``` - #[inline] - pub fn mut_last<'a>(&'a mut self) -> Option<&'a mut T> { - self.as_mut_slice().mut_last() - } - - /// Remove an element from anywhere in the vector and return it, replacing - /// it with the last element. This does not preserve ordering, but is O(1). - /// - /// Returns `None` if `index` is out of bounds. - /// - /// # Example - /// ```rust - /// let mut v = ~[~"foo", ~"bar", ~"baz", ~"qux"]; - /// - /// assert_eq!(v.swap_remove(1), Some(~"bar")); - /// assert_eq!(v, ~[~"foo", ~"qux", ~"baz"]); - /// - /// assert_eq!(v.swap_remove(0), Some(~"foo")); - /// assert_eq!(v, ~[~"baz", ~"qux"]); - /// - /// assert_eq!(v.swap_remove(2), None); - /// ``` - #[inline] - pub fn swap_remove(&mut self, index: uint) -> Option { - let length = self.len(); - if index < length - 1 { - self.as_mut_slice().swap(index, length - 1); - } else if index >= length { - return None - } - self.pop() - } - - /// Prepend an element to the vector. - /// - /// # Warning - /// - /// This is an O(n) operation as it requires copying every element in the - /// vector. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// vec.unshift(4); - /// assert_eq!(vec, vec!(4, 1, 2, 3)); - /// ``` - #[inline] - pub fn unshift(&mut self, element: T) { - self.insert(0, element) - } - - /// Removes the first element from a vector and returns it, or `None` if - /// the vector is empty. - /// - /// # Warning - /// - /// This is an O(n) operation as it requires copying every element in the - /// vector. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// assert!(vec.shift() == Some(1)); - /// assert_eq!(vec, vec!(2, 3)); - /// ``` - #[inline] - pub fn shift(&mut self) -> Option { - self.remove(0) - } - - /// Insert an element at position `index` within the vector, shifting all - /// elements after position i one position to the right. - /// - /// # Failure - /// - /// Fails if `index` is out of bounds of the vector. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3); - /// vec.insert(1, 4); - /// assert_eq!(vec, vec!(1, 4, 2, 3)); - /// ``` - pub fn insert(&mut self, index: uint, element: T) { - let len = self.len(); - assert!(index <= len); - // space for the new element - self.reserve(len + 1); - - unsafe { // infallible - // The spot to put the new value - { - let p = self.as_mut_ptr().offset(index as int); - // Shift everything over to make space. (Duplicating the - // `index`th element into two consecutive places.) - ptr::copy_memory(p.offset(1), &*p, len - index); - // Write it in, overwriting the first copy of the `index`th - // element. - move_val_init(&mut *p, element); - } - self.set_len(len + 1); - } - } - - /// Remove and return the element at position `index` within the vector, - /// shifting all elements after position `index` one position to the left. - /// Returns `None` if `i` is out of bounds. - /// - /// # Example - /// - /// ```rust - /// let mut v = ~[1, 2, 3]; - /// assert_eq!(v.remove(1), Some(2)); - /// assert_eq!(v, ~[1, 3]); - /// - /// assert_eq!(v.remove(4), None); - /// // v is unchanged: - /// assert_eq!(v, ~[1, 3]); - /// ``` - pub fn remove(&mut self, index: uint) -> Option { - let len = self.len(); - if index < len { - unsafe { // infallible - let ret; - { - // the place we are taking from. - let ptr = self.as_mut_ptr().offset(index as int); - // copy it out, unsafely having a copy of the value on - // the stack and in the vector at the same time. - ret = Some(ptr::read(ptr as *T)); - - // Shift everything down to fill in that spot. - ptr::copy_memory(ptr, &*ptr.offset(1), len - index - 1); - } - self.set_len(len - 1); - ret - } - } else { - None - } - } - - ///Apply a function to each element of a vector and return the results. - #[inline] - #[deprecated="Use `xs.iter().map(closure)` instead."] - pub fn map(&self, f: |t: &T| -> U) -> Vec { - self.iter().map(f).collect() - } - - /// Takes ownership of the vector `other`, moving all elements into - /// the current vector. This does not copy any elements, and it is - /// illegal to use the `other` vector after calling this method - /// (because it is moved here). - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(~1); - /// vec.push_all_move(vec!(~2, ~3, ~4)); - /// assert_eq!(vec, vec!(~1, ~2, ~3, ~4)); - /// ``` - pub fn push_all_move(&mut self, other: Vec) { - for element in other.move_iter() { - self.push(element) - } - } - - /// Returns a mutable slice of `self` between `start` and `end`. - /// - /// # Failure - /// - /// Fails when `start` or `end` point outside the bounds of `self`, or when - /// `start` > `end`. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 3, 4); - /// assert!(vec.mut_slice(0, 2) == [1, 2]); - /// ``` - #[inline] - pub fn mut_slice<'a>(&'a mut self, start: uint, end: uint) - -> &'a mut [T] { - self.as_mut_slice().mut_slice(start, end) - } - - /// Reverse the order of elements in a vector, in place. - /// - /// # Example - /// - /// ```rust - /// let mut v = vec!(1, 2, 3); - /// v.reverse(); - /// assert_eq!(v, vec!(3, 2, 1)); - /// ``` - #[inline] - pub fn reverse(&mut self) { - self.as_mut_slice().reverse() - } - - /// Returns a slice of `self` from `start` to the end of the vec. - /// - /// # Failure - /// - /// Fails when `start` points outside the bounds of self. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3); - /// assert!(vec.slice_from(1) == [2, 3]); - /// ``` - #[inline] - pub fn slice_from<'a>(&'a self, start: uint) -> &'a [T] { - self.as_slice().slice_from(start) - } - - /// Returns a slice of self from the start of the vec to `end`. - /// - /// # Failure - /// - /// Fails when `end` points outside the bounds of self. - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3); - /// assert!(vec.slice_to(2) == [1, 2]); - /// ``` - #[inline] - pub fn slice_to<'a>(&'a self, end: uint) -> &'a [T] { - self.as_slice().slice_to(end) - } - - /// Returns a slice containing all but the last element of the vector. - /// - /// # Failure - /// - /// Fails if the vector is empty - #[inline] - pub fn init<'a>(&'a self) -> &'a [T] { - self.slice(0, self.len() - 1) - } - - - /// Returns an unsafe pointer to the vector's buffer. - /// - /// The caller must ensure that the vector outlives the pointer this - /// function returns, or else it will end up pointing to garbage. - /// - /// Modifying the vector may cause its buffer to be reallocated, which - /// would also make any pointers to it invalid. - #[inline] - pub fn as_ptr(&self) -> *T { - self.as_slice().as_ptr() - } - - /// Returns a mutable unsafe pointer to the vector's buffer. - /// - /// The caller must ensure that the vector outlives the pointer this - /// function returns, or else it will end up pointing to garbage. - /// - /// Modifying the vector may cause its buffer to be reallocated, which - /// would also make any pointers to it invalid. - #[inline] - pub fn as_mut_ptr(&mut self) -> *mut T { - self.as_mut_slice().as_mut_ptr() - } -} - -impl Vec { - /// Sorts the vector in place. - /// - /// This sort is `O(n log n)` worst-case and stable, but allocates - /// approximately `2 * n`, where `n` is the length of `self`. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(3i, 1, 2); - /// vec.sort(); - /// assert_eq!(vec, vec!(1, 2, 3)); - /// ``` - pub fn sort(&mut self) { - self.as_mut_slice().sort() - } -} - -impl Mutable for Vec { - #[inline] - fn clear(&mut self) { - self.truncate(0) - } -} - -impl Vec { - /// Return true if a vector contains an element with the given value - /// - /// # Example - /// - /// ```rust - /// let vec = vec!(1, 2, 3); - /// assert!(vec.contains(&1)); - /// ``` - pub fn contains(&self, x: &T) -> bool { - self.as_slice().contains(x) - } - - /// Remove consecutive repeated elements in the vector. - /// - /// If the vector is sorted, this removes all duplicates. - /// - /// # Example - /// - /// ```rust - /// let mut vec = vec!(1, 2, 2, 3, 2); - /// vec.dedup(); - /// assert_eq!(vec, vec!(1, 2, 3, 2)); - /// ``` - pub fn dedup(&mut self) { - unsafe { - // Although we have a mutable reference to `self`, we cannot make - // *arbitrary* changes. The `Eq` comparisons could fail, so we - // must ensure that the vector is in a valid state at all time. - // - // The way that we handle this is by using swaps; we iterate - // over all the elements, swapping as we go so that at the end - // the elements we wish to keep are in the front, and those we - // wish to reject are at the back. We can then truncate the - // vector. This operation is still O(n). - // - // Example: We start in this state, where `r` represents "next - // read" and `w` represents "next_write`. - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 1 | 2 | 3 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Comparing self[r] against self[w-1], tis is not a duplicate, so - // we swap self[r] and self[w] (no effect as r==w) and then increment both - // r and w, leaving us with: - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 1 | 2 | 3 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Comparing self[r] against self[w-1], this value is a duplicate, - // so we increment `r` but leave everything else unchanged: - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 1 | 2 | 3 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Comparing self[r] against self[w-1], this is not a duplicate, - // so swap self[r] and self[w] and advance r and w: - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 2 | 1 | 3 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Not a duplicate, repeat: - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 2 | 3 | 1 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Duplicate, advance r. End of vec. Truncate to w. - - let ln = self.len(); - if ln < 1 { return; } - - // Avoid bounds checks by using unsafe pointers. - let p = self.as_mut_slice().as_mut_ptr(); - let mut r = 1; - let mut w = 1; - - while r < ln { - let p_r = p.offset(r as int); - let p_wm1 = p.offset((w - 1) as int); - if *p_r != *p_wm1 { - if r != w { - let p_w = p_wm1.offset(1); - mem::swap(&mut *p_r, &mut *p_w); - } - w += 1; - } - r += 1; - } - - self.truncate(w); - } - } -} - -/// Iterates over the `second` vector, copying each element and appending it to -/// the `first`. Afterwards, the `first` is then returned for use again. -/// -/// # Example -/// -/// ```rust -/// let vec = vec!(1, 2); -/// let vec = std::vec_ng::append(vec, [3, 4]); -/// assert_eq!(vec, vec!(1, 2, 3, 4)); -/// ``` -#[inline] -pub fn append(mut first: Vec, second: &[T]) -> Vec { - first.push_all(second); - first -} - -/// Appends one element to the vector provided. The vector itself is then -/// returned for use again. -/// -/// # Example -/// -/// ```rust -/// let vec = vec!(1, 2); -/// let vec = std::vec_ng::append_one(vec, 3); -/// assert_eq!(vec, vec!(1, 2, 3)); -/// ``` -#[inline] -pub fn append_one(mut lhs: Vec, x: T) -> Vec { - lhs.push(x); - lhs -} - -#[unsafe_destructor] -impl Drop for Vec { - fn drop(&mut self) { - // This is (and should always remain) a no-op if the fields are - // zeroed (when moving out, because of #[unsafe_no_drop_flag]). - unsafe { - for x in self.as_mut_slice().iter() { - ptr::read(x); - } - free(self.ptr as *mut c_void) - } - } -} - -impl Default for Vec { - fn default() -> Vec { - Vec::new() - } -} - -impl fmt::Show for Vec { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.as_slice().fmt(f) - } -} - -/// An iterator that moves out of a vector. -pub struct MoveItems { - priv allocation: *mut c_void, // the block of memory allocated for the vector - priv iter: Items<'static, T> -} - -impl Iterator for MoveItems { - #[inline] - fn next(&mut self) -> Option { - unsafe { - self.iter.next().map(|x| ptr::read(x)) - } - } - - #[inline] - fn size_hint(&self) -> (uint, Option) { - self.iter.size_hint() - } -} - -impl DoubleEndedIterator for MoveItems { - #[inline] - fn next_back(&mut self) -> Option { - unsafe { - self.iter.next_back().map(|x| ptr::read(x)) - } - } -} - -#[unsafe_destructor] -impl Drop for MoveItems { - fn drop(&mut self) { - // destroy the remaining elements - for _x in *self {} - unsafe { - free(self.allocation) - } - } -} - -#[cfg(test)] -mod tests { - use super::Vec; - use iter::{Iterator, range, Extendable}; - use mem::{drop, size_of}; - use ops::Drop; - use option::{Some, None}; - use ptr; - - #[test] - fn test_small_vec_struct() { - assert!(size_of::>() == size_of::() * 3); - } - - #[test] - fn test_double_drop() { - struct TwoVec { - x: Vec, - y: Vec - } - - struct DropCounter<'a> { - count: &'a mut int - } - - #[unsafe_destructor] - impl<'a> Drop for DropCounter<'a> { - fn drop(&mut self) { - *self.count += 1; - } - } - - let mut count_x @ mut count_y = 0; - { - let mut tv = TwoVec { - x: Vec::new(), - y: Vec::new() - }; - tv.x.push(DropCounter {count: &mut count_x}); - tv.y.push(DropCounter {count: &mut count_y}); - - // If Vec had a drop flag, here is where it would be zeroed. - // Instead, it should rely on its internal state to prevent - // doing anything significant when dropped multiple times. - drop(tv.x); - - // Here tv goes out of scope, tv.y should be dropped, but not tv.x. - } - - assert_eq!(count_x, 1); - assert_eq!(count_y, 1); - } - - #[test] - fn test_reserve_additional() { - let mut v = Vec::new(); - assert_eq!(v.capacity(), 0); - - v.reserve_additional(2); - assert!(v.capacity() >= 2); - - for i in range(0, 16) { - v.push(i); - } - - assert!(v.capacity() >= 16); - v.reserve_additional(16); - assert!(v.capacity() >= 32); - - v.push(16); - - v.reserve_additional(16); - assert!(v.capacity() >= 33) - } - - #[test] - fn test_extend() { - let mut v = Vec::new(); - let mut w = Vec::new(); - - v.extend(&mut range(0, 3)); - for i in range(0, 3) { w.push(i) } - - assert_eq!(v, w); - - v.extend(&mut range(3, 10)); - for i in range(3, 10) { w.push(i) } - - assert_eq!(v, w); - } -} diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index a06415bc083..0547b374edb 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -9,7 +9,7 @@ // except according to those terms. use std::fmt; -use std::vec_ng::Vec; +use std::vec::Vec; use std::fmt::Show; #[deriving(Eq)] diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 77b0d4b5c9d..cbf5242271d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -21,7 +21,7 @@ use std::fmt; use std::fmt::Show; use std::option::Option; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; use serialize::{Encodable, Decodable, Encoder, Decoder}; /// A pointer abstraction. FIXME(eddyb) #10676 use Rc in the future. @@ -1157,7 +1157,7 @@ mod test { use codemap::*; use super::*; - use std::vec_ng::Vec; + use std::vec::Vec; fn is_freeze() {} diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index bfe3f833695..d1b13d93856 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -22,7 +22,7 @@ use std::cell::RefCell; use std::iter; use std::slice; use std::fmt; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Clone, Eq)] pub enum PathElem { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index da6278aaae9..b75a49b2097 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -22,7 +22,7 @@ use visit; use std::cell::Cell; use std::cmp; use std::u32; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn path_name_i(idents: &[Ident]) -> ~str { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") @@ -711,7 +711,7 @@ mod test { use ast::*; use super::*; use opt_vec; - use std::vec_ng::Vec; + use std::vec::Vec; fn ident_to_segment(id : &Ident) -> PathSegment { PathSegment {identifier:id.clone(), diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 65a0f473db2..8c6079b4d1a 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -21,7 +21,7 @@ use parse::token; use crateid::CrateId; use collections::HashSet; -use std::vec_ng::Vec; +use std::vec::Vec; pub trait AttrMetaMethods { // This could be changed to `fn check_name(&self, name: InternedString) -> diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index d93b5803eac..a52fbbe0c50 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -24,7 +24,7 @@ source code snippets, etc. use std::cell::RefCell; use std::cmp; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; use serialize::{Encodable, Decodable, Encoder, Decoder}; pub trait Pos { diff --git a/src/libsyntax/crateid.rs b/src/libsyntax/crateid.rs index e5136b7081b..20463612886 100644 --- a/src/libsyntax/crateid.rs +++ b/src/libsyntax/crateid.rs @@ -19,7 +19,7 @@ use std::fmt; /// to be `0.0`. use std::from_str::FromStr; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Clone, Eq)] pub struct CrateId { diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 8c1e27d8b01..b8a4b6d34f4 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -20,7 +20,7 @@ use parse; use parse::token::InternedString; use parse::token; -use std::vec_ng::Vec; +use std::vec::Vec; enum State { Asm, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index df2c265e6eb..e456b62e5e7 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -20,7 +20,7 @@ use parse::token::{InternedString, intern, str_to_ident}; use util::small_vector::SmallVector; use collections::HashMap; -use std::vec_ng::Vec; +use std::vec::Vec; // new-style macro! tt code: // diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 7c42476bc01..7cf27e81ca0 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -21,7 +21,7 @@ use opt_vec::OptVec; use parse::token::special_idents; use parse::token; -use std::vec_ng::Vec; +use std::vec::Vec; pub struct Field { ident: ast::Ident, @@ -585,7 +585,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn expr_vec_ng(&self, sp: Span) -> @ast::Expr { self.expr_call_global(sp, vec!(self.ident_of("std"), - self.ident_of("vec_ng"), + self.ident_of("vec"), self.ident_of("Vec"), self.ident_of("new")), Vec::new()) diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 6123fd4d3d4..174f36146aa 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -17,7 +17,7 @@ use ext::base; use ext::build::AstBuilder; use std::char; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { // Gather all argument expressions diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs index 5d11a0d1e2f..e885119118c 100644 --- a/src/libsyntax/ext/cfg.rs +++ b/src/libsyntax/ext/cfg.rs @@ -26,7 +26,7 @@ use parse::token::InternedString; use parse::token; use parse; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_cfg(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let mut p = parse::new_parser_from_tts(cx.parse_sess(), diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index ee3adb7aad8..2aeda30695e 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -15,7 +15,7 @@ use ext::base; use opt_vec; use parse::token; use parse::token::{str_to_ident}; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index e63363c608b..a0aa1bb3710 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_clone(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 1e7199ccc95..80e56f0e407 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_eq(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index 66f45988239..caad6772b19 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -15,7 +15,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_ord(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 2b3c0b9ea69..3292246bf0b 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 89a344bdb7b..d8c2eea9896 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -16,7 +16,7 @@ use ext::build::AstBuilder; use ext::deriving::generic::*; use std::cmp::{Ordering, Equal, Less, Greater}; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_totalord(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index bc6d69c7cca..e5e11ce878c 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -21,7 +21,7 @@ use ext::deriving::generic::*; use parse::token::InternedString; use parse::token; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_decodable(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index 8259459f57a..2015aa99717 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_default(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 091ff7b9c90..0550e64bef8 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -89,7 +89,7 @@ use ext::build::AstBuilder; use ext::deriving::generic::*; use parse::token; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_encodable(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index d24bb2802c6..dce777aaaae 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -187,8 +187,8 @@ use codemap::Span; use opt_vec; use parse::token::InternedString; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; pub use self::ty::*; mod ty; @@ -407,7 +407,7 @@ impl<'a> TraitDef<'a> { cx.item( self.span, ident, - vec_ng::append(vec!(attr), self.attributes.as_slice()), + vec::append(vec!(attr), self.attributes.as_slice()), ast::ItemImpl(trait_generics, opt_trait_ref, self_type, methods.map(|x| *x))) } diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index a94feee9d37..366647cc371 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_hash(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 190f009103f..35c1437a176 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -16,7 +16,7 @@ use ext::build::AstBuilder; use ext::deriving::generic::*; use parse::token::InternedString; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index b8ef9d98b29..4ae140406c3 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -15,7 +15,7 @@ use ext::base::ExtCtxt; use ext::build::{AstBuilder}; use ext::deriving::generic::*; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_rand(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index 51399d8efab..d86fff5a4aa 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -19,7 +19,7 @@ use ext::deriving::generic::*; use parse::token; use collections::HashMap; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_show(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 60166f30f1e..22d91956552 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -20,7 +20,7 @@ use ext::build::AstBuilder; use codemap::{Span,respan}; use opt_vec; -use std::vec_ng::Vec; +use std::vec::Vec; /// The types of pointers pub enum PtrTy<'a> { diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index 98c0ec9d072..d788bafc9b2 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_deriving_zero(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 0c7b92d0373..bb9e5afaed4 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -22,7 +22,7 @@ use ext::build::AstBuilder; use parse::token; use std::os; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_option_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 49058917e30..4134b23125e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -32,7 +32,7 @@ use util::small_vector::SmallVector; use std::cast; use std::unstable::dynamic_lib::DynamicLibrary; use std::os; -use std::vec_ng::Vec; +use std::vec::Vec; pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr { match e.node { @@ -979,7 +979,7 @@ mod test { use visit; use visit::Visitor; - use std::vec_ng::Vec; + use std::vec::Vec; // a visitor that extracts the paths // from a given thingy and puts them in a mutable diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 3bfc4f6e51d..743fe798480 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -21,7 +21,7 @@ use rsparse = parse; use std::fmt::parse; use collections::{HashMap, HashSet}; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Eq)] enum ArgumentType { diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index b04e1dfd8b5..ab5f3fbf3a6 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -20,7 +20,7 @@ use ast::{Ident, Mrk, Name, SyntaxContext}; use std::cell::RefCell; use std::local_data; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashMap; @@ -281,7 +281,7 @@ mod tests { use super::{resolve, xorPush, new_mark_internal, new_sctable_internal}; use super::{new_rename_internal, marksof_internal, resolve_internal}; use super::{SCTable, EmptyCtxt, Mark, Rename, IllegalCtxt}; - use std::vec_ng::Vec; + use std::vec::Vec; use collections::HashMap; #[test] fn xorpush_test () { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index e96597d4159..5b66184b16c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -17,7 +17,7 @@ use parse::token::*; use parse::token; use parse; -use std::vec_ng::Vec; +use std::vec::Vec; /** * @@ -37,7 +37,7 @@ pub mod rt { use parse; use print::pprust; - use std::vec_ng::Vec; + use std::vec::Vec; pub use ast::*; pub use parse::token::*; diff --git a/src/libsyntax/ext/registrar.rs b/src/libsyntax/ext/registrar.rs index d8bf726da79..db59388e24f 100644 --- a/src/libsyntax/ext/registrar.rs +++ b/src/libsyntax/ext/registrar.rs @@ -15,7 +15,7 @@ use diagnostic; use visit; use visit::Visitor; -use std::vec_ng::Vec; +use std::vec::Vec; struct MacroRegistrarContext { registrars: Vec<(ast::NodeId, Span)> , diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 698bde4578c..f5c29840e48 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -22,7 +22,7 @@ use parse::token::{Token, EOF, Nonterminal}; use parse::token; use collections::HashMap; -use std::vec_ng::Vec; +use std::vec::Vec; /* This is an Earley-like parser, without support for in-grammar nonterminals, only by calling out to the main rust parser for named nonterminals (which it diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 3f4ed0b1e8e..d283d6d7142 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -28,7 +28,7 @@ use print; use util::small_vector::SmallVector; use std::cell::RefCell; -use std::vec_ng::Vec; +use std::vec::Vec; struct ParserAnyMacro<'a> { parser: RefCell>, diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index e120f07742e..19af4eed4c3 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -18,7 +18,7 @@ use parse::token; use parse::lexer::TokenAndSpan; use std::cell::{Cell, RefCell}; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashMap; ///an unzipping of `TokenTree`s diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index d9510ddad4b..a54c3b6af01 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -16,7 +16,7 @@ use parse::token; use opt_vec::OptVec; use util::small_vector::SmallVector; -use std::vec_ng::Vec; +use std::vec::Vec; // We may eventually want to be able to fold over type parameters, too. pub trait Folder { diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index aee387d6d96..55261fd3267 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -17,7 +17,7 @@ use std::default::Default; use std::slice; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Clone, Encodable, Decodable, Hash)] pub enum OptVec { diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 399648ef1d8..e86f6f5be81 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -15,7 +15,7 @@ use parse::token; use parse::parser::Parser; use parse::token::INTERPOLATED; -use std::vec_ng::Vec; +use std::vec::Vec; // a parser that can parse attributes. pub trait ParserAttr { diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index ed74fd416d1..9bc0fdd3078 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -20,7 +20,7 @@ use parse::token; use std::io; use std::str; use std::uint; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Clone, Eq)] pub enum CommentStyle { diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 546aefc1297..c34ef465dad 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -1005,7 +1005,7 @@ mod test { use parse::token; use parse::token::{str_to_ident}; use std::io::util; - use std::vec_ng::Vec; + use std::vec::Vec; fn mk_sh() -> diagnostic::SpanHandler { let emitter = diagnostic::EmitterWriter::new(~util::NullWriter); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 062bc100863..7e8ca77eb04 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -21,7 +21,7 @@ use std::cell::RefCell; use std::io::File; use std::rc::Rc; use std::str; -use std::vec_ng::Vec; +use std::vec::Vec; pub mod lexer; pub mod parser; @@ -279,7 +279,7 @@ mod test { use std::io; use std::io::MemWriter; use std::str; - use std::vec_ng::Vec; + use std::vec::Vec; use codemap::{Span, BytePos, Spanned}; use opt_vec; use ast; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e1a02d5240f..1c03ab7f0f8 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -82,8 +82,8 @@ use std::cell::Cell; use collections::HashSet; use std::kinds::marker; use std::mem::replace; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; #[allow(non_camel_case_types)] #[deriving(Eq)] @@ -271,7 +271,7 @@ fn maybe_append(lhs: Vec , rhs: Option >) -> Vec { match rhs { None => lhs, - Some(ref attrs) => vec_ng::append(lhs, attrs.as_slice()) + Some(ref attrs) => vec::append(lhs, attrs.as_slice()) } } @@ -407,7 +407,7 @@ impl<'a> Parser<'a> { } else if inedible.contains(&self.token) { // leave it in the input } else { - let expected = vec_ng::append(edible.iter() + let expected = vec::append(edible.iter() .map(|x| (*x).clone()) .collect(), inedible); @@ -449,7 +449,7 @@ impl<'a> Parser<'a> { match e.node { ExprPath(..) => { // might be unit-struct construction; check for recoverableinput error. - let expected = vec_ng::append(edible.iter() + let expected = vec::append(edible.iter() .map(|x| (*x).clone()) .collect(), inedible); @@ -472,7 +472,7 @@ impl<'a> Parser<'a> { debug!("commit_stmt {:?}", s); let _s = s; // unused, but future checks might want to inspect `s`. if self.last_token.as_ref().map_or(false, |t| is_ident_or_path(*t)) { - let expected = vec_ng::append(edible.iter() + let expected = vec::append(edible.iter() .map(|x| (*x).clone()) .collect(), inedible.as_slice()); @@ -1113,7 +1113,7 @@ impl<'a> Parser<'a> { debug!("parse_trait_methods(): parsing provided method"); let (inner_attrs, body) = p.parse_inner_attrs_and_block(); - let attrs = vec_ng::append(attrs, inner_attrs.as_slice()); + let attrs = vec::append(attrs, inner_attrs.as_slice()); Provided(@ast::Method { ident: ident, attrs: attrs, @@ -3854,7 +3854,7 @@ impl<'a> Parser<'a> { let (inner_attrs, body) = self.parse_inner_attrs_and_block(); let hi = body.span.hi; - let attrs = vec_ng::append(attrs, inner_attrs.as_slice()); + let attrs = vec::append(attrs, inner_attrs.as_slice()); @ast::Method { ident: ident, attrs: attrs, @@ -4086,7 +4086,7 @@ impl<'a> Parser<'a> { while self.token != term { let mut attrs = self.parse_outer_attributes(); if first { - attrs = vec_ng::append(attrs_remaining.clone(), + attrs = vec::append(attrs_remaining.clone(), attrs.as_slice()); first = false; } @@ -4236,7 +4236,7 @@ impl<'a> Parser<'a> { &path, id_sp); let (inner, next) = p0.parse_inner_attrs_and_next(); - let mod_attrs = vec_ng::append(outer_attrs, inner.as_slice()); + let mod_attrs = vec::append(outer_attrs, inner.as_slice()); let first_item_outer_attrs = next; let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs); { @@ -4561,7 +4561,7 @@ impl<'a> Parser<'a> { match self.token { INTERPOLATED(token::NtItem(item)) => { self.bump(); - let new_attrs = vec_ng::append(attrs, item.attrs.as_slice()); + let new_attrs = vec::append(attrs, item.attrs.as_slice()); return IoviItem(@Item { attrs: new_attrs, ..(*item).clone() @@ -4989,7 +4989,7 @@ impl<'a> Parser<'a> { mut extern_mod_allowed: bool, macros_allowed: bool) -> ParsedItemsAndViewItems { - let mut attrs = vec_ng::append(first_item_attrs, + let mut attrs = vec::append(first_item_attrs, self.parse_outer_attributes() .as_slice()); // First, parse view items. @@ -5071,7 +5071,7 @@ impl<'a> Parser<'a> { fn parse_foreign_items(&mut self, first_item_attrs: Vec , macros_allowed: bool) -> ParsedItemsAndViewItems { - let mut attrs = vec_ng::append(first_item_attrs, + let mut attrs = vec::append(first_item_attrs, self.parse_outer_attributes() .as_slice()); let mut foreign_items = Vec::new(); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index efadea16fe2..43d686dc6cb 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -22,7 +22,7 @@ use std::char; use std::fmt; use std::local_data; use std::path::BytesContainer; -use std::vec_ng::Vec; +use std::vec::Vec; #[allow(non_camel_case_types)] #[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)] diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 5540b26d9e7..c588e407e30 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -62,7 +62,7 @@ */ use std::io; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Clone, Eq)] pub enum Breaks { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 2f96a71cc0f..5c23dd163d1 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -32,7 +32,7 @@ use std::char; use std::str; use std::io; use std::io::{IoResult, MemWriter}; -use std::vec_ng::Vec; +use std::vec::Vec; // The &mut State is stored here to prevent recursive type. pub enum AnnNode<'a> { @@ -2392,7 +2392,7 @@ mod test { use codemap; use parse::token; - use std::vec_ng::Vec; + use std::vec::Vec; #[test] fn test_fun_to_str() { diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index c1ed96fe4de..8a8bf1fdfb3 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -21,7 +21,7 @@ use std::cmp::Equiv; use std::fmt; use std::hash::Hash; use std::rc::Rc; -use std::vec_ng::Vec; +use std::vec::Vec; pub struct Interner { priv map: RefCell>, diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 658e9709750..13590542dac 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -15,7 +15,7 @@ use parse::{new_parser_from_source_str}; use parse::parser::Parser; use parse::token; -use std::vec_ng::Vec; +use std::vec::Vec; // map a string to tts, using a made-up filename: pub fn string_to_tts(source_str: ~str) -> Vec { diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index f15b7dd5563..72faaee64ff 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -9,8 +9,8 @@ // except according to those terms. use std::mem; -use std::vec_ng::Vec; -use std::vec_ng; +use std::vec::Vec; +use std::vec; /// A vector type optimized for cases where the size is almost always 0 or 1 pub enum SmallVector { @@ -114,7 +114,7 @@ impl SmallVector { pub enum MoveItems { priv ZeroIterator, priv OneIterator(T), - priv ManyIterator(vec_ng::MoveItems), + priv ManyIterator(vec::MoveItems), } impl Iterator for MoveItems { @@ -146,7 +146,7 @@ impl Iterator for MoveItems { mod test { use super::*; - use std::vec_ng::Vec; + use std::vec::Vec; #[test] fn test_len() { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 880fce58083..408c9d635b6 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -15,7 +15,7 @@ use codemap::Span; use parse; use opt_vec; use opt_vec::OptVec; -use std::vec_ng::Vec; +use std::vec::Vec; // Context-passing AST walker. Each overridden visit method has full control // over what happens with its node, it can do its own traversal of the node's diff --git a/src/liburl/lib.rs b/src/liburl/lib.rs index 067479753ea..9a24e8ecfa9 100644 --- a/src/liburl/lib.rs +++ b/src/liburl/lib.rs @@ -28,7 +28,7 @@ use std::hash::Hash; use std::io::BufReader; use std::from_str::FromStr; use std::uint; -use std::vec_ng::Vec; +use std::vec::Vec; use collections::HashMap; diff --git a/src/test/compile-fail/issue-11873.rs b/src/test/compile-fail/issue-11873.rs index 49b226b882e..1ae887a8332 100644 --- a/src/test/compile-fail/issue-11873.rs +++ b/src/test/compile-fail/issue-11873.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::vec_ng::Vec; +use std::vec::Vec; fn main() { let mut v = vec!(1); diff --git a/src/test/run-pass/overloaded-autoderef-count.rs b/src/test/run-pass/overloaded-autoderef-count.rs index 10ee06473c8..1243ba1ce16 100644 --- a/src/test/run-pass/overloaded-autoderef-count.rs +++ b/src/test/run-pass/overloaded-autoderef-count.rs @@ -10,7 +10,7 @@ use std::cell::Cell; use std::ops::{Deref, DerefMut}; -use std::vec_ng::Vec; +use std::vec::Vec; #[deriving(Eq)] struct DerefCounter { diff --git a/src/test/run-pass/overloaded-deref-count.rs b/src/test/run-pass/overloaded-deref-count.rs index 28ac70c47c5..24dde8ada18 100644 --- a/src/test/run-pass/overloaded-deref-count.rs +++ b/src/test/run-pass/overloaded-deref-count.rs @@ -10,7 +10,7 @@ use std::cell::Cell; use std::ops::{Deref, DerefMut}; -use std::vec_ng::Vec; +use std::vec::Vec; struct DerefCounter { count_imm: Cell, diff --git a/src/test/run-pass/typeck_type_placeholder_1.rs b/src/test/run-pass/typeck_type_placeholder_1.rs index 789a95dd6e5..e75bcb8b89e 100644 --- a/src/test/run-pass/typeck_type_placeholder_1.rs +++ b/src/test/run-pass/typeck_type_placeholder_1.rs @@ -14,7 +14,7 @@ static CONSTEXPR: *int = &'static 413 as *_; pub fn main() { - use std::vec_ng::Vec; + use std::vec::Vec; let x: Vec<_> = range(0u, 5).collect(); assert_eq!(x.as_slice(), &[0u,1,2,3,4]); -- cgit 1.4.1-3-g733a5