]> git.lizzy.rs Git - rust.git/commitdiff
test: Make manual changes to deal with the fallout from removal of
authorPatrick Walton <pcwalton@mimiga.net>
Wed, 5 Mar 2014 23:28:08 +0000 (15:28 -0800)
committerHuon Wilson <dbau.pp+github@gmail.com>
Fri, 21 Mar 2014 12:37:21 +0000 (23:37 +1100)
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.

236 files changed:
src/compiletest/compiletest.rs
src/compiletest/errors.rs
src/compiletest/header.rs
src/compiletest/procsrv.rs
src/compiletest/runtest.rs
src/libarena/lib.rs
src/libgetopts/lib.rs
src/libglob/lib.rs
src/libnum/rational.rs
src/librustc/driver/driver.rs
src/librustc/lib.rs
src/librustdoc/clean.rs
src/librustdoc/core.rs
src/librustdoc/doctree.rs
src/librustdoc/fold.rs
src/librustdoc/html/format.rs
src/librustdoc/html/render.rs
src/librustdoc/lib.rs
src/librustdoc/markdown.rs
src/librustdoc/passes.rs
src/librustdoc/plugins.rs
src/librustdoc/test.rs
src/librustdoc/visit_ast.rs
src/libsync/arc.rs
src/libsync/sync/mod.rs
src/libsync/task_pool.rs
src/libterm/lib.rs
src/libterm/terminfo/mod.rs
src/libterm/terminfo/parm.rs
src/libterm/terminfo/parser/compiled.rs
src/libterm/terminfo/searcher.rs
src/libtest/lib.rs
src/libtime/lib.rs
src/libuuid/lib.rs
src/test/auxiliary/cci_class_6.rs
src/test/auxiliary/cci_nested_lib.rs
src/test/auxiliary/cci_no_inline_lib.rs
src/test/auxiliary/issue-2631-a.rs
src/test/auxiliary/issue_2723_a.rs
src/test/bench/core-std.rs
src/test/bench/core-uint-to-str.rs
src/test/bench/msgsend-pipes-shared.rs
src/test/bench/msgsend-pipes.rs
src/test/bench/msgsend-ring-mutex-arcs.rs
src/test/bench/msgsend-ring-rw-arcs.rs
src/test/bench/shootout-ackermann.rs
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-fasta-redux.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-fibo.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide.rs
src/test/bench/shootout-meteor.rs
src/test/bench/shootout-nbody.rs
src/test/bench/shootout-pfib.rs
src/test/bench/shootout-threadring.rs
src/test/bench/std-smallintmap.rs
src/test/bench/sudoku.rs
src/test/bench/task-perf-alloc-unwind.rs
src/test/bench/task-perf-jargon-metal-smoke.rs
src/test/bench/task-perf-spawnalot.rs
src/test/compile-fail/access-mode-in-closures.rs
src/test/compile-fail/ambig_impl_unify.rs
src/test/compile-fail/bad-expr-path.rs
src/test/compile-fail/bad-expr-path2.rs
src/test/compile-fail/borrowck-assign-comp-idx.rs
src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
src/test/compile-fail/borrowck-init-op-equal.rs
src/test/compile-fail/borrowck-loan-vec-content.rs
src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs
src/test/compile-fail/borrowck-vec-pattern-element-loan.rs
src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs
src/test/compile-fail/borrowck-vec-pattern-nesting.rs
src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs
src/test/compile-fail/drop-on-non-struct.rs
src/test/compile-fail/empty-vec-trailing-comma.rs [deleted file]
src/test/compile-fail/evec-subtyping.rs [deleted file]
src/test/compile-fail/import.rs
src/test/compile-fail/import2.rs
src/test/compile-fail/import4.rs
src/test/compile-fail/infinite-vec-type-recursion.rs
src/test/compile-fail/issue-10487.rs [deleted file]
src/test/compile-fail/issue-2149.rs
src/test/compile-fail/issue-2150.rs
src/test/compile-fail/issue-2548.rs [deleted file]
src/test/compile-fail/issue-2590.rs
src/test/compile-fail/issue-3044.rs
src/test/compile-fail/issue-7573.rs
src/test/compile-fail/issue-8727.rs
src/test/compile-fail/kindck-freeze.rs
src/test/compile-fail/kindck-pod.rs
src/test/compile-fail/kindck-send.rs
src/test/compile-fail/lint-heap-memory.rs
src/test/compile-fail/lint-unused-mut-variables.rs
src/test/compile-fail/lint-unused-unsafe.rs
src/test/compile-fail/liveness-issue-2163.rs
src/test/compile-fail/match-vec-unreachable.rs
src/test/compile-fail/moves-based-on-type-access-to-field.rs
src/test/compile-fail/moves-based-on-type-exprs.rs
src/test/compile-fail/no-capture-arc.rs
src/test/compile-fail/no-reuse-move-arc.rs
src/test/compile-fail/non-constant-enum-for-vec-repeat.rs
src/test/compile-fail/non-copyable-void.rs
src/test/compile-fail/non-exhaustive-match.rs
src/test/compile-fail/pattern-tyvar-2.rs
src/test/compile-fail/repeat_count.rs
src/test/compile-fail/tag-that-dare-not-speak-its-name.rs
src/test/compile-fail/uninstantiable-fixed-length-vec.rs [deleted file]
src/test/compile-fail/unique-vec-res.rs
src/test/compile-fail/use-after-move-implicity-coerced-object.rs
src/test/compile-fail/vector-no-ann.rs
src/test/compile-fail/writing-to-immutable-vec.rs
src/test/pretty/block-disambig.rs
src/test/pretty/match-naked-expr-medium.rs
src/test/pretty/vec-comments.pp
src/test/pretty/vec-comments.rs
src/test/pretty/vec-type.pp [deleted file]
src/test/pretty/vec-type.rs [deleted file]
src/test/run-fail/bug-2470-bounds-check-overflow.rs
src/test/run-fail/issue-3029.rs
src/test/run-fail/unwind-misc-1.rs
src/test/run-fail/unwind-partial-box.rs
src/test/run-fail/unwind-partial-unique.rs
src/test/run-fail/unwind-partial-vec.rs
src/test/run-fail/unwind-rec.rs
src/test/run-fail/unwind-rec2.rs
src/test/run-fail/unwind-tup.rs
src/test/run-fail/unwind-tup2.rs
src/test/run-fail/vec-overrun.rs
src/test/run-pass/alloca-from-derived-tydesc.rs
src/test/run-pass/assignability-trait.rs
src/test/run-pass/auto-ref-slice-plus-ref.rs
src/test/run-pass/auto-ref-sliceable.rs
src/test/run-pass/autobind.rs
src/test/run-pass/block-iter-1.rs
src/test/run-pass/block-iter-2.rs
src/test/run-pass/borrow-by-val-method-receiver.rs
src/test/run-pass/borrowck-binding-mutbl.rs
src/test/run-pass/borrowck-mut-uniq.rs
src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs
src/test/run-pass/borrowck-root-while-cond-2.rs
src/test/run-pass/borrowck-root-while-cond.rs
src/test/run-pass/call-closure-from-overloaded-op.rs
src/test/run-pass/class-poly-methods.rs
src/test/run-pass/cleanup-rvalue-scopes.rs
src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs
src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs
src/test/run-pass/coerce-reborrow-mut-vec-arg.rs
src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs
src/test/run-pass/const-enum-vec-repeat.rs [deleted file]
src/test/run-pass/deep-vector.rs
src/test/run-pass/deep-vector2.rs
src/test/run-pass/empty-mutable-vec.rs
src/test/run-pass/expr-fn.rs
src/test/run-pass/expr-match-fail.rs
src/test/run-pass/expr-repeat-vstore.rs [deleted file]
src/test/run-pass/for-loop-fail.rs
src/test/run-pass/foreach-nested.rs
src/test/run-pass/generic-static-methods.rs
src/test/run-pass/getopts_ref.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/html-literals.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/import-glob-crate.rs
src/test/run-pass/infer-fn-tail-expr.rs
src/test/run-pass/integral-indexing.rs
src/test/run-pass/issue-1821.rs
src/test/run-pass/issue-2502.rs
src/test/run-pass/issue-2804.rs
src/test/run-pass/issue-2904.rs
src/test/run-pass/issue-2989.rs
src/test/run-pass/issue-3052.rs
src/test/run-pass/issue-3389.rs
src/test/run-pass/issue-3563-3.rs
src/test/run-pass/issue-3609.rs
src/test/run-pass/issue-3991.rs
src/test/run-pass/issue-4036.rs
src/test/run-pass/issue-5708.rs
src/test/run-pass/issue-6153.rs
src/test/run-pass/issue-8898.rs
src/test/run-pass/issue-9382.rs
src/test/run-pass/ivec-add.rs [deleted file]
src/test/run-pass/ivec-pass-by-value.rs
src/test/run-pass/ivec-tag.rs
src/test/run-pass/lambda-infer-unresolved.rs
src/test/run-pass/liveness-move-in-loop.rs
src/test/run-pass/log-str.rs [deleted file]
src/test/run-pass/match-vec-rvalue.rs
src/test/run-pass/monad.rs
src/test/run-pass/move-arg-2-unique.rs
src/test/run-pass/move-arg-2.rs
src/test/run-pass/mutable-alias-vec.rs
src/test/run-pass/mutable-vec-drop.rs
src/test/run-pass/newtype-polymorphic.rs
src/test/run-pass/nullable-pointer-iotareduction.rs
src/test/run-pass/nullable-pointer-size.rs
src/test/run-pass/objects-owned-object-borrowed-method-header.rs
src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs
src/test/run-pass/overload-index-operator.rs
src/test/run-pass/overloaded-deref.rs
src/test/run-pass/packed-struct-generic-size.rs
src/test/run-pass/pure-sum.rs
src/test/run-pass/rcvr-borrowed-to-slice.rs
src/test/run-pass/reflect-visit-type.rs
src/test/run-pass/regions-borrow-evec-uniq.rs
src/test/run-pass/regions-dependent-addr-of.rs
src/test/run-pass/regions-dependent-autoslice.rs
src/test/run-pass/regions-infer-borrow-scope-view.rs
src/test/run-pass/regions-mock-tcx.rs
src/test/run-pass/seq-compare.rs
src/test/run-pass/shadow.rs
src/test/run-pass/shape_intrinsic_tag_then_rec.rs
src/test/run-pass/size-and-align.rs
src/test/run-pass/static-impl.rs
src/test/run-pass/swap-2.rs
src/test/run-pass/task-comm-16.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/trait-bounds-in-arc.rs
src/test/run-pass/trait-generic.rs
src/test/run-pass/trait-to-str.rs
src/test/run-pass/tydesc-name.rs
src/test/run-pass/type-params-in-for-each.rs
src/test/run-pass/unique-autoderef-index.rs
src/test/run-pass/unique-in-vec-copy.rs
src/test/run-pass/unique-in-vec.rs
src/test/run-pass/utf8_chars.rs
src/test/run-pass/vec-concat.rs
src/test/run-pass/vec-drop.rs
src/test/run-pass/vec-growth.rs
src/test/run-pass/vec-ivec-deadlock.rs [deleted file]
src/test/run-pass/vec-late-init.rs
src/test/run-pass/vec-trailing-comma.rs [deleted file]
src/test/run-pass/vec.rs
src/test/run-pass/vector-no-ann-2.rs
src/test/run-pass/while-with-break.rs

index 855bc1e5852d07fb3f9fae67b7b53c77b0eab480..3916aa3b2af60157146d84804b10458e6a4e9b94 100644 (file)
@@ -21,6 +21,7 @@
 extern crate log;
 
 use std::os;
+use std::vec_ng::Vec;
 use std::io;
 use std::io::fs;
 use getopts::{optopt, optflag, reqopt};
 
 pub fn main() {
     let args = os::args();
-    let config = parse_config(args);
+    let config = parse_config(args.move_iter().collect());
     log_config(&config);
     run_tests(&config);
 }
 
-pub fn parse_config(args: ~[~str]) -> config {
+pub fn parse_config(args: Vec<~str> ) -> config {
 
-    let groups : ~[getopts::OptGroup] =
-        ~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
+    let groups : Vec<getopts::OptGroup> =
+        vec!(reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
           reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
           reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
           optopt("", "clang-path", "path to  executable for codegen tests", "PATH"),
@@ -79,28 +80,27 @@ pub fn parse_config(args: ~[~str]) -> config {
           optopt("", "adb-path", "path to the android debugger", "PATH"),
           optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
           optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite", "A.B"),
-          optflag("h", "help", "show this message"),
-         ];
+          optflag("h", "help", "show this message"));
 
     assert!(!args.is_empty());
-    let argv0 = args[0].clone();
+    let argv0 = (*args.get(0)).clone();
     let args_ = args.tail();
-    if args[1] == ~"-h" || args[1] == ~"--help" {
+    if *args.get(1) == ~"-h" || *args.get(1) == ~"--help" {
         let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
-        println!("{}", getopts::usage(message, groups));
+        println!("{}", getopts::usage(message, groups.as_slice()));
         println!("");
         fail!()
     }
 
     let matches =
-        &match getopts::getopts(args_, groups) {
+        &match getopts::getopts(args_, groups.as_slice()) {
           Ok(m) => m,
           Err(f) => fail!("{}", f.to_err_msg())
         };
 
     if matches.opt_present("h") || matches.opt_present("help") {
         let message = format!("Usage: {} [OPTIONS]  [TESTNAME...]", argv0);
-        println!("{}", getopts::usage(message, groups));
+        println!("{}", getopts::usage(message, groups.as_slice()));
         println!("");
         fail!()
     }
@@ -123,7 +123,7 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
         run_ignored: matches.opt_present("ignored"),
         filter:
             if !matches.free.is_empty() {
-                 Some(matches.free[0].clone())
+                 Some((*matches.free.get(0)).clone())
             } else {
                 None
             },
@@ -239,7 +239,7 @@ pub fn run_tests(config: &config) {
     // parallel (especially when we have lots and lots of child processes).
     // For context, see #8904
     io::test::raise_fd_limit();
-    let res = test::run_tests_console(&opts, tests);
+    let res = test::run_tests_console(&opts, tests.move_iter().collect());
     match res {
         Ok(true) => {}
         Ok(false) => fail!("Some tests failed"),
@@ -263,10 +263,10 @@ pub fn test_opts(config: &config) -> test::TestOpts {
     }
 }
 
-pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
+pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
     debug!("making tests from {}",
            config.src_base.display());
-    let mut tests = ~[];
+    let mut tests = Vec::new();
     let dirs = fs::readdir(&config.src_base).unwrap();
     for file in dirs.iter() {
         let file = file.clone();
@@ -288,10 +288,10 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
     // Pretty-printer does not work with .rc files yet
     let valid_extensions =
         match config.mode {
-          mode_pretty => ~[~".rs"],
-          _ => ~[~".rc", ~".rs"]
+          mode_pretty => vec!(~".rs"),
+          _ => vec!(~".rc", ~".rs")
         };
-    let invalid_prefixes = ~[~".", ~"#", ~"~"];
+    let invalid_prefixes = vec!(~".", ~"#", ~"~");
     let name = testfile.filename_str().unwrap();
 
     let mut valid = false;
index 4fee64e630481e679dd9fdb6bc102f91a8850bb9..8dfde741104a4780bf0bca2b916da7459e6a6564 100644 (file)
@@ -9,13 +9,14 @@
 // except according to those terms.
 
 use std::io::{BufferedReader, File};
+use std::vec_ng::Vec;
 
 pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
 
 // Load any test directives embedded in the file
-pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
+pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
 
-    let mut error_patterns = ~[];
+    let mut error_patterns = Vec::new();
     let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
     let mut line_num = 1u;
     for ln in rdr.lines() {
@@ -25,12 +26,12 @@ pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
     return error_patterns;
 }
 
-fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
+fn parse_expected(line_num: uint, line: ~str) -> Vec<ExpectedError> {
     let line = line.trim();
     let error_tag = ~"//~";
     let mut idx;
     match line.find_str(error_tag) {
-      None => return ~[],
+      None => return Vec::new(),
       Some(nn) => { idx = (nn as uint) + error_tag.len(); }
     }
 
@@ -57,6 +58,6 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
 
     debug!("line={} kind={} msg={}", line_num - adjust_line, kind, msg);
 
-    return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
-                           msg: msg}];
+    return vec!(ExpectedError{line: line_num - adjust_line, kind: kind,
+                           msg: msg});
 }
index 81b76f6b09a835d6ea98eff16e42effdb66999ac..a68bcb73e86639716206091c9b2839f2a9cfe239 100644 (file)
 use common;
 use util;
 
+use std::vec_ng::Vec;
+
 pub struct TestProps {
     // Lines that should be expected, in order, on standard out
-    error_patterns: ~[~str],
+    error_patterns: Vec<~str> ,
     // Extra flags to pass to the compiler
     compile_flags: Option<~str>,
     // If present, the name of a file that this test should match when
     // pretty-printed
     pp_exact: Option<Path>,
     // Modules from aux directory that should be compiled
-    aux_builds: ~[~str],
+    aux_builds: Vec<~str> ,
     // Environment settings to use during execution
-    exec_env: ~[(~str,~str)],
+    exec_env: Vec<(~str,~str)> ,
     // Commands to be given to the debugger, when testing debug info
-    debugger_cmds: ~[~str],
+    debugger_cmds: Vec<~str> ,
     // Lines to check if they appear in the expected debugger output
-    check_lines: ~[~str],
+    check_lines: Vec<~str> ,
     // Flag to force a crate to be built with the host architecture
     force_host: bool,
     // Check stdout for error-pattern output as well as stderr
@@ -38,13 +40,13 @@ pub struct TestProps {
 
 // Load any test directives embedded in the file
 pub fn load_props(testfile: &Path) -> TestProps {
-    let mut error_patterns = ~[];
-    let mut aux_builds = ~[];
-    let mut exec_env = ~[];
+    let mut error_patterns = Vec::new();
+    let mut aux_builds = Vec::new();
+    let mut exec_env = Vec::new();
     let mut compile_flags = None;
     let mut pp_exact = None;
-    let mut debugger_cmds = ~[];
-    let mut check_lines = ~[];
+    let mut debugger_cmds = Vec::new();
+    let mut check_lines = Vec::new();
     let mut force_host = false;
     let mut check_stdout = false;
     let mut no_prefer_dynamic = false;
@@ -183,7 +185,7 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
 fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
     parse_name_value_directive(line, ~"exec-env").map(|nv| {
         // nv is either FOO or FOO=BAR
-        let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
+        let mut strs: Vec<~str> = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
 
         match strs.len() {
           1u => (strs.pop().unwrap(), ~""),
index 5db01399992e888e111f4832456949e0a4cc77f2..78ff059a67f05389b3136e4ad3e69d7e4434f1b8 100644 (file)
 use std::os;
 use std::str;
 use std::io::process::{ProcessExit, Process, ProcessConfig, ProcessOutput};
+use std::vec;
 
 #[cfg(target_os = "win32")]
-fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
+fn target_env(lib_path: &str, prog: &str) -> Vec<(~str,~str)> {
 
     let mut env = os::env();
 
@@ -35,11 +36,11 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
 #[cfg(target_os = "linux")]
 #[cfg(target_os = "macos")]
 #[cfg(target_os = "freebsd")]
-fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
+fn target_env(lib_path: &str, prog: &str) -> Vec<(~str,~str)> {
     // Make sure we include the aux directory in the path
     let aux_path = prog + ".libaux";
 
-    let mut env = os::env();
+    let mut env: Vec<(~str,~str)> = os::env().move_iter().collect();
     let var = if cfg!(target_os = "macos") {
         "DYLD_LIBRARY_PATH"
     } else {
@@ -62,10 +63,11 @@ pub struct Result {status: ProcessExit, out: ~str, err: ~str}
 pub fn run(lib_path: &str,
            prog: &str,
            args: &[~str],
-           env: ~[(~str, ~str)],
+           env: Vec<(~str, ~str)> ,
            input: Option<~str>) -> Option<Result> {
 
-    let env = env + target_env(lib_path, prog);
+    let env = vec::append(env.clone(),
+                             target_env(lib_path, prog).as_slice());
     let mut opt_process = Process::configure(ProcessConfig {
         program: prog,
         args: args,
@@ -93,10 +95,11 @@ pub fn run(lib_path: &str,
 pub fn run_background(lib_path: &str,
            prog: &str,
            args: &[~str],
-           env: ~[(~str, ~str)],
+           env: Vec<(~str, ~str)> ,
            input: Option<~str>) -> Option<Process> {
 
-    let env = env + target_env(lib_path, prog);
+    let env = vec::append(env.clone(),
+                             target_env(lib_path, prog).as_slice());
     let opt_process = Process::configure(ProcessConfig {
         program: prog,
         args: args,
index 796fc2c802b58ce6ad199ed5bf09a495cf0a6fdf..77b898023689852c9a310c2609ccf32bf6d34843 100644 (file)
@@ -33,6 +33,7 @@
 use std::str;
 use std::task;
 use std::slice;
+use std::vec_ng;
 
 use test::MetricMap;
 
@@ -155,12 +156,14 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
 
     let src = File::open(testfile).read_to_end().unwrap();
     let src = str::from_utf8_owned(src).unwrap();
-    let mut srcs = ~[src];
+    let mut srcs = vec!(src);
 
     let mut round = 0;
     while round < rounds {
         logv(config, format!("pretty-printing round {}", round));
-        let proc_res = print_source(config, testfile, srcs[round].clone());
+        let proc_res = print_source(config,
+                                    testfile,
+                                    (*srcs.get(round)).clone());
 
         if !proc_res.status.success() {
             fatal_ProcRes(format!("pretty-printing failed in round {}", round),
@@ -178,9 +181,9 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
             let s = File::open(&filepath).read_to_end().unwrap();
             str::from_utf8_owned(s).unwrap()
           }
-          None => { srcs[srcs.len() - 2u].clone() }
+          None => { (*srcs.get(srcs.len() - 2u)).clone() }
         };
-    let mut actual = srcs[srcs.len() - 1u].clone();
+    let mut actual = (*srcs.get(srcs.len() - 1u)).clone();
 
     if props.pp_exact.is_some() {
         // Now we have to care about line endings
@@ -202,12 +205,12 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
 
     fn print_source(config: &config, testfile: &Path, src: ~str) -> ProcRes {
         compose_and_run(config, testfile, make_pp_args(config, testfile),
-                        ~[], config.compile_lib_path, Some(src))
+                        Vec::new(), config.compile_lib_path, Some(src))
     }
 
     fn make_pp_args(config: &config, _testfile: &Path) -> ProcArgs {
-        let args = ~[~"-", ~"--pretty", ~"normal",
-                     ~"--target=" + config.target];
+        let args = vec!(~"-", ~"--pretty", ~"normal",
+                     ~"--target=" + config.target);
         // FIXME (#9639): This needs to handle non-utf8 paths
         return ProcArgs {prog: config.rustc_path.as_str().unwrap().to_owned(), args: args};
     }
@@ -244,12 +247,12 @@ fn make_typecheck_args(config: &config, props: &TestProps, testfile: &Path) -> P
             config.target.as_slice()
         };
         // FIXME (#9639): This needs to handle non-utf8 paths
-        let mut args = ~[~"-",
+        let mut args = vec!(~"-",
                          ~"--no-trans", ~"--crate-type=lib",
                          ~"--target=" + target,
                          ~"-L", config.build_base.as_str().unwrap().to_owned(),
                          ~"-L",
-                         aux_dir.as_str().unwrap().to_owned()];
+                         aux_dir.as_str().unwrap().to_owned());
         args.push_all_move(split_maybe_args(&config.target_rustcflags));
         args.push_all_move(split_maybe_args(&props.compile_flags));
         // FIXME (#9639): This needs to handle non-utf8 paths
@@ -295,12 +298,12 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
             procsrv::run("", config.adb_path,
                          [~"push", exe_file.as_str().unwrap().to_owned(),
                           config.adb_test_dir.clone()],
-                         ~[(~"",~"")], Some(~""))
+                         vec!((~"",~"")), Some(~""))
                 .expect(format!("failed to exec `{}`", config.adb_path));
 
             procsrv::run("", config.adb_path,
                          [~"forward", ~"tcp:5039", ~"tcp:5039"],
-                         ~[(~"",~"")], Some(~""))
+                         vec!((~"",~"")), Some(~""))
                 .expect(format!("failed to exec `{}`", config.adb_path));
 
             let adb_arg = format!("export LD_LIBRARY_PATH={}; gdbserver :5039 {}/{}",
@@ -309,7 +312,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
 
             let mut process = procsrv::run_background("", config.adb_path,
                                                       [~"shell",adb_arg.clone()],
-                                                      ~[(~"",~"")], Some(~""))
+                                                      vec!((~"",~"")), Some(~""))
                 .expect(format!("failed to exec `{}`", config.adb_path));
             loop {
                 //waiting 1 second for gdbserver start
@@ -341,17 +344,21 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
 
             let debugger_script = make_out_name(config, testfile, "debugger.script");
             // FIXME (#9639): This needs to handle non-utf8 paths
-            let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
-                                  "-command=" + debugger_script.as_str().unwrap().to_owned()];
+            let debugger_opts = vec!(~"-quiet", ~"-batch", ~"-nx",
+                                  "-command=" + debugger_script.as_str().unwrap().to_owned());
 
             let gdb_path = tool_path.append("/bin/arm-linux-androideabi-gdb");
             let procsrv::Result{ out, err, status }=
                 procsrv::run("",
                              gdb_path,
-                             debugger_opts, ~[(~"",~"")], None)
+                             debugger_opts.as_slice(),
+                             vec!((~"",~"")),
+                             None)
                 .expect(format!("failed to exec `{}`", gdb_path));
             let cmdline = {
-                let cmdline = make_cmdline("", "arm-linux-androideabi-gdb", debugger_opts);
+                let cmdline = make_cmdline("",
+                                           "arm-linux-androideabi-gdb",
+                                           debugger_opts.as_slice());
                 logv(config, format!("executing {}", cmdline));
                 cmdline
             };
@@ -380,11 +387,11 @@ fn debugger() -> ~str { ~"gdb" }
             let debugger_script = make_out_name(config, testfile, "debugger.script");
 
             // FIXME (#9639): This needs to handle non-utf8 paths
-            let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
+            let debugger_opts = vec!(~"-quiet", ~"-batch", ~"-nx",
                 "-command=" + debugger_script.as_str().unwrap().to_owned(),
-                exe_file.as_str().unwrap().to_owned()];
+                exe_file.as_str().unwrap().to_owned());
             proc_args = ProcArgs {prog: debugger(), args: debugger_opts};
-            proc_res = compose_and_run(config, testfile, proc_args, ~[], "", None);
+            proc_res = compose_and_run(config, testfile, proc_args, Vec::new(), "", None);
         }
     }
 
@@ -395,7 +402,10 @@ fn debugger() -> ~str { ~"gdb" }
     if num_check_lines > 0 {
         // Allow check lines to leave parts unspecified (e.g., uninitialized
         // bits in the wrong case of an enum) with the notation "[...]".
-        let check_fragments: ~[~[&str]] = check_lines.map(|s| s.split_str("[...]").collect());
+        let check_fragments: Vec<Vec<~str>> =
+            check_lines.iter().map(|s| {
+                s.split_str("[...]").map(|x| x.to_str()).collect()
+            }).collect();
         // check if each line in props.check_lines appears in the
         // output (in order)
         let mut i = 0u;
@@ -403,11 +413,11 @@ fn debugger() -> ~str { ~"gdb" }
             let mut rest = line.trim();
             let mut first = true;
             let mut failed = false;
-            for &frag in check_fragments[i].iter() {
+            for frag in check_fragments.get(i).iter() {
                 let found = if first {
-                    if rest.starts_with(frag) { Some(0) } else { None }
+                    if rest.starts_with(*frag) { Some(0) } else { None }
                 } else {
-                    rest.find_str(frag)
+                    rest.find_str(*frag)
                 };
                 match found {
                     None => {
@@ -430,7 +440,7 @@ fn debugger() -> ~str { ~"gdb" }
         }
         if i != num_check_lines {
             fatal_ProcRes(format!("line not found in debugger output: {}",
-                                  check_lines[i]), &proc_res);
+                                  *check_lines.get(i)), &proc_res);
         }
     }
 
@@ -461,7 +471,7 @@ fn check_error_patterns(props: &TestProps,
     }
 
     let mut next_err_idx = 0u;
-    let mut next_err_pat = &props.error_patterns[next_err_idx];
+    let mut next_err_pat = props.error_patterns.get(next_err_idx);
     let mut done = false;
     let output_to_check = if props.check_stdout {
         proc_res.stdout + proc_res.stderr
@@ -477,7 +487,7 @@ fn check_error_patterns(props: &TestProps,
                 done = true;
                 break;
             }
-            next_err_pat = &props.error_patterns[next_err_idx];
+            next_err_pat = props.error_patterns.get(next_err_idx);
         }
     }
     if done { return; }
@@ -495,7 +505,7 @@ fn check_error_patterns(props: &TestProps,
     }
 }
 
-fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
+fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
                          testfile: &Path,
                          proc_res: &ProcRes) {
 
@@ -509,12 +519,12 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
 
     let prefixes = expected_errors.iter().map(|ee| {
         format!("{}:{}:", testfile.display(), ee.line)
-    }).collect::<~[~str]>();
+    }).collect::<Vec<~str> >();
 
     #[cfg(target_os = "win32")]
     fn to_lower( s : &str ) -> ~str {
         let i = s.chars();
-        let c : ~[char] = i.map( |c| {
+        let c : Vec<char> = i.map( |c| {
             if c.is_ascii() {
                 c.to_ascii().to_lower().to_char()
             } else {
@@ -547,8 +557,8 @@ fn prefix_matches( line : &str, prefix : &str ) -> bool {
         for (i, ee) in expected_errors.iter().enumerate() {
             if !found_flags[i] {
                 debug!("prefix={} ee.kind={} ee.msg={} line={}",
-                       prefixes[i], ee.kind, ee.msg, line);
-                if prefix_matches(line, prefixes[i]) &&
+                       *prefixes.get(i), ee.kind, ee.msg, line);
+                if prefix_matches(line, *prefixes.get(i)) &&
                     line.contains(ee.kind) &&
                     line.contains(ee.msg) {
                     found_flags[i] = true;
@@ -572,7 +582,7 @@ fn prefix_matches( line : &str, prefix : &str ) -> bool {
 
     for (i, &flag) in found_flags.iter().enumerate() {
         if !flag {
-            let ee = &expected_errors[i];
+            let ee = expected_errors.get(i);
             fatal_ProcRes(format!("expected {} on line {} not found: {}",
                                ee.kind, ee.line, ee.msg), proc_res);
         }
@@ -654,7 +664,7 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut uint) -> bool {
     return true;
 }
 
-struct ProcArgs {prog: ~str, args: ~[~str]}
+struct ProcArgs {prog: ~str, args: Vec<~str> }
 
 struct ProcRes {status: ProcessExit, stdout: ~str, stderr: ~str, cmdline: ~str}
 
@@ -671,8 +681,10 @@ fn compile_test_(config: &config, props: &TestProps,
                  testfile: &Path, extra_args: &[~str]) -> ProcRes {
     let aux_dir = aux_output_dir_name(config, testfile);
     // FIXME (#9639): This needs to handle non-utf8 paths
-    let link_args = ~[~"-L", aux_dir.as_str().unwrap().to_owned()];
-    let args = make_compile_args(config, props, link_args + extra_args,
+    let link_args = vec!(~"-L", aux_dir.as_str().unwrap().to_owned());
+    let args = make_compile_args(config,
+                                 props,
+                                 vec::append(link_args, extra_args),
                                  |a, b| ThisFile(make_exe_name(a, b)), testfile);
     compose_and_run_compiler(config, props, testfile, args, None)
 }
@@ -710,23 +722,26 @@ fn compose_and_run_compiler(
 
     let aux_dir = aux_output_dir_name(config, testfile);
     // FIXME (#9639): This needs to handle non-utf8 paths
-    let extra_link_args = ~[~"-L", aux_dir.as_str().unwrap().to_owned()];
+    let extra_link_args = vec!(~"-L", aux_dir.as_str().unwrap().to_owned());
 
     for rel_ab in props.aux_builds.iter() {
         let abs_ab = config.aux_base.join(rel_ab.as_slice());
         let aux_props = load_props(&abs_ab);
         let crate_type = if aux_props.no_prefer_dynamic {
-            ~[]
+            Vec::new()
         } else {
-            ~[~"--crate-type=dylib"]
+            vec!(~"--crate-type=dylib")
         };
         let aux_args =
-            make_compile_args(config, &aux_props, crate_type + extra_link_args,
+            make_compile_args(config,
+                              &aux_props,
+                              vec::append(crate_type,
+                                             extra_link_args.as_slice()),
                               |a,b| {
                                   let f = make_lib_name(a, b, testfile);
                                   ThisDirectory(f.dir_path())
                               }, &abs_ab);
-        let auxres = compose_and_run(config, &abs_ab, aux_args, ~[],
+        let auxres = compose_and_run(config, &abs_ab, aux_args, Vec::new(),
                                      config.compile_lib_path, None);
         if !auxres.status.success() {
             fatal_ProcRes(
@@ -745,7 +760,7 @@ fn compose_and_run_compiler(
         }
     }
 
-    compose_and_run(config, testfile, args, ~[],
+    compose_and_run(config, testfile, args, Vec::new(),
                     config.compile_lib_path, input)
 }
 
@@ -756,7 +771,7 @@ fn ensure_dir(path: &Path) {
 
 fn compose_and_run(config: &config, testfile: &Path,
                    ProcArgs{ args, prog }: ProcArgs,
-                   procenv: ~[(~str, ~str)],
+                   procenv: Vec<(~str, ~str)> ,
                    lib_path: &str,
                    input: Option<~str>) -> ProcRes {
     return program_output(config, testfile, lib_path,
@@ -770,7 +785,7 @@ enum TargetLocation {
 
 fn make_compile_args(config: &config,
                      props: &TestProps,
-                     extras: ~[~str],
+                     extras: Vec<~str> ,
                      xform: |&config, &Path| -> TargetLocation,
                      testfile: &Path)
                      -> ProcArgs {
@@ -781,10 +796,10 @@ fn make_compile_args(config: &config,
         config.target.as_slice()
     };
     // FIXME (#9639): This needs to handle non-utf8 paths
-    let mut args = ~[testfile.as_str().unwrap().to_owned(),
+    let mut args = vec!(testfile.as_str().unwrap().to_owned(),
                      ~"-L", config.build_base.as_str().unwrap().to_owned(),
-                     ~"--target=" + target]
-        + extras;
+                     ~"--target=" + target);
+    args.push_all(extras.as_slice());
     if !props.no_prefer_dynamic {
         args.push(~"-C");
         args.push(~"prefer-dynamic");
@@ -833,28 +848,28 @@ fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
     return ProcArgs {prog: prog, args: args};
 }
 
-fn split_maybe_args(argstr: &Option<~str>) -> ~[~str] {
+fn split_maybe_args(argstr: &Option<~str>) -> Vec<~str> {
     match *argstr {
         Some(ref s) => {
             s.split(' ')
                 .filter_map(|s| if s.is_whitespace() {None} else {Some(s.to_owned())})
                 .collect()
         }
-        None => ~[]
+        None => Vec::new()
     }
 }
 
 fn program_output(config: &config, testfile: &Path, lib_path: &str, prog: ~str,
-                  args: ~[~str], env: ~[(~str, ~str)],
+                  args: Vec<~str> , env: Vec<(~str, ~str)> ,
                   input: Option<~str>) -> ProcRes {
     let cmdline =
         {
-            let cmdline = make_cmdline(lib_path, prog, args);
+            let cmdline = make_cmdline(lib_path, prog, args.as_slice());
             logv(config, format!("executing {}", cmdline));
             cmdline
         };
     let procsrv::Result{ out, err, status } =
-            procsrv::run(lib_path, prog, args, env, input)
+            procsrv::run(lib_path, prog, args.as_slice(), env, input)
             .expect(format!("failed to exec `{}`", prog));
     dump_output(config, testfile, out, err);
     return ProcRes {status: status,
@@ -951,19 +966,19 @@ fn fatal_ProcRes(err: ~str, proc_res: &ProcRes) -> ! {
 }
 
 fn _arm_exec_compiled_test(config: &config, props: &TestProps,
-                      testfile: &Path, env: ~[(~str, ~str)]) -> ProcRes {
+                      testfile: &Path, env: Vec<(~str, ~str)> ) -> ProcRes {
 
     let args = make_run_args(config, props, testfile);
-    let cmdline = make_cmdline("", args.prog, args.args);
+    let cmdline = make_cmdline("", args.prog, args.args.as_slice());
 
     // get bare program string
-    let mut tvec: ~[~str] = args.prog.split('/').map(|ts| ts.to_owned()).collect();
+    let mut tvec: Vec<~str> = args.prog.split('/').map(|ts| ts.to_owned()).collect();
     let prog_short = tvec.pop().unwrap();
 
     // copy to target
     let copy_result = procsrv::run("", config.adb_path,
         [~"push", args.prog.clone(), config.adb_test_dir.clone()],
-        ~[(~"",~"")], Some(~""))
+        vec!((~"",~"")), Some(~""))
         .expect(format!("failed to exec `{}`", config.adb_path));
 
     if config.verbose {
@@ -974,7 +989,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
 
     logv(config, format!("executing ({}) {}", config.target, cmdline));
 
-    let mut runargs = ~[];
+    let mut runargs = Vec::new();
 
     // run test via adb_run_wrapper
     runargs.push(~"shell");
@@ -988,17 +1003,20 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
     for tv in args.args.iter() {
         runargs.push(tv.to_owned());
     }
-    procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""))
+    procsrv::run("",
+                 config.adb_path,
+                 runargs.as_slice(),
+                 vec!((~"",~"")), Some(~""))
         .expect(format!("failed to exec `{}`", config.adb_path));
 
     // get exitcode of result
-    runargs = ~[];
+    runargs = Vec::new();
     runargs.push(~"shell");
     runargs.push(~"cat");
     runargs.push(format!("{}/{}.exitcode", config.adb_test_dir, prog_short));
 
     let procsrv::Result{ out: exitcode_out, err: _, status: _ } =
-        procsrv::run("", config.adb_path, runargs, ~[(~"",~"")],
+        procsrv::run("", config.adb_path, runargs.as_slice(), vec!((~"",~"")),
                      Some(~""))
         .expect(format!("failed to exec `{}`", config.adb_path));
 
@@ -1012,23 +1030,29 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
     }
 
     // get stdout of result
-    runargs = ~[];
+    runargs = Vec::new();
     runargs.push(~"shell");
     runargs.push(~"cat");
     runargs.push(format!("{}/{}.stdout", config.adb_test_dir, prog_short));
 
     let procsrv::Result{ out: stdout_out, err: _, status: _ } =
-        procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""))
+        procsrv::run("",
+                     config.adb_path,
+                     runargs.as_slice(),
+                     vec!((~"",~"")), Some(~""))
         .expect(format!("failed to exec `{}`", config.adb_path));
 
     // get stderr of result
-    runargs = ~[];
+    runargs = Vec::new();
     runargs.push(~"shell");
     runargs.push(~"cat");
     runargs.push(format!("{}/{}.stderr", config.adb_test_dir, prog_short));
 
     let procsrv::Result{ out: stderr_out, err: _, status: _ } =
-        procsrv::run("", config.adb_path, runargs, ~[(~"",~"")], Some(~""))
+        procsrv::run("",
+                     config.adb_path,
+                     runargs.as_slice(),
+                     vec!((~"",~"")), Some(~""))
         .expect(format!("failed to exec `{}`", config.adb_path));
 
     dump_output(config, testfile, stdout_out, stderr_out);
@@ -1050,7 +1074,7 @@ fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
             // FIXME (#9639): This needs to handle non-utf8 paths
             let copy_result = procsrv::run("", config.adb_path,
                 [~"push", file.as_str().unwrap().to_owned(), config.adb_test_dir.clone()],
-                ~[(~"",~"")], Some(~""))
+                vec!((~"",~"")), Some(~""))
                 .expect(format!("failed to exec `{}`", config.adb_path));
 
             if config.verbose {
@@ -1081,10 +1105,12 @@ fn compile_test_and_save_bitcode(config: &config, props: &TestProps,
                                  testfile: &Path) -> ProcRes {
     let aux_dir = aux_output_dir_name(config, testfile);
     // FIXME (#9639): This needs to handle non-utf8 paths
-    let link_args = ~[~"-L", aux_dir.as_str().unwrap().to_owned()];
-    let llvm_args = ~[~"--emit=obj", ~"--crate-type=lib", ~"-C", ~"save-temps"];
-    let args = make_compile_args(config, props,
-                                 link_args + llvm_args,
+    let link_args = vec!(~"-L", aux_dir.as_str().unwrap().to_owned());
+    let llvm_args = vec!(~"--emit=obj", ~"--crate-type=lib", ~"-C", ~"save-temps");
+    let args = make_compile_args(config,
+                                 props,
+                                 vec::append(link_args,
+                                                llvm_args.as_slice()),
                                  |a, b| ThisFile(make_o_name(a, b)), testfile);
     compose_and_run_compiler(config, props, testfile, args, None)
 }
@@ -1097,12 +1123,12 @@ fn compile_cc_with_clang_and_save_bitcode(config: &config, _props: &TestProps,
     let proc_args = ProcArgs {
         // FIXME (#9639): This needs to handle non-utf8 paths
         prog: config.clang_path.get_ref().as_str().unwrap().to_owned(),
-        args: ~[~"-c",
+        args: vec!(~"-c",
                 ~"-emit-llvm",
                 ~"-o", bitcodefile.as_str().unwrap().to_owned(),
-                testcc.as_str().unwrap().to_owned() ]
+                testcc.as_str().unwrap().to_owned() )
     };
-    compose_and_run(config, testfile, proc_args, ~[], "", None)
+    compose_and_run(config, testfile, proc_args, Vec::new(), "", None)
 }
 
 fn extract_function_from_bitcode(config: &config, _props: &TestProps,
@@ -1115,11 +1141,11 @@ fn extract_function_from_bitcode(config: &config, _props: &TestProps,
     let proc_args = ProcArgs {
         // FIXME (#9639): This needs to handle non-utf8 paths
         prog: prog.as_str().unwrap().to_owned(),
-        args: ~["-func=" + fname,
+        args: vec!("-func=" + fname,
                 "-o=" + extracted_bc.as_str().unwrap(),
-                bitcodefile.as_str().unwrap().to_owned() ]
+                bitcodefile.as_str().unwrap().to_owned() )
     };
-    compose_and_run(config, testfile, proc_args, ~[], "", None)
+    compose_and_run(config, testfile, proc_args, Vec::new(), "", None)
 }
 
 fn disassemble_extract(config: &config, _props: &TestProps,
@@ -1132,10 +1158,10 @@ fn disassemble_extract(config: &config, _props: &TestProps,
     let proc_args = ProcArgs {
         // FIXME (#9639): This needs to handle non-utf8 paths
         prog: prog.as_str().unwrap().to_owned(),
-        args: ~["-o=" + extracted_ll.as_str().unwrap(),
-                extracted_bc.as_str().unwrap().to_owned() ]
+        args: vec!("-o=" + extracted_ll.as_str().unwrap(),
+                extracted_bc.as_str().unwrap().to_owned() )
     };
-    compose_and_run(config, testfile, proc_args, ~[], "", None)
+    compose_and_run(config, testfile, proc_args, Vec::new(), "", None)
 }
 
 
index dbebb8fb2bc680edd1ec61b4ac64a7b69a8967c0..a09d5a826bb99cbb630892f3d22ac62aed5c67be 100644 (file)
 use std::rt::global_heap;
 use std::intrinsics::{TyDesc, get_tydesc};
 use std::intrinsics;
-use std::slice;
 
 // The way arena uses arrays is really deeply awful. The arrays are
 // allocated, and have capacities reserved, but the fill for the array
 // will always stay at 0.
 #[deriving(Clone, Eq)]
 struct Chunk {
-    data: Rc<RefCell<~[u8]>>,
+    data: Rc<RefCell<Vec<u8> >>,
     fill: Cell<uint>,
     is_pod: Cell<bool>,
 }
@@ -111,7 +110,7 @@ pub fn new_with_size(initial_size: uint) -> Arena {
 
 fn chunk(size: uint, is_pod: bool) -> Chunk {
     Chunk {
-        data: Rc::new(RefCell::new(slice::with_capacity(size))),
+        data: Rc::new(RefCell::new(Vec::with_capacity(size))),
         fill: Cell::new(0u),
         is_pod: Cell::new(is_pod),
     }
@@ -489,6 +488,9 @@ fn drop(&mut self) {
 #[cfg(test)]
 mod tests {
     extern crate test;
+
+    use std::vec_ng::Vec;
+
     use self::test::BenchHarness;
     use super::{Arena, TypedArena};
 
@@ -549,7 +551,7 @@ pub fn bench_pod_old_arena(bh: &mut BenchHarness) {
 
     struct Nonpod {
         string: ~str,
-        array: ~[int],
+        array: Vec<int> ,
     }
 
     #[test]
@@ -558,7 +560,7 @@ pub fn test_nonpod() {
         for _ in range(0, 100000) {
             arena.alloc(Nonpod {
                 string: ~"hello world",
-                array: ~[ 1, 2, 3, 4, 5 ],
+                array: vec!( 1, 2, 3, 4, 5 ),
             });
         }
     }
@@ -569,7 +571,7 @@ pub fn bench_nonpod(bh: &mut BenchHarness) {
         bh.iter(|| {
             arena.alloc(Nonpod {
                 string: ~"hello world",
-                array: ~[ 1, 2, 3, 4, 5 ],
+                array: vec!( 1, 2, 3, 4, 5 ),
             })
         })
     }
@@ -579,7 +581,7 @@ pub fn bench_nonpod_nonarena(bh: &mut BenchHarness) {
         bh.iter(|| {
             ~Nonpod {
                 string: ~"hello world",
-                array: ~[ 1, 2, 3, 4, 5 ],
+                array: vec!( 1, 2, 3, 4, 5 ),
             }
         })
     }
@@ -590,7 +592,7 @@ pub fn bench_nonpod_old_arena(bh: &mut BenchHarness) {
         bh.iter(|| {
             arena.alloc(|| Nonpod {
                 string: ~"hello world",
-                array: ~[ 1, 2, 3, 4, 5 ],
+                array: vec!( 1, 2, 3, 4, 5 ),
             })
         })
     }
index d176f9740561d24a56b40ba210ccf69b18cb033c..6f30c7129eabba5ad9033a78ce8fd04163146641 100644 (file)
@@ -67,7 +67,7 @@
 //!     }
 //!     let output = matches.opt_str("o");
 //!     let input: &str = if !matches.free.is_empty() {
-//!         matches.free[0].clone()
+//!         (*matches.free.get(0)).clone()
 //!     } else {
 //!         print_usage(program, opts);
 //!         return;
@@ -92,8 +92,6 @@
 use std::cmp::Eq;
 use std::result::{Err, Ok};
 use std::result;
-use std::option::{Some, None};
-use std::slice;
 
 /// Name of an option. Either a string or a single char.
 #[deriving(Clone, Eq)]
@@ -138,7 +136,7 @@ pub struct Opt {
     /// How often it can occur
     occur: Occur,
     /// Which options it aliases
-    priv aliases: ~[Opt],
+    priv aliases: Vec<Opt> ,
 }
 
 /// One group of options, e.g., both -h and --help, along with
@@ -171,12 +169,11 @@ enum Optval {
 #[deriving(Clone, Eq)]
 pub struct Matches {
     /// Options that matched
-    priv opts: ~[Opt],
+    priv opts: Vec<Opt> ,
     /// Values of the Options that matched
-    priv vals: ~[~[Optval]],
+    priv vals: Vec<Vec<Optval> > ,
     /// Free string fragments
-    free: ~[~str]
-}
+    free: Vec<~str> }
 
 /// The type returned when the command line does not conform to the
 /// expected format. Call the `to_err_msg` method to retrieve the
@@ -244,26 +241,26 @@ pub fn long_to_short(&self) -> Opt {
                 name: Long((long_name)),
                 hasarg: hasarg,
                 occur: occur,
-                aliases: ~[]
+                aliases: Vec::new()
             },
             (1,0) => Opt {
                 name: Short(short_name.char_at(0)),
                 hasarg: hasarg,
                 occur: occur,
-                aliases: ~[]
+                aliases: Vec::new()
             },
             (1,_) => Opt {
                 name: Long((long_name)),
                 hasarg: hasarg,
                 occur:  occur,
-                aliases: ~[
+                aliases: vec!(
                     Opt {
                         name: Short(short_name.char_at(0)),
                         hasarg: hasarg,
                         occur:  occur,
-                        aliases: ~[]
+                        aliases: Vec::new()
                     }
-                ]
+                )
             },
             (_,_) => fail!("something is wrong with the long-form opt")
         }
@@ -271,9 +268,9 @@ pub fn long_to_short(&self) -> Opt {
 }
 
 impl Matches {
-    fn opt_vals(&self, nm: &str) -> ~[Optval] {
-        match find_opt(self.opts, Name::from_str(nm)) {
-            Some(id) => self.vals[id].clone(),
+    fn opt_vals(&self, nm: &str) -> Vec<Optval> {
+        match find_opt(self.opts.as_slice(), Name::from_str(nm)) {
+            Some(id) => (*self.vals.get(id)).clone(),
             None => fail!("No option '{}' defined", nm)
         }
     }
@@ -283,7 +280,7 @@ fn opt_val(&self, nm: &str) -> Option<Optval> {
         if vals.is_empty() {
             None
         } else {
-            Some(vals[0].clone())
+            Some((*vals.get(0)).clone())
         }
     }
 
@@ -300,8 +297,8 @@ pub fn opt_count(&self, nm: &str) -> uint {
     /// Returns true if any of several options were matched.
     pub fn opts_present(&self, names: &[~str]) -> bool {
         for nm in names.iter() {
-            match find_opt(self.opts, Name::from_str(*nm)) {
-                Some(id) if !self.vals[id].is_empty() => return true,
+            match find_opt(self.opts.as_slice(), Name::from_str(*nm)) {
+                Some(id) if !self.vals.get(id).is_empty() => return true,
                 _ => (),
             };
         }
@@ -323,8 +320,8 @@ pub fn opts_str(&self, names: &[~str]) -> Option<~str> {
     /// option.
     ///
     /// Used when an option accepts multiple values.
-    pub fn opt_strs(&self, nm: &str) -> ~[~str] {
-        let mut acc: ~[~str] = ~[];
+    pub fn opt_strs(&self, nm: &str) -> Vec<~str> {
+        let mut acc: Vec<~str> = Vec::new();
         let r = self.opt_vals(nm);
         for v in r.iter() {
             match *v {
@@ -341,8 +338,8 @@ pub fn opt_str(&self, nm: &str) -> Option<~str> {
         if vals.is_empty() {
             return None::<~str>;
         }
-        match vals[0] {
-            Val(ref s) => Some((*s).clone()),
+        match vals.get(0) {
+            &Val(ref s) => Some((*s).clone()),
             _ => None
         }
     }
@@ -356,8 +353,8 @@ pub fn opt_str(&self, nm: &str) -> Option<~str> {
     pub fn opt_default(&self, nm: &str, def: &str) -> Option<~str> {
         let vals = self.opt_vals(nm);
         if vals.is_empty() { return None; }
-        match vals[0] {
-            Val(ref s) => Some((*s).clone()),
+        match vals.get(0) {
+            &Val(ref s) => Some((*s).clone()),
             _ => Some(def.to_owned())
         }
     }
@@ -522,10 +519,10 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
     let opts = optgrps.map(|x| x.long_to_short());
     let n_opts = opts.len();
 
-    fn f(_x: uint) -> ~[Optval] { return ~[]; }
+    fn f(_x: uint) -> Vec<Optval> { return Vec::new(); }
 
-    let mut vals = slice::from_fn(n_opts, f);
-    let mut free: ~[~str] = ~[];
+    let mut vals = Vec::from_fn(n_opts, f);
+    let mut free: Vec<~str> = Vec::new();
     let l = args.len();
     let mut i = 0;
     while i < l {
@@ -542,18 +539,18 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
             let mut i_arg = None;
             if cur[1] == '-' as u8 {
                 let tail = cur.slice(2, curlen);
-                let tail_eq: ~[&str] = tail.split('=').collect();
+                let tail_eq: Vec<&str> = tail.split('=').collect();
                 if tail_eq.len() <= 1 {
-                    names = ~[Long(tail.to_owned())];
+                    names = vec!(Long(tail.to_owned()));
                 } else {
                     names =
-                        ~[Long(tail_eq[0].to_owned())];
-                    i_arg = Some(tail_eq[1].to_owned());
+                        vec!(Long((*tail_eq.get(0)).to_owned()));
+                    i_arg = Some((*tail_eq.get(1)).to_owned());
                 }
             } else {
                 let mut j = 1;
                 let mut last_valid_opt_id = None;
-                names = ~[];
+                names = Vec::new();
                 while j < curlen {
                     let range = cur.char_range_at(j);
                     let opt = Short(range.ch);
@@ -600,22 +597,30 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
                     if !i_arg.is_none() {
                         return Err(UnexpectedArgument(nm.to_str()));
                     }
-                    vals[optid].push(Given);
+                    vals.get_mut(optid).push(Given);
                   }
                   Maybe => {
                     if !i_arg.is_none() {
-                        vals[optid].push(Val((i_arg.clone()).unwrap()));
+                        vals.get_mut(optid)
+                            .push(Val((i_arg.clone())
+                            .unwrap()));
                     } else if name_pos < names.len() ||
                                   i + 1 == l || is_arg(args[i + 1]) {
-                        vals[optid].push(Given);
-                    } else { i += 1; vals[optid].push(Val(args[i].clone())); }
+                        vals.get_mut(optid).push(Given);
+                    } else {
+                        i += 1;
+                        vals.get_mut(optid).push(Val(args[i].clone()));
+                    }
                   }
                   Yes => {
                     if !i_arg.is_none() {
-                        vals[optid].push(Val(i_arg.clone().unwrap()));
+                        vals.get_mut(optid).push(Val(i_arg.clone().unwrap()));
                     } else if i + 1 == l {
                         return Err(ArgumentMissing(nm.to_str()));
-                    } else { i += 1; vals[optid].push(Val(args[i].clone())); }
+                    } else {
+                        i += 1;
+                        vals.get_mut(optid).push(Val(args[i].clone()));
+                    }
                   }
                 }
             }
@@ -624,7 +629,7 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
     }
     i = 0u;
     while i < n_opts {
-        let n = vals[i].len();
+        let n = vals.get(i).len();
         let occ = opts[i].occur;
         if occ == Req {
             if n == 0 {
@@ -639,7 +644,7 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
         i += 1;
     }
     Ok(Matches {
-        opts: opts.to_owned(),
+        opts: Vec::from_slice(opts),
         vals: vals,
         free: free
     })
@@ -711,7 +716,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str {
         }
 
         // FIXME: #5516 should be graphemes not codepoints
-        let mut desc_rows = ~[];
+        let mut desc_rows = Vec::new();
         each_split_within(desc_normalized_whitespace, 54, |substr| {
             desc_rows.push(substr.to_owned());
             true
@@ -724,7 +729,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str {
         row
     });
 
-    format!("{}\n\nOptions:\n{}\n", brief, rows.collect::<~[~str]>().connect("\n"))
+    format!("{}\n\nOptions:\n{}\n", brief, rows.collect::<Vec<~str> >().connect("\n"))
 }
 
 fn format_option(opt: &OptGroup) -> ~str {
@@ -879,7 +884,7 @@ enum LengthLimit {
 #[test]
 fn test_split_within() {
     fn t(s: &str, i: uint, u: &[~str]) {
-        let mut v = ~[];
+        let mut v = Vec::new();
         each_split_within(s, i, |s| { v.push(s.to_owned()); true });
         assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b));
     }
@@ -898,6 +903,7 @@ mod tests {
 
     use std::result::{Err, Ok};
     use std::result;
+    use std::vec_ng::Vec;
 
     fn check_fail_type(f: Fail_, ft: FailType) {
         match f {
@@ -912,9 +918,9 @@ fn check_fail_type(f: Fail_, ft: FailType) {
     // Tests for reqopt
     #[test]
     fn test_reqopt() {
-        let long_args = ~[~"--test=20"];
-        let opts = ~[reqopt("t", "test", "testing", "TEST")];
-        let rs = getopts(long_args, opts);
+        let long_args = vec!(~"--test=20");
+        let opts = vec!(reqopt("t", "test", "testing", "TEST"));
+        let rs = getopts(long_args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert!(m.opt_present("test"));
@@ -924,8 +930,8 @@ fn test_reqopt() {
           }
           _ => { fail!("test_reqopt failed (long arg)"); }
         }
-        let short_args = ~[~"-t", ~"20"];
-        match getopts(short_args, opts) {
+        let short_args = vec!(~"-t", ~"20");
+        match getopts(short_args.as_slice(), opts.as_slice()) {
           Ok(ref m) => {
             assert!((m.opt_present("test")));
             assert_eq!(m.opt_str("test").unwrap(), ~"20");
@@ -938,9 +944,9 @@ fn test_reqopt() {
 
     #[test]
     fn test_reqopt_missing() {
-        let args = ~[~"blah"];
-        let opts = ~[reqopt("t", "test", "testing", "TEST")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"blah");
+        let opts = vec!(reqopt("t", "test", "testing", "TEST"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => check_fail_type(f, OptionMissing_),
           _ => fail!()
@@ -949,15 +955,15 @@ fn test_reqopt_missing() {
 
     #[test]
     fn test_reqopt_no_arg() {
-        let long_args = ~[~"--test"];
-        let opts = ~[reqopt("t", "test", "testing", "TEST")];
-        let rs = getopts(long_args, opts);
+        let long_args = vec!(~"--test");
+        let opts = vec!(reqopt("t", "test", "testing", "TEST"));
+        let rs = getopts(long_args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => check_fail_type(f, ArgumentMissing_),
           _ => fail!()
         }
-        let short_args = ~[~"-t"];
-        match getopts(short_args, opts) {
+        let short_args = vec!(~"-t");
+        match getopts(short_args.as_slice(), opts.as_slice()) {
           Err(f) => check_fail_type(f, ArgumentMissing_),
           _ => fail!()
         }
@@ -965,9 +971,9 @@ fn test_reqopt_no_arg() {
 
     #[test]
     fn test_reqopt_multi() {
-        let args = ~[~"--test=20", ~"-t", ~"30"];
-        let opts = ~[reqopt("t", "test", "testing", "TEST")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"--test=20", ~"-t", ~"30");
+        let opts = vec!(reqopt("t", "test", "testing", "TEST"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => check_fail_type(f, OptionDuplicated_),
           _ => fail!()
@@ -977,9 +983,9 @@ fn test_reqopt_multi() {
     // Tests for optopt
     #[test]
     fn test_optopt() {
-        let long_args = ~[~"--test=20"];
-        let opts = ~[optopt("t", "test", "testing", "TEST")];
-        let rs = getopts(long_args, opts);
+        let long_args = vec!(~"--test=20");
+        let opts = vec!(optopt("t", "test", "testing", "TEST"));
+        let rs = getopts(long_args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert!(m.opt_present("test"));
@@ -989,8 +995,8 @@ fn test_optopt() {
           }
           _ => fail!()
         }
-        let short_args = ~[~"-t", ~"20"];
-        match getopts(short_args, opts) {
+        let short_args = vec!(~"-t", ~"20");
+        match getopts(short_args.as_slice(), opts.as_slice()) {
           Ok(ref m) => {
             assert!((m.opt_present("test")));
             assert_eq!(m.opt_str("test").unwrap(), ~"20");
@@ -1003,9 +1009,9 @@ fn test_optopt() {
 
     #[test]
     fn test_optopt_missing() {
-        let args = ~[~"blah"];
-        let opts = ~[optopt("t", "test", "testing", "TEST")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"blah");
+        let opts = vec!(optopt("t", "test", "testing", "TEST"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert!(!m.opt_present("test"));
@@ -1017,15 +1023,15 @@ fn test_optopt_missing() {
 
     #[test]
     fn test_optopt_no_arg() {
-        let long_args = ~[~"--test"];
-        let opts = ~[optopt("t", "test", "testing", "TEST")];
-        let rs = getopts(long_args, opts);
+        let long_args = vec!(~"--test");
+        let opts = vec!(optopt("t", "test", "testing", "TEST"));
+        let rs = getopts(long_args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => check_fail_type(f, ArgumentMissing_),
           _ => fail!()
         }
-        let short_args = ~[~"-t"];
-        match getopts(short_args, opts) {
+        let short_args = vec!(~"-t");
+        match getopts(short_args.as_slice(), opts.as_slice()) {
           Err(f) => check_fail_type(f, ArgumentMissing_),
           _ => fail!()
         }
@@ -1033,9 +1039,9 @@ fn test_optopt_no_arg() {
 
     #[test]
     fn test_optopt_multi() {
-        let args = ~[~"--test=20", ~"-t", ~"30"];
-        let opts = ~[optopt("t", "test", "testing", "TEST")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"--test=20", ~"-t", ~"30");
+        let opts = vec!(optopt("t", "test", "testing", "TEST"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => check_fail_type(f, OptionDuplicated_),
           _ => fail!()
@@ -1045,9 +1051,9 @@ fn test_optopt_multi() {
     // Tests for optflag
     #[test]
     fn test_optflag() {
-        let long_args = ~[~"--test"];
-        let opts = ~[optflag("t", "test", "testing")];
-        let rs = getopts(long_args, opts);
+        let long_args = vec!(~"--test");
+        let opts = vec!(optflag("t", "test", "testing"));
+        let rs = getopts(long_args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert!(m.opt_present("test"));
@@ -1055,8 +1061,8 @@ fn test_optflag() {
           }
           _ => fail!()
         }
-        let short_args = ~[~"-t"];
-        match getopts(short_args, opts) {
+        let short_args = vec!(~"-t");
+        match getopts(short_args.as_slice(), opts.as_slice()) {
           Ok(ref m) => {
             assert!(m.opt_present("test"));
             assert!(m.opt_present("t"));
@@ -1067,9 +1073,9 @@ fn test_optflag() {
 
     #[test]
     fn test_optflag_missing() {
-        let args = ~[~"blah"];
-        let opts = ~[optflag("t", "test", "testing")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"blah");
+        let opts = vec!(optflag("t", "test", "testing"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert!(!m.opt_present("test"));
@@ -1081,9 +1087,9 @@ fn test_optflag_missing() {
 
     #[test]
     fn test_optflag_long_arg() {
-        let args = ~[~"--test=20"];
-        let opts = ~[optflag("t", "test", "testing")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"--test=20");
+        let opts = vec!(optflag("t", "test", "testing"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => {
             error!("{:?}", f.clone().to_err_msg());
@@ -1095,9 +1101,9 @@ fn test_optflag_long_arg() {
 
     #[test]
     fn test_optflag_multi() {
-        let args = ~[~"--test", ~"-t"];
-        let opts = ~[optflag("t", "test", "testing")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"--test", ~"-t");
+        let opts = vec!(optflag("t", "test", "testing"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => check_fail_type(f, OptionDuplicated_),
           _ => fail!()
@@ -1106,14 +1112,14 @@ fn test_optflag_multi() {
 
     #[test]
     fn test_optflag_short_arg() {
-        let args = ~[~"-t", ~"20"];
-        let opts = ~[optflag("t", "test", "testing")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"-t", ~"20");
+        let opts = vec!(optflag("t", "test", "testing"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             // The next variable after the flag is just a free argument
 
-            assert!(m.free[0] == ~"20");
+            assert!(*m.free.get(0) == ~"20");
           }
           _ => fail!()
         }
@@ -1122,9 +1128,9 @@ fn test_optflag_short_arg() {
     // Tests for optflagmulti
     #[test]
     fn test_optflagmulti_short1() {
-        let args = ~[~"-v"];
-        let opts = ~[optflagmulti("v", "verbose", "verbosity")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"-v");
+        let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("v"), 1);
@@ -1135,9 +1141,9 @@ fn test_optflagmulti_short1() {
 
     #[test]
     fn test_optflagmulti_short2a() {
-        let args = ~[~"-v", ~"-v"];
-        let opts = ~[optflagmulti("v", "verbose", "verbosity")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"-v", ~"-v");
+        let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("v"), 2);
@@ -1148,9 +1154,9 @@ fn test_optflagmulti_short2a() {
 
     #[test]
     fn test_optflagmulti_short2b() {
-        let args = ~[~"-vv"];
-        let opts = ~[optflagmulti("v", "verbose", "verbosity")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"-vv");
+        let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("v"), 2);
@@ -1161,9 +1167,9 @@ fn test_optflagmulti_short2b() {
 
     #[test]
     fn test_optflagmulti_long1() {
-        let args = ~[~"--verbose"];
-        let opts = ~[optflagmulti("v", "verbose", "verbosity")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"--verbose");
+        let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("verbose"), 1);
@@ -1174,9 +1180,9 @@ fn test_optflagmulti_long1() {
 
     #[test]
     fn test_optflagmulti_long2() {
-        let args = ~[~"--verbose", ~"--verbose"];
-        let opts = ~[optflagmulti("v", "verbose", "verbosity")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"--verbose", ~"--verbose");
+        let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("verbose"), 2);
@@ -1187,9 +1193,9 @@ fn test_optflagmulti_long2() {
 
     #[test]
     fn test_optflagmulti_mix() {
-        let args = ~[~"--verbose", ~"-v", ~"-vv", ~"verbose"];
-        let opts = ~[optflagmulti("v", "verbose", "verbosity")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"--verbose", ~"-v", ~"-vv", ~"verbose");
+        let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("verbose"), 4);
@@ -1202,9 +1208,9 @@ fn test_optflagmulti_mix() {
     // Tests for optmulti
     #[test]
     fn test_optmulti() {
-        let long_args = ~[~"--test=20"];
-        let opts = ~[optmulti("t", "test", "testing", "TEST")];
-        let rs = getopts(long_args, opts);
+        let long_args = vec!(~"--test=20");
+        let opts = vec!(optmulti("t", "test", "testing", "TEST"));
+        let rs = getopts(long_args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert!((m.opt_present("test")));
@@ -1214,8 +1220,8 @@ fn test_optmulti() {
           }
           _ => fail!()
         }
-        let short_args = ~[~"-t", ~"20"];
-        match getopts(short_args, opts) {
+        let short_args = vec!(~"-t", ~"20");
+        match getopts(short_args.as_slice(), opts.as_slice()) {
           Ok(ref m) => {
             assert!((m.opt_present("test")));
             assert_eq!(m.opt_str("test").unwrap(), ~"20");
@@ -1228,9 +1234,9 @@ fn test_optmulti() {
 
     #[test]
     fn test_optmulti_missing() {
-        let args = ~[~"blah"];
-        let opts = ~[optmulti("t", "test", "testing", "TEST")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"blah");
+        let opts = vec!(optmulti("t", "test", "testing", "TEST"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
             assert!(!m.opt_present("test"));
@@ -1242,15 +1248,15 @@ fn test_optmulti_missing() {
 
     #[test]
     fn test_optmulti_no_arg() {
-        let long_args = ~[~"--test"];
-        let opts = ~[optmulti("t", "test", "testing", "TEST")];
-        let rs = getopts(long_args, opts);
+        let long_args = vec!(~"--test");
+        let opts = vec!(optmulti("t", "test", "testing", "TEST"));
+        let rs = getopts(long_args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => check_fail_type(f, ArgumentMissing_),
           _ => fail!()
         }
-        let short_args = ~[~"-t"];
-        match getopts(short_args, opts) {
+        let short_args = vec!(~"-t");
+        match getopts(short_args.as_slice(), opts.as_slice()) {
           Err(f) => check_fail_type(f, ArgumentMissing_),
           _ => fail!()
         }
@@ -1258,9 +1264,9 @@ fn test_optmulti_no_arg() {
 
     #[test]
     fn test_optmulti_multi() {
-        let args = ~[~"--test=20", ~"-t", ~"30"];
-        let opts = ~[optmulti("t", "test", "testing", "TEST")];
-        let rs = getopts(args, opts);
+        let args = vec!(~"--test=20", ~"-t", ~"30");
+        let opts = vec!(optmulti("t", "test", "testing", "TEST"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
               assert!(m.opt_present("test"));
@@ -1268,8 +1274,8 @@ fn test_optmulti_multi() {
               assert!(m.opt_present("t"));
               assert_eq!(m.opt_str("t").unwrap(), ~"20");
               let pair = m.opt_strs("test");
-              assert!(pair[0] == ~"20");
-              assert!(pair[1] == ~"30");
+              assert!(*pair.get(0) == ~"20");
+              assert!(*pair.get(1) == ~"30");
           }
           _ => fail!()
         }
@@ -1277,15 +1283,15 @@ fn test_optmulti_multi() {
 
     #[test]
     fn test_unrecognized_option() {
-        let long_args = ~[~"--untest"];
-        let opts = ~[optmulti("t", "test", "testing", "TEST")];
-        let rs = getopts(long_args, opts);
+        let long_args = vec!(~"--untest");
+        let opts = vec!(optmulti("t", "test", "testing", "TEST"));
+        let rs = getopts(long_args.as_slice(), opts.as_slice());
         match rs {
           Err(f) => check_fail_type(f, UnrecognizedOption_),
           _ => fail!()
         }
-        let short_args = ~[~"-u"];
-        match getopts(short_args, opts) {
+        let short_args = vec!(~"-u");
+        match getopts(short_args.as_slice(), opts.as_slice()) {
           Err(f) => check_fail_type(f, UnrecognizedOption_),
           _ => fail!()
         }
@@ -1294,33 +1300,33 @@ fn test_unrecognized_option() {
     #[test]
     fn test_combined() {
         let args =
-            ~[~"prog", ~"free1", ~"-s", ~"20", ~"free2",
+            vec!(~"prog", ~"free1", ~"-s", ~"20", ~"free2",
               ~"--flag", ~"--long=30", ~"-f", ~"-m", ~"40",
-              ~"-m", ~"50", ~"-n", ~"-A B", ~"-n", ~"-60 70"];
+              ~"-m", ~"50", ~"-n", ~"-A B", ~"-n", ~"-60 70");
         let opts =
-            ~[optopt("s", "something", "something", "SOMETHING"),
+            vec!(optopt("s", "something", "something", "SOMETHING"),
               optflag("", "flag", "a flag"),
               reqopt("", "long", "hi", "LONG"),
               optflag("f", "", "another flag"),
               optmulti("m", "", "mmmmmm", "YUM"),
               optmulti("n", "", "nothing", "NOTHING"),
-              optopt("", "notpresent", "nothing to see here", "NOPE")];
-        let rs = getopts(args, opts);
+              optopt("", "notpresent", "nothing to see here", "NOPE"));
+        let rs = getopts(args.as_slice(), opts.as_slice());
         match rs {
           Ok(ref m) => {
-            assert!(m.free[0] == ~"prog");
-            assert!(m.free[1] == ~"free1");
+            assert!(*m.free.get(0) == ~"prog");
+            assert!(*m.free.get(1) == ~"free1");
             assert_eq!(m.opt_str("s").unwrap(), ~"20");
-            assert!(m.free[2] == ~"free2");
+            assert!(*m.free.get(2) == ~"free2");
             assert!((m.opt_present("flag")));
             assert_eq!(m.opt_str("long").unwrap(), ~"30");
             assert!((m.opt_present("f")));
             let pair = m.opt_strs("m");
-            assert!(pair[0] == ~"40");
-            assert!(pair[1] == ~"50");
+            assert!(*pair.get(0) == ~"40");
+            assert!(*pair.get(1) == ~"50");
             let pair = m.opt_strs("n");
-            assert!(pair[0] == ~"-A B");
-            assert!(pair[1] == ~"-60 70");
+            assert!(*pair.get(0) == ~"-A B");
+            assert!(*pair.get(1) == ~"-60 70");
             assert!((!m.opt_present("notpresent")));
           }
           _ => fail!()
@@ -1329,12 +1335,13 @@ fn test_combined() {
 
     #[test]
     fn test_multi() {
-        let opts = ~[optopt("e", "", "encrypt", "ENCRYPT"),
+        let opts = vec!(optopt("e", "", "encrypt", "ENCRYPT"),
                      optopt("", "encrypt", "encrypt", "ENCRYPT"),
-                     optopt("f", "", "flag", "FLAG")];
+                     optopt("f", "", "flag", "FLAG"));
 
-        let args_single = ~[~"-e", ~"foo"];
-        let matches_single = &match getopts(args_single, opts) {
+        let args_single = vec!(~"-e", ~"foo");
+        let matches_single = &match getopts(args_single.as_slice(),
+                                            opts.as_slice()) {
           result::Ok(m) => m,
           result::Err(_) => fail!()
         };
@@ -1349,8 +1356,9 @@ fn test_multi() {
         assert_eq!(matches_single.opts_str([~"e", ~"encrypt"]).unwrap(), ~"foo");
         assert_eq!(matches_single.opts_str([~"encrypt", ~"e"]).unwrap(), ~"foo");
 
-        let args_both = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
-        let matches_both = &match getopts(args_both, opts) {
+        let args_both = vec!(~"-e", ~"foo", ~"--encrypt", ~"foo");
+        let matches_both = &match getopts(args_both.as_slice(),
+                                          opts.as_slice()) {
           result::Ok(m) => m,
           result::Err(_) => fail!()
         };
@@ -1370,10 +1378,10 @@ fn test_multi() {
 
     #[test]
     fn test_nospace() {
-        let args = ~[~"-Lfoo", ~"-M."];
-        let opts = ~[optmulti("L", "", "library directory", "LIB"),
-                     optmulti("M", "", "something", "MMMM")];
-        let matches = &match getopts(args, opts) {
+        let args = vec!(~"-Lfoo", ~"-M.");
+        let opts = vec!(optmulti("L", "", "library directory", "LIB"),
+                     optmulti("M", "", "something", "MMMM"));
+        let matches = &match getopts(args.as_slice(), opts.as_slice()) {
           result::Ok(m) => m,
           result::Err(_) => fail!()
         };
@@ -1386,14 +1394,16 @@ fn test_nospace() {
 
     #[test]
     fn test_long_to_short() {
-        let mut short = Opt { name: Long(~"banana"),
-                              hasarg: Yes,
-                              occur: Req,
-                              aliases: ~[] };
-        short.aliases = ~[Opt { name: Short('b'),
+        let mut short = Opt {
+            name: Long(~"banana"),
+            hasarg: Yes,
+            occur: Req,
+            aliases: Vec::new(),
+        };
+        short.aliases = vec!(Opt { name: Short('b'),
                                 hasarg: Yes,
                                 occur: Req,
-                                aliases: ~[] }];
+                                aliases: Vec::new() });
         let verbose = reqopt("b", "banana", "some bananas", "VAL");
 
         assert!(verbose.long_to_short() == short);
@@ -1401,27 +1411,25 @@ fn test_long_to_short() {
 
     #[test]
     fn test_aliases_long_and_short() {
-        let opts = ~[
-            optflagmulti("a", "apple", "Desc"),
-        ];
+        let opts = vec!(
+            optflagmulti("a", "apple", "Desc"));
 
-        let args = ~[~"-a", ~"--apple", ~"-a"];
+        let args = vec!(~"-a", ~"--apple", ~"-a");
 
-        let matches = getopts(args, opts).unwrap();
+        let matches = getopts(args.as_slice(), opts.as_slice()).unwrap();
         assert_eq!(3, matches.opt_count("a"));
         assert_eq!(3, matches.opt_count("apple"));
     }
 
     #[test]
     fn test_usage() {
-        let optgroups = ~[
+        let optgroups = vec!(
             reqopt("b", "banana", "Desc", "VAL"),
             optopt("a", "012345678901234567890123456789",
                              "Desc", "VAL"),
             optflag("k", "kiwi", "Desc"),
             optflagopt("p", "", "Desc", "VAL"),
-            optmulti("l", "", "Desc", "VAL"),
-        ];
+            optmulti("l", "", "Desc", "VAL"));
 
         let expected =
 ~"Usage: fruits
@@ -1435,7 +1443,7 @@ fn test_usage() {
     -l VAL              Desc
 ";
 
-        let generated_usage = usage("Usage: fruits", optgroups);
+        let generated_usage = usage("Usage: fruits", optgroups.as_slice());
 
         debug!("expected: <<{}>>", expected);
         debug!("generated: <<{}>>", generated_usage);
@@ -1447,12 +1455,11 @@ fn test_usage_description_wrapping() {
         // indentation should be 24 spaces
         // lines wrap after 78: or rather descriptions wrap after 54
 
-        let optgroups = ~[
+        let optgroups = vec!(
             optflag("k", "kiwi",
                 "This is a long description which won't be wrapped..+.."), // 54
             optflag("a", "apple",
-                "This is a long description which _will_ be wrapped..+.."), // 55
-        ];
+                "This is a long description which _will_ be wrapped..+.."));
 
         let expected =
 ~"Usage: fruits
@@ -1463,7 +1470,7 @@ fn test_usage_description_wrapping() {
                         wrapped..+..
 ";
 
-        let usage = usage("Usage: fruits", optgroups);
+        let usage = usage("Usage: fruits", optgroups.as_slice());
 
         debug!("expected: <<{}>>", expected);
         debug!("generated: <<{}>>", usage);
@@ -1472,13 +1479,12 @@ fn test_usage_description_wrapping() {
 
     #[test]
     fn test_usage_description_multibyte_handling() {
-        let optgroups = ~[
+        let optgroups = vec!(
             optflag("k", "k\u2013w\u2013",
                 "The word kiwi is normally spelled with two i's"),
             optflag("a", "apple",
                 "This \u201Cdescription\u201D has some characters that could \
-confuse the line wrapping; an apple costs 0.51€ in some parts of Europe."),
-        ];
+confuse the line wrapping; an apple costs 0.51€ in some parts of Europe."));
 
         let expected =
 ~"Usage: fruits
@@ -1490,7 +1496,7 @@ fn test_usage_description_multibyte_handling() {
                         some parts of Europe.
 ";
 
-        let usage = usage("Usage: fruits", optgroups);
+        let usage = usage("Usage: fruits", optgroups.as_slice());
 
         debug!("expected: <<{}>>", expected);
         debug!("generated: <<{}>>", usage);
@@ -1499,17 +1505,16 @@ fn test_usage_description_multibyte_handling() {
 
     #[test]
     fn test_short_usage() {
-        let optgroups = ~[
+        let optgroups = vec!(
             reqopt("b", "banana", "Desc", "VAL"),
             optopt("a", "012345678901234567890123456789",
                      "Desc", "VAL"),
             optflag("k", "kiwi", "Desc"),
             optflagopt("p", "", "Desc", "VAL"),
-            optmulti("l", "", "Desc", "VAL"),
-        ];
+            optmulti("l", "", "Desc", "VAL"));
 
         let expected = ~"Usage: fruits -b VAL [-a VAL] [-k] [-p [VAL]] [-l VAL]..";
-        let generated_usage = short_usage("fruits", optgroups);
+        let generated_usage = short_usage("fruits", optgroups.as_slice());
 
         debug!("expected: <<{}>>", expected);
         debug!("generated: <<{}>>", generated_usage);
index c5af3309e2146da1eceb7d1c8b983dc970a81e7f..f4591c9fc1977ca7a7e3b30384b386ea05e8fa6a 100644 (file)
  */
 pub struct Paths {
     priv root: Path,
-    priv dir_patterns: ~[Pattern],
+    priv dir_patterns: Vec<Pattern> ,
     priv options: MatchOptions,
-    priv todo: ~[(Path,uint)]
-}
+    priv todo: Vec<(Path,uint)> }
 
 ///
 /// Return an iterator that produces all the Paths that match the given pattern,
@@ -103,16 +102,23 @@ fn check_windows_verbatim(_: &Path) -> bool { false }
         if check_windows_verbatim(pat_root.get_ref()) {
             // FIXME: How do we want to handle verbatim paths? I'm inclined to return nothing,
             // since we can't very well find all UNC shares with a 1-letter server name.
-            return Paths { root: root, dir_patterns: ~[], options: options, todo: ~[] };
+            return Paths {
+                root: root,
+                dir_patterns: Vec::new(),
+                options: options,
+                todo: Vec::new(),
+            };
         }
         root.push(pat_root.get_ref());
     }
 
     let root_len = pat_root.map_or(0u, |p| p.as_vec().len());
     let dir_patterns = pattern.slice_from(cmp::min(root_len, pattern.len()))
-                       .split_terminator(is_sep).map(|s| Pattern::new(s)).to_owned_vec();
+                       .split_terminator(is_sep)
+                       .map(|s| Pattern::new(s))
+                       .collect();
 
-    let todo = list_dir_sorted(&root).move_iter().map(|x|(x,0u)).to_owned_vec();
+    let todo = list_dir_sorted(&root).move_iter().map(|x|(x,0u)).collect();
 
     Paths {
         root: root,
@@ -131,7 +137,7 @@ fn next(&mut self) -> Option<Path> {
             }
 
             let (path,idx) = self.todo.pop().unwrap();
-            let ref pattern = self.dir_patterns[idx];
+            let ref pattern = *self.dir_patterns.get(idx);
 
             if pattern.matches_with(match path.filename_str() {
                 // this ugly match needs to go here to avoid a borrowck error
@@ -155,13 +161,13 @@ fn next(&mut self) -> Option<Path> {
 
 }
 
-fn list_dir_sorted(path: &Path) -> ~[Path] {
+fn list_dir_sorted(path: &Path) -> Vec<Path> {
     match fs::readdir(path) {
         Ok(mut children) => {
             children.sort_by(|p1, p2| p2.filename().cmp(&p1.filename()));
-            children
+            children.move_iter().collect()
         }
-        Err(..) => ~[]
+        Err(..) => Vec::new()
     }
 }
 
@@ -170,16 +176,15 @@ fn list_dir_sorted(path: &Path) -> ~[Path] {
  */
 #[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, Hash, Default)]
 pub struct Pattern {
-    priv tokens: ~[PatternToken]
-}
+    priv tokens: Vec<PatternToken> }
 
 #[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, Hash)]
 enum PatternToken {
     Char(char),
     AnyChar,
     AnySequence,
-    AnyWithin(~[CharSpecifier]),
-    AnyExcept(~[CharSpecifier])
+    AnyWithin(Vec<CharSpecifier> ),
+    AnyExcept(Vec<CharSpecifier> )
 }
 
 #[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, Hash)]
@@ -219,7 +224,7 @@ impl Pattern {
     pub fn new(pattern: &str) -> Pattern {
 
         let chars = pattern.chars().to_owned_vec();
-        let mut tokens = ~[];
+        let mut tokens = Vec::new();
         let mut i = 0;
 
         while i < chars.len() {
@@ -392,10 +397,16 @@ fn matches_from(&self,
                             !require_literal(c)
                         }
                         AnyWithin(ref specifiers) => {
-                            !require_literal(c) && in_char_specifiers(*specifiers, c, options)
+                            !require_literal(c) &&
+                                in_char_specifiers(specifiers.as_slice(),
+                                                   c,
+                                                   options)
                         }
                         AnyExcept(ref specifiers) => {
-                            !require_literal(c) && !in_char_specifiers(*specifiers, c, options)
+                            !require_literal(c) &&
+                                !in_char_specifiers(specifiers.as_slice(),
+                                                    c,
+                                                    options)
                         }
                         Char(c2) => {
                             chars_eq(c, c2, options.case_sensitive)
@@ -422,8 +433,8 @@ fn matches_from(&self,
 
 }
 
-fn parse_char_specifiers(s: &[char]) -> ~[CharSpecifier] {
-    let mut cs = ~[];
+fn parse_char_specifiers(s: &[char]) -> Vec<CharSpecifier> {
+    let mut cs = Vec::new();
     let mut i = 0;
     while i < s.len() {
         if i + 3 <= s.len() && s[i + 1] == '-' {
index afd4fa73ef6d848278e35b15d91aac8d3d06cd57..a71674c4122816c934520d7ea4070ea9ea4f914b 100644 (file)
@@ -299,9 +299,9 @@ fn from_str(s: &str) -> Option<Ratio<T>> {
         if split.len() < 2 {
             return None
         }
-        let a_option: Option<T> = FromStr::from_str(split.as_slice()[0]);
+        let a_option: Option<T> = FromStr::from_str(*split.get(0));
         a_option.and_then(|a| {
-            let b_option: Option<T> = FromStr::from_str(split.as_slice()[1]);
+            let b_option: Option<T> = FromStr::from_str(*split.get(1));
             b_option.and_then(|b| {
                 Some(Ratio::new(a.clone(), b.clone()))
             })
@@ -316,11 +316,12 @@ fn from_str_radix(s: &str, radix: uint) -> Option<Ratio<T>> {
         if split.len() < 2 {
             None
         } else {
-            let a_option: Option<T> = FromStrRadix::from_str_radix(split.as_slice()[0],
-                                                                   radix);
+            let a_option: Option<T> = FromStrRadix::from_str_radix(
+                *split.get(0),
+                radix);
             a_option.and_then(|a| {
                 let b_option: Option<T> =
-                    FromStrRadix::from_str_radix(split.as_slice()[1], radix);
+                    FromStrRadix::from_str_radix(*split.get(1), radix);
                 b_option.and_then(|b| {
                     Some(Ratio::new(a.clone(), b.clone()))
                 })
index ae9cd37fe69286f21abf4b1ec4022bde323b0f64..fd8b274509aef1b27edd60f94f3b3cd2ac664882 100644 (file)
@@ -837,7 +837,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> session::Options {
         let flags = vec::append(matches.opt_strs(level_short)
                                           .move_iter()
                                           .collect(),
-                                   matches.opt_strs(level_name));
+                                   matches.opt_strs(level_name).as_slice());
         for lint_name in flags.iter() {
             let lint_name = lint_name.replace("-", "_");
             match lint_dict.find_equiv(&lint_name) {
index 57ef81b1bc57cf15a6631518abb1a23f18d0c565..b3e40bd71f367327a23b6d9fb1a9ddc94139abae 100644 (file)
@@ -243,7 +243,7 @@ pub fn run_compiler(args: &[~str]) {
     let lint_flags = vec::append(matches.opt_strs("W")
                                            .move_iter()
                                            .collect(),
-                                    matches.opt_strs("warn"));
+                                    matches.opt_strs("warn").as_slice());
     if lint_flags.iter().any(|x| x == &~"help") {
         describe_warnings();
         return;
@@ -273,7 +273,7 @@ pub fn run_compiler(args: &[~str]) {
     let (input, input_file_path) = match matches.free.len() {
       0u => d::early_error("no input filename given"),
       1u => {
-        let ifile = matches.free[0].as_slice();
+        let ifile = matches.free.get(0).as_slice();
         if ifile == "-" {
             let contents = io::stdin().read_to_end().unwrap();
             let src = str::from_utf8_owned(contents).unwrap();
index 57b381d915af0b82ed5c05edb43987b3b00d896c..c18349d8d5aa4a19d2cd9e6cb53790be227d0bb3 100644 (file)
@@ -35,12 +35,6 @@ pub trait Clean<T> {
     fn clean(&self) -> T;
 }
 
-impl<T: Clean<U>, U> Clean<~[U]> for ~[T] {
-    fn clean(&self) -> ~[U] {
-        self.iter().map(|x| x.clean()).collect()
-    }
-}
-
 impl<T: Clean<U>, U> Clean<Vec<U>> for Vec<T> {
     fn clean(&self) -> Vec<U> {
         self.iter().map(|x| x.clean()).collect()
@@ -75,7 +69,7 @@ fn clean(&self) -> Vec<U> {
 pub struct Crate {
     name: ~str,
     module: Option<Item>,
-    externs: ~[(ast::CrateNum, ExternalCrate)],
+    externs: Vec<(ast::CrateNum, ExternalCrate)> ,
 }
 
 impl<'a> Clean<Crate> for visit_ast::RustdocVisitor<'a> {
@@ -83,13 +77,13 @@ fn clean(&self) -> Crate {
         use syntax::attr::find_crateid;
         let cx = local_data::get(super::ctxtkey, |x| *x.unwrap());
 
-        let mut externs = ~[];
+        let mut externs = Vec::new();
         cx.sess().cstore.iter_crate_data(|n, meta| {
             externs.push((n, meta.clean()));
         });
 
         Crate {
-            name: match find_crateid(self.attrs) {
+            name: match find_crateid(self.attrs.as_slice()) {
                 Some(n) => n.name,
                 None => fail!("rustdoc requires a `crate_id` crate attribute"),
             },
@@ -102,7 +96,7 @@ fn clean(&self) -> Crate {
 #[deriving(Clone, Encodable, Decodable)]
 pub struct ExternalCrate {
     name: ~str,
-    attrs: ~[Attribute],
+    attrs: Vec<Attribute> ,
 }
 
 impl Clean<ExternalCrate> for cstore::crate_metadata {
@@ -125,7 +119,7 @@ pub struct Item {
     source: Span,
     /// Not everything has a name. E.g., impls
     name: Option<~str>,
-    attrs: ~[Attribute],
+    attrs: Vec<Attribute> ,
     inner: ItemEnum,
     visibility: Option<Visibility>,
     id: ast::NodeId,
@@ -195,7 +189,7 @@ pub enum ItemEnum {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Module {
-    items: ~[Item],
+    items: Vec<Item> ,
     is_crate: bool,
 }
 
@@ -206,13 +200,13 @@ fn clean(&self) -> Item {
         } else {
             ~""
         };
-        let mut foreigns = ~[];
+        let mut foreigns = Vec::new();
         for subforeigns in self.foreigns.clean().move_iter() {
             for foreign in subforeigns.move_iter() {
                 foreigns.push(foreign)
             }
         }
-        let items: ~[~[Item]] = ~[
+        let items: Vec<Vec<Item> > = vec!(
             self.structs.clean().move_iter().collect(),
             self.enums.clean().move_iter().collect(),
             self.fns.clean().move_iter().collect(),
@@ -224,7 +218,7 @@ fn clean(&self) -> Item {
             self.impls.clean().move_iter().collect(),
             self.view_items.clean().move_iter().collect(),
             self.macros.clean().move_iter().collect()
-        ];
+        );
         Item {
             name: Some(name),
             attrs: self.attrs.clean(),
@@ -233,7 +227,9 @@ fn clean(&self) -> Item {
             id: self.id,
             inner: ModuleItem(Module {
                is_crate: self.is_crate,
-               items: items.concat_vec(),
+               items: items.iter()
+                           .flat_map(|x| x.iter().map(|x| (*x).clone()))
+                           .collect(),
             })
         }
     }
@@ -242,7 +238,7 @@ fn clean(&self) -> Item {
 #[deriving(Clone, Encodable, Decodable)]
 pub enum Attribute {
     Word(~str),
-    List(~str, ~[Attribute]),
+    List(~str, Vec<Attribute> ),
     NameValue(~str, ~str)
 }
 
@@ -292,8 +288,7 @@ fn name_str_pair(&self) -> Option<(InternedString, InternedString)> {
 pub struct TyParam {
     name: ~str,
     id: ast::NodeId,
-    bounds: ~[TyParamBound]
-}
+    bounds: Vec<TyParamBound> }
 
 impl Clean<TyParam> for ast::TyParam {
     fn clean(&self) -> TyParam {
@@ -340,9 +335,8 @@ fn clean(&self) -> Lifetime {
 // maybe use a Generic enum and use ~[Generic]?
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Generics {
-    lifetimes: ~[Lifetime],
-    type_params: ~[TyParam]
-}
+    lifetimes: Vec<Lifetime> ,
+    type_params: Vec<TyParam> }
 
 impl Clean<Generics> for ast::Generics {
     fn clean(&self) -> Generics {
@@ -373,7 +367,7 @@ fn clean(&self) -> Item {
             },
             output: (self.decl.output.clean()),
             cf: self.decl.cf.clean(),
-            attrs: ~[]
+            attrs: Vec::new()
         };
         Item {
             name: Some(self.ident.clean()),
@@ -411,7 +405,7 @@ fn clean(&self) -> Item {
             },
             output: (self.decl.output.clean()),
             cf: self.decl.cf.clean(),
-            attrs: ~[]
+            attrs: Vec::new()
         };
         Item {
             name: Some(self.ident.clean()),
@@ -476,12 +470,11 @@ fn clean(&self) -> Item {
 pub struct ClosureDecl {
     sigil: ast::Sigil,
     region: Option<Lifetime>,
-    lifetimes: ~[Lifetime],
+    lifetimes: Vec<Lifetime> ,
     decl: FnDecl,
     onceness: ast::Onceness,
     purity: ast::Purity,
-    bounds: ~[TyParamBound]
-}
+    bounds: Vec<TyParamBound> }
 
 impl Clean<ClosureDecl> for ast::ClosureTy {
     fn clean(&self) -> ClosureDecl {
@@ -494,7 +487,7 @@ fn clean(&self) -> ClosureDecl {
             purity: self.purity,
             bounds: match self.bounds {
                 Some(ref x) => x.clean().move_iter().collect(),
-                None        => ~[]
+                None        => Vec::new()
             },
         }
     }
@@ -505,12 +498,11 @@ pub struct FnDecl {
     inputs: Arguments,
     output: Type,
     cf: RetStyle,
-    attrs: ~[Attribute]
-}
+    attrs: Vec<Attribute> }
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Arguments {
-    values: ~[Argument],
+    values: Vec<Argument> ,
 }
 
 impl Clean<FnDecl> for ast::FnDecl {
@@ -521,7 +513,7 @@ fn clean(&self) -> FnDecl {
             },
             output: (self.output.clean()),
             cf: self.cf.clean(),
-            attrs: ~[]
+            attrs: Vec::new()
         }
     }
 }
@@ -560,9 +552,9 @@ fn clean(&self) -> RetStyle {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Trait {
-    methods: ~[TraitMethod],
+    methods: Vec<TraitMethod> ,
     generics: Generics,
-    parents: ~[Type],
+    parents: Vec<Type> ,
 }
 
 impl Clean<Item> for doctree::Trait {
@@ -632,14 +624,14 @@ pub enum Type {
     /// structs/enums/traits (anything that'd be an ast::TyPath)
     ResolvedPath {
         path: Path,
-        typarams: Option<~[TyParamBound]>,
+        typarams: Option<Vec<TyParamBound> >,
         id: ast::NodeId,
     },
     /// Same as above, but only external variants
     ExternalPath {
         path: Path,
-        typarams: Option<~[TyParamBound]>,
-        fqn: ~[~str],
+        typarams: Option<Vec<TyParamBound> >,
+        fqn: Vec<~str> ,
         kind: TypeKind,
         krate: ast::CrateNum,
     },
@@ -655,7 +647,7 @@ pub enum Type {
     Closure(~ClosureDecl),
     /// extern "ABI" fn
     BareFunction(~BareFunctionDecl),
-    Tuple(~[Type]),
+    Tuple(Vec<Type> ),
     Vector(~Type),
     FixedVector(~Type, ~str),
     String,
@@ -746,7 +738,7 @@ fn clean(&self) -> Option<Visibility> {
 pub struct Struct {
     struct_type: doctree::StructType,
     generics: Generics,
-    fields: ~[Item],
+    fields: Vec<Item> ,
     fields_stripped: bool,
 }
 
@@ -774,7 +766,7 @@ fn clean(&self) -> Item {
 #[deriving(Clone, Encodable, Decodable)]
 pub struct VariantStruct {
     struct_type: doctree::StructType,
-    fields: ~[Item],
+    fields: Vec<Item> ,
     fields_stripped: bool,
 }
 
@@ -790,7 +782,7 @@ fn clean(&self) -> VariantStruct {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Enum {
-    variants: ~[Item],
+    variants: Vec<Item> ,
     generics: Generics,
     variants_stripped: bool,
 }
@@ -835,7 +827,7 @@ fn clean(&self) -> Item {
 #[deriving(Clone, Encodable, Decodable)]
 pub enum VariantKind {
     CLikeVariant,
-    TupleVariant(~[Type]),
+    TupleVariant(Vec<Type> ),
     StructVariant(VariantStruct),
 }
 
@@ -882,7 +874,7 @@ fn clean(&self) -> Span {
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Path {
     global: bool,
-    segments: ~[PathSegment],
+    segments: Vec<PathSegment> ,
 }
 
 impl Clean<Path> for ast::Path {
@@ -897,8 +889,8 @@ fn clean(&self) -> Path {
 #[deriving(Clone, Encodable, Decodable)]
 pub struct PathSegment {
     name: ~str,
-    lifetimes: ~[Lifetime],
-    types: ~[Type],
+    lifetimes: Vec<Lifetime> ,
+    types: Vec<Type> ,
 }
 
 impl Clean<PathSegment> for ast::PathSegment {
@@ -969,7 +961,7 @@ fn clean(&self) -> BareFunctionDecl {
             purity: self.purity,
             generics: Generics {
                 lifetimes: self.lifetimes.clean().move_iter().collect(),
-                type_params: ~[],
+                type_params: Vec::new(),
             },
             decl: self.decl.clean(),
             abi: self.abis.to_str(),
@@ -1025,7 +1017,7 @@ pub struct Impl {
     generics: Generics,
     trait_: Option<Type>,
     for_: Type,
-    methods: ~[Item],
+    methods: Vec<Item> ,
 }
 
 impl Clean<Item> for doctree::Impl {
@@ -1069,7 +1061,7 @@ fn clean(&self) -> Item {
 #[deriving(Clone, Encodable, Decodable)]
 pub enum ViewItemInner {
     ExternCrate(~str, Option<~str>, ast::NodeId),
-    Import(~[ViewPath])
+    Import(Vec<ViewPath>)
 }
 
 impl Clean<ViewItemInner> for ast::ViewItem_ {
@@ -1096,7 +1088,7 @@ pub enum ViewPath {
     // use source::*;
     GlobImport(ImportSource),
     // use source::{a, b, c};
-    ImportList(ImportSource, ~[ViewListIdent]),
+    ImportList(ImportSource, Vec<ViewListIdent> ),
 }
 
 #[deriving(Clone, Encodable, Decodable)]
@@ -1231,7 +1223,7 @@ fn name_from_pat(p: &ast::Pat) -> ~str {
 }
 
 /// Given a Type, resolve it using the def_map
-fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>,
+fn resolve_type(path: Path, tpbs: Option<Vec<TyParamBound> >,
                 id: ast::NodeId) -> Type {
     let cx = local_data::get(super::ctxtkey, |x| *x.unwrap());
     let tycx = match cx.maybe_typed {
@@ -1274,9 +1266,14 @@ fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>,
         ResolvedPath{ path: path, typarams: tpbs, id: def_id.node }
     } else {
         let fqn = csearch::get_item_path(tycx, def_id);
-        let fqn = fqn.move_iter().map(|i| i.to_str()).to_owned_vec();
-        ExternalPath{ path: path, typarams: tpbs, fqn: fqn, kind: kind,
-                      krate: def_id.krate }
+        let fqn = fqn.move_iter().map(|i| i.to_str()).collect();
+        ExternalPath {
+            path: path,
+            typarams: tpbs,
+            fqn: fqn,
+            kind: kind,
+            krate: def_id.krate,
+        }
     }
 }
 
index 91c4311ff541c4b6569b22a548fd0bc8105c5517..7fb40a09693edd388e668e1f4a381dc8b8b535fa 100644 (file)
@@ -51,8 +51,8 @@ pub struct CrateAnalysis {
 }
 
 /// Parses, resolves, and typechecks the given crate
-fn get_ast_and_resolve(cpath: &Path,
-                       libs: HashSet<Path>, cfgs: ~[~str]) -> (DocContext, CrateAnalysis) {
+fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<~str>)
+                       -> (DocContext, CrateAnalysis) {
     use syntax::codemap::dummy_spanned;
     use rustc::driver::driver::{FileInput, build_configuration,
                                 phase_1_parse_input,
@@ -101,7 +101,8 @@ fn get_ast_and_resolve(cpath: &Path,
     })
 }
 
-pub fn run_core (libs: HashSet<Path>, cfgs: ~[~str], path: &Path) -> (clean::Crate, CrateAnalysis) {
+pub fn run_core(libs: HashSet<Path>, cfgs: Vec<~str>, path: &Path)
+                -> (clean::Crate, CrateAnalysis) {
     let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs);
     let ctxt = @ctxt;
     local_data::set(super::ctxtkey, ctxt);
index c5849f5aa28b6376531d1d26616de52f9608209e..2bd2e7a8e5c61d138a9ca5322d0f18009bc7a2dd 100644 (file)
 
 pub struct Module {
     name: Option<Ident>,
-    attrs: ~[ast::Attribute],
+    attrs: Vec<ast::Attribute> ,
     where: Span,
-    structs: ~[Struct],
-    enums: ~[Enum],
-    fns: ~[Function],
-    mods: ~[Module],
+    structs: Vec<Struct> ,
+    enums: Vec<Enum> ,
+    fns: Vec<Function> ,
+    mods: Vec<Module> ,
     id: NodeId,
-    typedefs: ~[Typedef],
-    statics: ~[Static],
-    traits: ~[Trait],
+    typedefs: Vec<Typedef> ,
+    statics: Vec<Static> ,
+    traits: Vec<Trait> ,
     vis: ast::Visibility,
-    impls: ~[Impl],
-    foreigns: ~[ast::ForeignMod],
-    view_items: ~[ast::ViewItem],
-    macros: ~[Macro],
+    impls: Vec<Impl> ,
+    foreigns: Vec<ast::ForeignMod> ,
+    view_items: Vec<ast::ViewItem> ,
+    macros: Vec<Macro> ,
     is_crate: bool,
 }
 
@@ -43,18 +43,18 @@ pub fn new(name: Option<Ident>) -> Module {
             id: 0,
             vis: ast::Private,
             where: syntax::codemap::DUMMY_SP,
-            attrs      : ~[],
-            structs    : ~[],
-            enums      : ~[],
-            fns        : ~[],
-            mods       : ~[],
-            typedefs   : ~[],
-            statics    : ~[],
-            traits     : ~[],
-            impls      : ~[],
-            view_items : ~[],
-            foreigns   : ~[],
-            macros     : ~[],
+            attrs      : Vec::new(),
+            structs    : Vec::new(),
+            enums      : Vec::new(),
+            fns        : Vec::new(),
+            mods       : Vec::new(),
+            typedefs   : Vec::new(),
+            statics    : Vec::new(),
+            traits     : Vec::new(),
+            impls      : Vec::new(),
+            view_items : Vec::new(),
+            foreigns   : Vec::new(),
+            macros     : Vec::new(),
             is_crate   : false,
         }
     }
@@ -83,16 +83,16 @@ pub struct Struct {
     struct_type: StructType,
     name: Ident,
     generics: ast::Generics,
-    attrs: ~[ast::Attribute],
-    fields: ~[ast::StructField],
+    attrs: Vec<ast::Attribute> ,
+    fields: Vec<ast::StructField> ,
     where: Span,
 }
 
 pub struct Enum {
     vis: ast::Visibility,
-    variants: ~[Variant],
+    variants: Vec<Variant> ,
     generics: ast::Generics,
-    attrs: ~[ast::Attribute],
+    attrs: Vec<ast::Attribute> ,
     id: NodeId,
     where: Span,
     name: Ident,
@@ -100,7 +100,7 @@ pub struct Enum {
 
 pub struct Variant {
     name: Ident,
-    attrs: ~[ast::Attribute],
+    attrs: Vec<ast::Attribute> ,
     kind: ast::VariantKind,
     id: ast::NodeId,
     vis: ast::Visibility,
@@ -109,7 +109,7 @@ pub struct Variant {
 
 pub struct Function {
     decl: ast::FnDecl,
-    attrs: ~[ast::Attribute],
+    attrs: Vec<ast::Attribute> ,
     id: NodeId,
     name: Ident,
     vis: ast::Visibility,
@@ -123,7 +123,7 @@ pub struct Typedef {
     gen: ast::Generics,
     name: Ident,
     id: ast::NodeId,
-    attrs: ~[ast::Attribute],
+    attrs: Vec<ast::Attribute> ,
     where: Span,
     vis: ast::Visibility,
 }
@@ -133,7 +133,7 @@ pub struct Static {
     mutability: ast::Mutability,
     expr: @ast::Expr,
     name: Ident,
-    attrs: ~[ast::Attribute],
+    attrs: Vec<ast::Attribute> ,
     vis: ast::Visibility,
     id: ast::NodeId,
     where: Span,
@@ -141,10 +141,10 @@ pub struct Static {
 
 pub struct Trait {
     name: Ident,
-    methods: ~[ast::TraitMethod], //should be TraitMethod
+    methods: Vec<ast::TraitMethod> , //should be TraitMethod
     generics: ast::Generics,
-    parents: ~[ast::TraitRef],
-    attrs: ~[ast::Attribute],
+    parents: Vec<ast::TraitRef> ,
+    attrs: Vec<ast::Attribute> ,
     id: ast::NodeId,
     where: Span,
     vis: ast::Visibility,
@@ -154,8 +154,8 @@ pub struct Impl {
     generics: ast::Generics,
     trait_: Option<ast::TraitRef>,
     for_: ast::P<ast::Ty>,
-    methods: ~[@ast::Method],
-    attrs: ~[ast::Attribute],
+    methods: Vec<@ast::Method> ,
+    attrs: Vec<ast::Attribute> ,
     where: Span,
     vis: ast::Visibility,
     id: ast::NodeId,
@@ -164,7 +164,7 @@ pub struct Impl {
 pub struct Macro {
     name: Ident,
     id: ast::NodeId,
-    attrs: ~[ast::Attribute],
+    attrs: Vec<ast::Attribute> ,
     where: Span,
 }
 
index 672b46afcd0835ef615ec2a6579df472d62d771b..f6b9ec329fd35df0ccee9aa94f981d10d81a0352 100644 (file)
@@ -23,7 +23,7 @@ fn fold_item_recur(&mut self, item: Item) -> Option<Item> {
         let inner = inner;
         let inner = match inner {
             StructItem(mut i) => {
-                let mut foo = ~[]; swap(&mut foo, &mut i.fields);
+                let mut foo = Vec::new(); swap(&mut foo, &mut i.fields);
                 let num_fields = foo.len();
                 i.fields.extend(&mut foo.move_iter().filter_map(|x| self.fold_item(x)));
                 i.fields_stripped |= num_fields != i.fields.len();
@@ -33,7 +33,7 @@ fn fold_item_recur(&mut self, item: Item) -> Option<Item> {
                 ModuleItem(self.fold_mod(i))
             },
             EnumItem(mut i) => {
-                let mut foo = ~[]; swap(&mut foo, &mut i.variants);
+                let mut foo = Vec::new(); swap(&mut foo, &mut i.variants);
                 let num_variants = foo.len();
                 i.variants.extend(&mut foo.move_iter().filter_map(|x| self.fold_item(x)));
                 i.variants_stripped |= num_variants != i.variants.len();
@@ -56,12 +56,12 @@ fn vtrm<T: DocFolder>(this: &mut T, trm: TraitMethod) -> Option<TraitMethod> {
                         },
                     }
                 }
-                let mut foo = ~[]; swap(&mut foo, &mut i.methods);
+                let mut foo = Vec::new(); swap(&mut foo, &mut i.methods);
                 i.methods.extend(&mut foo.move_iter().filter_map(|x| vtrm(self, x)));
                 TraitItem(i)
             },
             ImplItem(mut i) => {
-                let mut foo = ~[]; swap(&mut foo, &mut i.methods);
+                let mut foo = Vec::new(); swap(&mut foo, &mut i.methods);
                 i.methods.extend(&mut foo.move_iter().filter_map(|x| self.fold_item(x)));
                 ImplItem(i)
             },
@@ -69,7 +69,7 @@ fn vtrm<T: DocFolder>(this: &mut T, trm: TraitMethod) -> Option<TraitMethod> {
                 let i2 = i.clone(); // this clone is small
                 match i.kind {
                     StructVariant(mut j) => {
-                        let mut foo = ~[]; swap(&mut foo, &mut j.fields);
+                        let mut foo = Vec::new(); swap(&mut foo, &mut j.fields);
                         let num_fields = foo.len();
                         let c = |x| self.fold_item(x);
                         j.fields.extend(&mut foo.move_iter().filter_map(c));
index 9a7d00195d40d1adc6ee6fd990279b286462bfe1..a8f243139d269b80febb72ff37069606754136db 100644 (file)
@@ -170,7 +170,7 @@ fn external_path(w: &mut io::Writer, p: &clean::Path, print_all: bool,
             }
         },
         |_cache| {
-            Some((fqn.to_owned(), match kind {
+            Some((Vec::from_slice(fqn), match kind {
                 clean::TypeStruct => "struct",
                 clean::TypeEnum => "enum",
                 clean::TypeFunction => "fn",
@@ -181,7 +181,7 @@ fn external_path(w: &mut io::Writer, p: &clean::Path, print_all: bool,
 
 fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
         root: |&render::Cache, &[~str]| -> Option<~str>,
-        info: |&render::Cache| -> Option<(~[~str], &'static str)>)
+        info: |&render::Cache| -> Option<(Vec<~str> , &'static str)>)
     -> fmt::Result
 {
     // The generics will get written to both the title and link
@@ -210,7 +210,7 @@ fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
         local_data::get(cache_key, |cache| {
             let cache = cache.unwrap().get();
             let abs_root = root(cache, loc.as_slice());
-            let rel_root = match path.segments[0].name.as_slice() {
+            let rel_root = match path.segments.get(0).name.as_slice() {
                 "self" => Some(~"./"),
                 _ => None,
             };
@@ -279,7 +279,7 @@ fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
 
 /// Helper to render type parameters
 fn typarams(w: &mut io::Writer,
-            typarams: &Option<~[clean::TyParamBound]>) -> fmt::Result {
+            typarams: &Option<Vec<clean::TyParamBound> >) -> fmt::Result {
     match *typarams {
         Some(ref params) => {
             try!(write!(w, "&lt;"));
@@ -536,11 +536,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             Some(did) if ast_util::is_local(did) => {
                 let path = clean::Path {
                     global: false,
-                    segments: ~[clean::PathSegment {
+                    segments: vec!(clean::PathSegment {
                         name: self.name.clone(),
-                        lifetimes: ~[],
-                        types: ~[],
-                    }]
+                        lifetimes: Vec::new(),
+                        types: Vec::new(),
+                    })
                 };
                 resolved_path(f.buf, did.node, &path, false)
             }
index 6bbe22402d10c6dfb38a085d0d964da0c25d7ad4..4079fafb3683789867cc9e57ca919956db53ed56 100644 (file)
@@ -68,7 +68,7 @@
 pub struct Context {
     /// Current hierarchy of components leading down to what's currently being
     /// rendered
-    current: ~[~str],
+    current: Vec<~str> ,
     /// String representation of how to get back to the root path of the 'doc/'
     /// folder in terms of a relative URL.
     root_path: ~str,
@@ -83,7 +83,7 @@ pub struct Context {
     /// functions), and the value is the list of containers belonging to this
     /// header. This map will change depending on the surrounding context of the
     /// page.
-    sidebar: HashMap<~str, ~[~str]>,
+    sidebar: HashMap<~str, Vec<~str> >,
     /// This flag indicates whether [src] links should be generated or not. If
     /// the source files are present in the html rendering, then this will be
     /// `true`.
@@ -130,14 +130,14 @@ pub struct Cache {
     ///
     /// The values of the map are a list of implementations and documentation
     /// found on that implementation.
-    impls: HashMap<ast::NodeId, ~[(clean::Impl, Option<~str>)]>,
+    impls: HashMap<ast::NodeId, Vec<(clean::Impl, Option<~str>)> >,
 
     /// Maintains a mapping of local crate node ids to the fully qualified name
     /// and "short type description" of that node. This is used when generating
     /// URLs when a type is being linked to. External paths are not located in
     /// this map because the `External` type itself has all the information
     /// necessary.
-    paths: HashMap<ast::NodeId, (~[~str], &'static str)>,
+    paths: HashMap<ast::NodeId, (Vec<~str> , &'static str)>,
 
     /// This map contains information about all known traits of this crate.
     /// Implementations of a crate should inherit the documentation of the
@@ -148,16 +148,16 @@ pub struct Cache {
     /// When rendering traits, it's often useful to be able to list all
     /// implementors of the trait, and this mapping is exactly, that: a mapping
     /// of trait ids to the list of known implementors of the trait
-    implementors: HashMap<ast::NodeId, ~[Implementor]>,
+    implementors: HashMap<ast::NodeId, Vec<Implementor> >,
 
     /// Cache of where external crate documentation can be found.
     extern_locations: HashMap<ast::CrateNum, ExternalLocation>,
 
     // Private fields only used when initially crawling a crate to build a cache
 
-    priv stack: ~[~str],
-    priv parent_stack: ~[ast::NodeId],
-    priv search_index: ~[IndexItem],
+    priv stack: Vec<~str> ,
+    priv parent_stack: Vec<ast::NodeId> ,
+    priv search_index: Vec<IndexItem> ,
     priv privmod: bool,
     priv public_items: NodeSet,
 
@@ -202,13 +202,13 @@ struct IndexItem {
 // TLS keys used to carry information around during rendering.
 
 local_data_key!(pub cache_key: Arc<Cache>)
-local_data_key!(pub current_location_key: ~[~str])
+local_data_key!(pub current_location_key: Vec<~str> )
 
 /// Generates the documentation for `crate` into the directory `dst`
 pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
     let mut cx = Context {
         dst: dst,
-        current: ~[],
+        current: Vec::new(),
         root_path: ~"",
         sidebar: HashMap::new(),
         layout: layout::Layout {
@@ -250,9 +250,9 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
             paths: HashMap::new(),
             traits: HashMap::new(),
             implementors: HashMap::new(),
-            stack: ~[],
-            parent_stack: ~[],
-            search_index: ~[],
+            stack: Vec::new(),
+            parent_stack: Vec::new(),
+            search_index: Vec::new(),
             extern_locations: HashMap::new(),
             privmod: false,
             public_items: public_items,
@@ -563,7 +563,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                 match i.trait_ {
                     Some(clean::ResolvedPath{ id, .. }) => {
                         let v = self.implementors.find_or_insert_with(id, |_|{
-                            ~[]
+                            Vec::new()
                         });
                         match i.for_ {
                             clean::ResolvedPath{..} => {
@@ -694,7 +694,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                         match i.for_ {
                             clean::ResolvedPath { id, .. } => {
                                 let v = self.impls.find_or_insert_with(id, |_| {
-                                    ~[]
+                                    Vec::new()
                                 });
                                 // extract relevant documentation for this impl
                                 match attrs.move_iter().find(|a| {
@@ -787,7 +787,7 @@ fn krate(self, mut krate: clean::Crate, cache: Cache) -> io::IoResult<()> {
         // using a rwarc makes this parallelizable in the future
         local_data::set(cache_key, Arc::new(cache));
 
-        let mut work = ~[(self, item)];
+        let mut work = vec!((self, item));
         loop {
             match work.pop() {
                 Some((mut cx, item)) => try!(cx.item(item, |cx, item| {
@@ -919,7 +919,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         }
 
         if self.cx.include_sources {
-            let mut path = ~[];
+            let mut path = Vec::new();
             clean_srcpath(self.item.source.filename.as_bytes(), |component| {
                 path.push(component.to_owned());
             });
@@ -966,8 +966,9 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
                       shortty(self.item), self.item.name.get_ref().as_slice()));
 
         match self.item.inner {
-            clean::ModuleItem(ref m) => item_module(fmt.buf, self.cx,
-                                                    self.item, m.items),
+            clean::ModuleItem(ref m) => {
+                item_module(fmt.buf, self.cx, self.item, m.items.as_slice())
+            }
             clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) =>
                 item_function(fmt.buf, self.item, f),
             clean::TraitItem(ref t) => item_trait(fmt.buf, self.item, t),
@@ -1319,8 +1320,14 @@ fn fun(w: &mut Writer, it: &clean::Item, purity: ast::Purity,
 fn item_struct(w: &mut Writer, it: &clean::Item,
                s: &clean::Struct) -> fmt::Result {
     try!(write!(w, "<pre class='rust struct'>"));
-    try!(render_struct(w, it, Some(&s.generics), s.struct_type, s.fields,
-                         s.fields_stripped, "", true));
+    try!(render_struct(w,
+                       it,
+                       Some(&s.generics),
+                       s.struct_type,
+                       s.fields.as_slice(),
+                       s.fields_stripped,
+                       "",
+                       true));
     try!(write!(w, "</pre>"));
 
     try!(document(w, it));
@@ -1368,9 +1375,14 @@ fn item_enum(w: &mut Writer, it: &clean::Item, e: &clean::Enum) -> fmt::Result {
                             try!(write!(w, ")"));
                         }
                         clean::StructVariant(ref s) => {
-                            try!(render_struct(w, v, None, s.struct_type,
-                                                 s.fields, s.fields_stripped,
-                                                 "    ", false));
+                            try!(render_struct(w,
+                                               v,
+                                               None,
+                                               s.struct_type,
+                                               s.fields.as_slice(),
+                                               s.fields_stripped,
+                                               "    ",
+                                               false));
                         }
                     }
                 }
@@ -1679,7 +1691,7 @@ fn block(w: &mut Writer, short: &str, longty: &str,
     }
 }
 
-fn build_sidebar(m: &clean::Module) -> HashMap<~str, ~[~str]> {
+fn build_sidebar(m: &clean::Module) -> HashMap<~str, Vec<~str> > {
     let mut map = HashMap::new();
     for item in m.items.iter() {
         let short = shortty(item);
@@ -1687,12 +1699,12 @@ fn build_sidebar(m: &clean::Module) -> HashMap<~str, ~[~str]> {
             None => continue,
             Some(ref s) => s.to_owned(),
         };
-        let v = map.find_or_insert_with(short.to_owned(), |_| ~[]);
+        let v = map.find_or_insert_with(short.to_owned(), |_| Vec::new());
         v.push(myname);
     }
 
     for (_, items) in map.mut_iter() {
-        items.sort();
+        items.as_mut_slice().sort();
     }
     return map;
 }
index 069ab37a2ad013e6df688f0896f0a09d4a9dbc41..6fcd1f83cf41cccdb28974e6eafded61361d1702 100644 (file)
@@ -80,15 +80,15 @@ pub mod html {
 local_data_key!(pub ctxtkey: @core::DocContext)
 local_data_key!(pub analysiskey: core::CrateAnalysis)
 
-type Output = (clean::Crate, ~[plugins::PluginJson]);
+type Output = (clean::Crate, Vec<plugins::PluginJson> );
 
 pub fn main() {
     std::os::set_exit_status(main_args(std::os::args()));
 }
 
-pub fn opts() -> ~[getopts::OptGroup] {
+pub fn opts() -> Vec<getopts::OptGroup> {
     use getopts::*;
-    ~[
+    vec!(
         optflag("h", "help", "show this help message"),
         optflag("", "version", "print rustdoc's version"),
         optopt("r", "input-format", "the input type of the specified file",
@@ -121,16 +121,18 @@ pub fn opts() -> ~[getopts::OptGroup] {
         optmulti("", "markdown-after-content",
                  "files to include inline between the content and </body> of a rendered \
                  Markdown file",
-                 "FILES"),
-    ]
+                 "FILES")
+    )
 }
 
 pub fn usage(argv0: &str) {
-    println!("{}", getopts::usage(format!("{} [options] <input>", argv0), opts()));
+    println!("{}",
+             getopts::usage(format!("{} [options] <input>", argv0),
+                            opts().as_slice()));
 }
 
 pub fn main_args(args: &[~str]) -> int {
-    let matches = match getopts::getopts(args.tail(), opts()) {
+    let matches = match getopts::getopts(args.tail(), opts().as_slice()) {
         Ok(m) => m,
         Err(err) => {
             println!("{}", err.to_err_msg());
@@ -152,12 +154,15 @@ pub fn main_args(args: &[~str]) -> int {
         println!("only one input file may be specified");
         return 1;
     }
-    let input = matches.free[0].as_slice();
+    let input = matches.free.get(0).as_slice();
 
-    let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice())).move_iter().collect();
+    let libs = matches.opt_strs("L").iter().map(|s| Path::new(s.as_slice())).collect();
 
     let test_args = matches.opt_strs("test-args");
-    let test_args = test_args.iter().flat_map(|s| s.words()).map(|s| s.to_owned()).to_owned_vec();
+    let test_args: Vec<~str> = test_args.iter()
+                                        .flat_map(|s| s.words())
+                                        .map(|s| s.to_owned())
+                                        .collect();
 
     let should_test = matches.opt_present("test");
     let markdown_input = input.ends_with(".md") || input.ends_with(".markdown");
@@ -165,7 +170,11 @@ pub fn main_args(args: &[~str]) -> int {
     let output = matches.opt_str("o").map(|s| Path::new(s));
 
     match (should_test, markdown_input) {
-        (true, true) => return markdown::test(input, libs, test_args),
+        (true, true) => {
+            return markdown::test(input,
+                                  libs,
+                                  test_args.move_iter().collect())
+        }
         (true, false) => return test::run(input, libs, test_args),
 
         (false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
@@ -173,7 +182,7 @@ pub fn main_args(args: &[~str]) -> int {
         (false, false) => {}
     }
 
-    if matches.opt_strs("passes") == ~[~"list"] {
+    if matches.opt_strs("passes").as_slice() == &[~"list"] {
         println!("Available passes for running rustdoc:");
         for &(name, _, description) in PASSES.iter() {
             println!("{:>20s} - {}", name, description);
@@ -248,13 +257,18 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
     let mut plugins = matches.opt_strs("plugins");
 
     // First, parse the crate and extract all relevant information.
-    let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice()));
+    let libs: Vec<Path> = matches.opt_strs("L")
+                                 .iter()
+                                 .map(|s| Path::new(s.as_slice()))
+                                 .collect();
     let cfgs = matches.opt_strs("cfg");
     let cr = Path::new(cratefile);
     info!("starting to run rustc");
     let (krate, analysis) = std::task::try(proc() {
         let cr = cr;
-        core::run_core(libs.move_iter().collect(), cfgs, &cr)
+        core::run_core(libs.move_iter().collect(),
+                       cfgs.move_iter().collect(),
+                       &cr)
     }).unwrap();
     info!("finished with rustc");
     local_data::set(analysiskey, analysis);
@@ -344,7 +358,7 @@ fn json_input(input: &str) -> Result<Output, ~str> {
             };
             // FIXME: this should read from the "plugins" field, but currently
             //      Json doesn't implement decodable...
-            let plugin_output = ~[];
+            let plugin_output = Vec::new();
             Ok((krate, plugin_output))
         }
         Ok(..) => Err(~"malformed json input: expected an object at the top"),
@@ -353,7 +367,7 @@ fn json_input(input: &str) -> Result<Output, ~str> {
 
 /// Outputs the crate/plugin json as a giant json blob at the specified
 /// destination.
-fn json_output(krate: clean::Crate, res: ~[plugins::PluginJson],
+fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
                dst: Path) -> io::IoResult<()> {
     // {
     //   "schema": version,
index f8ebfae6cfb92a4da368264ac1435991b25d0c2d..d04d39bcee5c0d26581a523727c120846e9ff642 100644 (file)
@@ -86,9 +86,12 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
     let input_str = load_or_return!(input, 1, 2);
 
     let (in_header, before_content, after_content) =
-        match (load_external_files(matches.opt_strs("markdown-in-header")),
-               load_external_files(matches.opt_strs("markdown-before-content")),
-               load_external_files(matches.opt_strs("markdown-after-content"))) {
+        match (load_external_files(matches.opt_strs("markdown-in-header")
+                                          .as_slice()),
+               load_external_files(matches.opt_strs("markdown-before-content")
+                                          .as_slice()),
+               load_external_files(matches.opt_strs("markdown-after-content")
+                                          .as_slice())) {
         (Some(a), Some(b), Some(c)) => (a,b,c),
         _ => return 3
     };
index e167f0ad9ee0ccbbe588be45bfc2cb7536625bbc..d9dd73e695647ebc60c19836c83dc63adc145d8e 100644 (file)
@@ -218,7 +218,7 @@ pub fn unindent_comments(krate: clean::Crate) -> plugins::PluginResult {
     impl fold::DocFolder for CommentCleaner {
         fn fold_item(&mut self, i: Item) -> Option<Item> {
             let mut i = i;
-            let mut avec: ~[clean::Attribute] = ~[];
+            let mut avec: Vec<clean::Attribute> = Vec::new();
             for attr in i.attrs.iter() {
                 match attr {
                     &clean::NameValue(ref x, ref s) if "doc" == *x => avec.push(
@@ -250,7 +250,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
                     _ => ()
                 }
             }
-            let mut a: ~[clean::Attribute] = i.attrs.iter().filter(|&a| match a {
+            let mut a: Vec<clean::Attribute> = i.attrs.iter().filter(|&a| match a {
                 &clean::NameValue(ref x, _) if "doc" == *x => false,
                 _ => true
             }).map(|x| x.clone()).collect();
@@ -267,7 +267,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
 }
 
 pub fn unindent(s: &str) -> ~str {
-    let lines = s.lines_any().collect::<~[&str]>();
+    let lines = s.lines_any().collect::<Vec<&str> >();
     let mut saw_first_line = false;
     let mut saw_second_line = false;
     let min_indent = lines.iter().fold(uint::MAX, |min_indent, line| {
@@ -311,7 +311,7 @@ pub fn unindent(s: &str) -> ~str {
     });
 
     if lines.len() >= 1 {
-        let mut unindented = ~[ lines[0].trim() ];
+        let mut unindented = vec!( lines.get(0).trim() );
         unindented.push_all(lines.tail().map(|&line| {
             if line.is_whitespace() {
                 line
index 2e7c4224ee186ef9c9f5077df3db64c1b83e53b6..6e0e9f8790064bdb72e22e9a8a4fbbdacd0e49c2 100644 (file)
@@ -19,8 +19,8 @@
 
 /// Manages loading and running of plugins
 pub struct PluginManager {
-    priv dylibs: ~[dl::DynamicLibrary],
-    priv callbacks: ~[PluginCallback],
+    priv dylibs: Vec<dl::DynamicLibrary> ,
+    priv callbacks: Vec<PluginCallback> ,
     /// The directory plugins will be loaded from
     prefix: Path,
 }
@@ -29,8 +29,8 @@ impl PluginManager {
     /// Create a new plugin manager
     pub fn new(prefix: Path) -> PluginManager {
         PluginManager {
-            dylibs: ~[],
-            callbacks: ~[],
+            dylibs: Vec::new(),
+            callbacks: Vec::new(),
             prefix: prefix,
         }
     }
@@ -57,8 +57,8 @@ pub fn add_plugin(&mut self, plugin: PluginCallback) {
         self.callbacks.push(plugin);
     }
     /// Run all the loaded plugins over the crate, returning their results
-    pub fn run_plugins(&self, krate: clean::Crate) -> (clean::Crate, ~[PluginJson]) {
-        let mut out_json = ~[];
+    pub fn run_plugins(&self, krate: clean::Crate) -> (clean::Crate, Vec<PluginJson> ) {
+        let mut out_json = Vec::new();
         let mut krate = krate;
         for &callback in self.callbacks.iter() {
             let (c, res) = callback(krate);
index 0a472a0ccaf2fe88970cc0eb33e207a3bb24c483..09a1b1fc81abd486616147e4baee05e0d1e945b6 100644 (file)
@@ -33,7 +33,7 @@
 use passes;
 use visit_ast::RustdocVisitor;
 
-pub fn run(input: &str, libs: HashSet<Path>, mut test_args: ~[~str]) -> int {
+pub fn run(input: &str, libs: HashSet<Path>, mut test_args: Vec<~str>) -> int {
     let input_path = Path::new(input);
     let input = driver::FileInput(input_path.clone());
 
@@ -71,13 +71,16 @@ pub fn run(input: &str, libs: HashSet<Path>, mut test_args: ~[~str]) -> int {
     let (krate, _) = passes::unindent_comments(krate);
     let (krate, _) = passes::collapse_docs(krate);
 
-    let mut collector = Collector::new(krate.name.to_owned(), libs, false, false);
+    let mut collector = Collector::new(krate.name.to_owned(),
+                                       libs,
+                                       false,
+                                       false);
     collector.fold_crate(krate);
 
     test_args.unshift(~"rustdoctest");
 
-    testing::test_main(test_args, collector.tests);
-
+    testing::test_main(test_args.as_slice(),
+                       collector.tests.move_iter().collect());
     0
 }
 
@@ -187,8 +190,8 @@ fn maketest(s: &str, cratename: &str, loose_feature_gating: bool) -> ~str {
 }
 
 pub struct Collector {
-    tests: ~[testing::TestDescAndFn],
-    priv names: ~[~str],
+    tests: Vec<testing::TestDescAndFn>,
+    priv names: Vec<~str>,
     priv libs: HashSet<Path>,
     priv cnt: uint,
     priv use_headers: bool,
@@ -202,8 +205,8 @@ impl Collector {
     pub fn new(cratename: ~str, libs: HashSet<Path>,
                use_headers: bool, loose_feature_gating: bool) -> Collector {
         Collector {
-            tests: ~[],
-            names: ~[],
+            tests: Vec::new(),
+            names: Vec::new(),
             libs: libs,
             cnt: 0,
             use_headers: use_headers,
index cd8cc8bde6a209facee42727a9fd979673a1bb1d..df533d882f775823ad35ac934bee55cb916615a2 100644 (file)
@@ -22,7 +22,7 @@
 
 pub struct RustdocVisitor<'a> {
     module: Module,
-    attrs: ~[ast::Attribute],
+    attrs: Vec<ast::Attribute> ,
     cx: &'a core::DocContext,
     analysis: Option<&'a core::CrateAnalysis>,
 }
@@ -32,7 +32,7 @@ pub fn new<'b>(cx: &'b core::DocContext,
                    analysis: Option<&'b core::CrateAnalysis>) -> RustdocVisitor<'b> {
         RustdocVisitor {
             module: Module::new(None),
-            attrs: ~[],
+            attrs: Vec::new(),
             cx: cx,
             analysis: analysis,
         }
@@ -72,7 +72,7 @@ pub fn visit_struct_def(&mut self, item: &ast::Item, sd: @ast::StructDef,
     pub fn visit_enum_def(&mut self, it: &ast::Item, def: &ast::EnumDef,
                           params: &ast::Generics) -> Enum {
         debug!("Visiting enum");
-        let mut vars: ~[Variant] = ~[];
+        let mut vars: Vec<Variant> = Vec::new();
         for x in def.variants.iter() {
             vars.push(Variant {
                 name: x.node.name,
@@ -110,7 +110,7 @@ pub fn visit_fn(&mut self, item: &ast::Item, fd: &ast::FnDecl,
         }
     }
 
-    pub fn visit_mod_contents(&mut self, span: Span, attrs: ~[ast::Attribute],
+    pub fn visit_mod_contents(&mut self, span: Span, attrs: Vec<ast::Attribute> ,
                               vis: ast::Visibility, id: ast::NodeId,
                               m: &ast::Mod,
                               name: Option<ast::Ident>) -> Module {
index 71adab71734b99d889ea4b9f7c4b576a610c0ddf..513ca79999730dd2fcb37a46628d7c23f3d0b4eb 100644 (file)
@@ -583,25 +583,26 @@ mod tests {
     use super::{Arc, RWArc, MutexArc, CowArc};
 
     use std::task;
+    use std::vec_ng::Vec;
 
     #[test]
     fn manually_share_arc() {
-        let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+        let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
         let arc_v = Arc::new(v);
 
         let (tx, rx) = channel();
 
         task::spawn(proc() {
-            let arc_v: Arc<~[int]> = rx.recv();
+            let arc_v: Arc<Vec<int>> = rx.recv();
 
             let v = arc_v.get().clone();
-            assert_eq!(v[3], 4);
+            assert_eq!(*v.get(3), 4);
         });
 
         tx.send(arc_v.clone());
 
-        assert_eq!(arc_v.get()[2], 3);
-        assert_eq!(arc_v.get()[4], 5);
+        assert_eq!(*arc_v.get().get(2), 3);
+        assert_eq!(*arc_v.get().get(4), 5);
 
         info!("{:?}", arc_v);
     }
@@ -803,7 +804,7 @@ fn test_rw_arc() {
         });
 
         // Readers try to catch the writer in the act
-        let mut children = ~[];
+        let mut children = Vec::new();
         for _ in range(0, 5) {
             let arc3 = arc.clone();
             let mut builder = task::task();
@@ -857,7 +858,7 @@ fn test_rw_downgrade() {
         let arc = RWArc::new(0);
 
         // Reader tasks
-        let mut reader_convos = ~[];
+        let mut reader_convos = Vec::new();
         for _ in range(0, 10) {
             let ((tx1, rx1), (tx2, rx2)) = (channel(), channel());
             reader_convos.push((tx1, rx2));
index 3bb60046b035ed3f2aa19d7deaa29b6cfd55eff5..c50eeae18d21bf4b05b3721383a37ff97235e9d1 100644 (file)
@@ -161,10 +161,10 @@ pub fn access<U>(&self, blk: || -> U) -> U {
 }
 
 #[doc(hidden)]
-impl Sem<~[WaitQueue]> {
+impl Sem<Vec<WaitQueue> > {
     fn new_and_signal(count: int, num_condvars: uint)
-        -> Sem<~[WaitQueue]> {
-        let mut queues = ~[];
+        -> Sem<Vec<WaitQueue> > {
+        let mut queues = Vec::new();
         for _ in range(0, num_condvars) { queues.push(WaitQueue::new()); }
         Sem::new(count, queues)
     }
@@ -182,7 +182,7 @@ enum ReacquireOrderLock<'a> {
 pub struct Condvar<'a> {
     // The 'Sem' object associated with this condvar. This is the one that's
     // atomically-unlocked-and-descheduled upon and reacquired during wakeup.
-    priv sem: &'a Sem<~[WaitQueue]>,
+    priv sem: &'a Sem<Vec<WaitQueue> >,
     // This is (can be) an extra semaphore which is held around the reacquire
     // operation on the first one. This is only used in cvars associated with
     // rwlocks, and is needed to ensure that, when a downgrader is trying to
@@ -230,7 +230,7 @@ pub fn wait_on(&self, condvar_id: uint) {
                     }
                     // Create waiter nobe, and enqueue ourself to
                     // be woken up by a signaller.
-                    wait_end = Some(state.blocked[condvar_id].wait_end());
+                    wait_end = Some(state.blocked.get(condvar_id).wait_end());
                 } else {
                     out_of_bounds = Some(state.blocked.len());
                 }
@@ -265,7 +265,7 @@ pub fn signal_on(&self, condvar_id: uint) -> bool {
             let mut result = false;
             self.sem.with(|state| {
                 if condvar_id < state.blocked.len() {
-                    result = state.blocked[condvar_id].signal();
+                    result = state.blocked.get(condvar_id).signal();
                 } else {
                     out_of_bounds = Some(state.blocked.len());
                 }
@@ -290,7 +290,7 @@ pub fn broadcast_on(&self, condvar_id: uint) -> uint {
                     // To avoid :broadcast_heavy, we make a new waitqueue,
                     // swap it out with the old one, and broadcast on the
                     // old one outside of the little-lock.
-                    queue = Some(replace(&mut state.blocked[condvar_id],
+                    queue = Some(replace(state.blocked.get_mut(condvar_id),
                                                WaitQueue::new()));
                 } else {
                     out_of_bounds = Some(state.blocked.len());
@@ -326,7 +326,7 @@ fn check_cvar_bounds<U>(
 }
 
 #[doc(hidden)]
-impl Sem<~[WaitQueue]> {
+impl Sem<Vec<WaitQueue> > {
     // The only other places that condvars get built are rwlock.write_cond()
     // and rwlock_write_mode.
     pub fn access_cond<U>(&self, blk: |c: &Condvar| -> U) -> U {
@@ -391,7 +391,7 @@ pub fn access<U>(&self, blk: || -> U) -> U { (&self.sem).access(blk) }
  * unwinds.
  */
 
-pub struct Mutex { priv sem: Sem<~[WaitQueue]> }
+pub struct Mutex { priv sem: Sem<Vec<WaitQueue> > }
 impl Clone for Mutex {
     /// Create a new handle to the mutex.
     fn clone(&self) -> Mutex {
@@ -461,7 +461,7 @@ struct RWLockInner {
  */
 pub struct RWLock {
     priv order_lock:  Semaphore,
-    priv access_lock: Sem<~[WaitQueue]>,
+    priv access_lock: Sem<Vec<WaitQueue> >,
     priv state:       UnsafeArc<RWLockInner>,
 }
 
@@ -765,6 +765,7 @@ mod tests {
     use std::result;
     use std::task;
     use std::comm::Empty;
+    use std::vec_ng::Vec;
 
     /************************************************************************
      * Semaphore tests
@@ -931,7 +932,7 @@ fn test_mutex_cond_wait() {
     #[cfg(test)]
     fn test_mutex_cond_broadcast_helper(num_waiters: uint) {
         let m = Mutex::new();
-        let mut rxs = ~[];
+        let mut rxs = vec!();
 
         for _ in range(0, num_waiters) {
             let mi = m.clone();
@@ -1200,7 +1201,7 @@ fn lock_cond(x: &RWLock, downgrade: bool, blk: |c: &Condvar|) {
             }
         }
         let x = RWLock::new();
-        let mut rxs = ~[];
+        let mut rxs = vec!();
 
         for _ in range(0, num_waiters) {
             let xi = x.clone();
index 7670e9cf50aa22d5d64e7623bb5691733488fc04..709dafd5b933ea2027105d80795c4cd8dfa4cba9 100644 (file)
@@ -14,7 +14,6 @@
 /// parallelism.
 
 use std::task;
-use std::slice;
 
 enum Msg<T> {
     Execute(proc(&T)),
@@ -22,7 +21,7 @@ enum Msg<T> {
 }
 
 pub struct TaskPool<T> {
-    priv channels: ~[Sender<Msg<T>>],
+    priv channels: Vec<Sender<Msg<T>>>,
     priv next_index: uint,
 }
 
@@ -46,7 +45,7 @@ pub fn new(n_tasks: uint,
                -> TaskPool<T> {
         assert!(n_tasks >= 1);
 
-        let channels = slice::from_fn(n_tasks, |i| {
+        let channels = Vec::from_fn(n_tasks, |i| {
             let (tx, rx) = channel::<Msg<T>>();
             let init_fn = init_fn_factory();
 
@@ -66,13 +65,16 @@ pub fn new(n_tasks: uint,
             tx
         });
 
-        return TaskPool { channels: channels, next_index: 0 };
+        return TaskPool {
+            channels: channels,
+            next_index: 0,
+        };
     }
 
     /// Executes the function `f` on a task in the pool. The function
     /// receives a reference to the local data returned by the `init_fn`.
     pub fn execute(&mut self, f: proc(&T)) {
-        self.channels[self.next_index].send(Execute(f));
+        self.channels.get(self.next_index).send(Execute(f));
         self.next_index += 1;
         if self.next_index == self.channels.len() { self.next_index = 0; }
     }
index 3584d2bd162284a8276bdc006fc45eed0c31c827..3148c9233ff2d7b4ea0018ec08af84ede6e902db 100644 (file)
@@ -24,8 +24,8 @@
 
 extern crate collections;
 
-use std::os;
 use std::io;
+use std::os;
 use terminfo::TermInfo;
 use terminfo::searcher::open;
 use terminfo::parser::compiled::{parse, msys_terminfo};
@@ -149,10 +149,14 @@ pub fn new(out: T) -> Result<Terminal<T>, ~str> {
     pub fn fg(&mut self, color: color::Color) -> io::IoResult<bool> {
         let color = self.dim_if_necessary(color);
         if self.num_colors > color {
-            let s = expand(*self.ti.strings.find_equiv(&("setaf")).unwrap(),
+            let s = expand(self.ti
+                               .strings
+                               .find_equiv(&("setaf"))
+                               .unwrap()
+                               .as_slice(),
                            [Number(color as int)], &mut Variables::new());
             if s.is_ok() {
-                try!(self.out.write(s.unwrap()));
+                try!(self.out.write(s.unwrap().as_slice()));
                 return Ok(true)
             }
         }
@@ -168,10 +172,14 @@ pub fn fg(&mut self, color: color::Color) -> io::IoResult<bool> {
     pub fn bg(&mut self, color: color::Color) -> io::IoResult<bool> {
         let color = self.dim_if_necessary(color);
         if self.num_colors > color {
-            let s = expand(*self.ti.strings.find_equiv(&("setab")).unwrap(),
+            let s = expand(self.ti
+                               .strings
+                               .find_equiv(&("setab"))
+                               .unwrap()
+                               .as_slice(),
                            [Number(color as int)], &mut Variables::new());
             if s.is_ok() {
-                try!(self.out.write(s.unwrap()));
+                try!(self.out.write(s.unwrap().as_slice()));
                 return Ok(true)
             }
         }
@@ -189,9 +197,11 @@ pub fn attr(&mut self, attr: attr::Attr) -> io::IoResult<bool> {
                 let cap = cap_for_attr(attr);
                 let parm = self.ti.strings.find_equiv(&cap);
                 if parm.is_some() {
-                    let s = expand(*parm.unwrap(), [], &mut Variables::new());
+                    let s = expand(parm.unwrap().as_slice(),
+                                   [],
+                                   &mut Variables::new());
                     if s.is_ok() {
-                        try!(self.out.write(s.unwrap()));
+                        try!(self.out.write(s.unwrap().as_slice()));
                         return Ok(true)
                     }
                 }
@@ -225,10 +235,10 @@ pub fn reset(&mut self) -> io::IoResult<()> {
             }
         }
         let s = cap.map_or(Err(~"can't find terminfo capability `sgr0`"), |op| {
-            expand(*op, [], &mut Variables::new())
+            expand(op.as_slice(), [], &mut Variables::new())
         });
         if s.is_ok() {
-            return self.out.write(s.unwrap())
+            return self.out.write(s.unwrap().as_slice())
         }
         Ok(())
     }
index de8a1dcc363c759538bfd1db4bab3e818438fbe8..26a819ef2bcb8d4c5d45def641ef822b6223f476 100644 (file)
 /// A parsed terminfo entry.
 pub struct TermInfo {
     /// Names for the terminal
-    priv names: ~[~str],
+    priv names: Vec<~str> ,
     /// Map of capability name to boolean value
     priv bools: HashMap<~str, bool>,
     /// Map of capability name to numeric value
     numbers: HashMap<~str, u16>,
     /// Map of capability name to raw (unexpanded) string
-    strings: HashMap<~str, ~[u8]>
+    strings: HashMap<~str, Vec<u8> >
 }
 
 pub mod searcher;
index ee14b90fbfdf9bb3c59b4cd5c890cb976a8bb75b..09e24a4b1e5ad3355d2ed6a5a74f0002cf451967 100644 (file)
@@ -10,7 +10,7 @@
 
 //! Parameterized string expansion
 
-use std::{char, slice};
+use std::char;
 use std::mem::replace;
 
 #[deriving(Eq)]
@@ -89,13 +89,13 @@ pub fn new() -> Variables {
   multiple capabilities for the same terminal.
   */
 pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
-    -> Result<~[u8], ~str> {
+    -> Result<Vec<u8> , ~str> {
     let mut state = Nothing;
 
     // expanded cap will only rarely be larger than the cap itself
-    let mut output = slice::with_capacity(cap.len());
+    let mut output = Vec::with_capacity(cap.len());
 
-    let mut stack: ~[Param] = ~[];
+    let mut stack: Vec<Param> = Vec::new();
 
     // Copy parameters into a local vector for mutability
     let mut mparams = [
@@ -248,7 +248,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                         let flags = Flags::new();
                         let res = format(stack.pop().unwrap(), FormatOp::from_char(cur), flags);
                         if res.is_err() { return res }
-                        output.push_all(res.unwrap())
+                        output.push_all(res.unwrap().as_slice())
                     } else { return Err(~"stack is empty") },
                     ':'|'#'|' '|'.'|'0'..'9' => {
                         let mut flags = Flags::new();
@@ -343,7 +343,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                     (_,'d')|(_,'o')|(_,'x')|(_,'X')|(_,'s') => if stack.len() > 0 {
                         let res = format(stack.pop().unwrap(), FormatOp::from_char(cur), *flags);
                         if res.is_err() { return res }
-                        output.push_all(res.unwrap());
+                        output.push_all(res.unwrap().as_slice());
                         old_state = state; // will cause state to go to Nothing
                     } else { return Err(~"stack is empty") },
                     (FormatStateFlags,'#') => {
@@ -476,10 +476,10 @@ fn to_char(self) -> char {
     }
 }
 
-fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
+fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,~str> {
     let mut s = match val {
         Number(d) => {
-            let mut s = match (op, flags.sign) {
+            let s = match (op, flags.sign) {
                 (FormatDigit, true)  => format!("{:+d}", d).into_bytes(),
                 (FormatDigit, false) => format!("{:d}", d).into_bytes(),
                 (FormatOctal, _)     => format!("{:o}", d).into_bytes(),
@@ -487,8 +487,9 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
                 (FormatHEX, _)       => format!("{:X}", d).into_bytes(),
                 (FormatString, _)    => return Err(~"non-number on stack with %s"),
             };
+            let mut s: Vec<u8> = s.move_iter().collect();
             if flags.precision > s.len() {
-                let mut s_ = slice::with_capacity(flags.precision);
+                let mut s_ = Vec::with_capacity(flags.precision);
                 let n = flags.precision - s.len();
                 s_.grow(n, &('0' as u8));
                 s_.push_all_move(s);
@@ -497,25 +498,31 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
             assert!(!s.is_empty(), "string conversion produced empty result");
             match op {
                 FormatDigit => {
-                    if flags.space && !(s[0] == '-' as u8 || s[0] == '+' as u8) {
+                    if flags.space && !(*s.get(0) == '-' as u8 ||
+                                        *s.get(0) == '+' as u8) {
                         s.unshift(' ' as u8);
                     }
                 }
                 FormatOctal => {
-                    if flags.alternate && s[0] != '0' as u8 {
+                    if flags.alternate && *s.get(0) != '0' as u8 {
                         s.unshift('0' as u8);
                     }
                 }
                 FormatHex => {
                     if flags.alternate {
-                        let s_ = replace(&mut s, ~['0' as u8, 'x' as u8]);
+                        let s_ = replace(&mut s, vec!('0' as u8, 'x' as u8));
                         s.push_all_move(s_);
                     }
                 }
                 FormatHEX => {
-                    s = s.into_ascii().to_upper().into_bytes();
+                    s = s.as_slice()
+                         .to_ascii()
+                         .to_upper()
+                         .into_bytes()
+                         .move_iter()
+                         .collect();
                     if flags.alternate {
-                        let s_ = replace(&mut s, ~['0' as u8, 'X' as u8]);
+                        let s_ = replace(&mut s, vec!('0' as u8, 'X' as u8));
                         s.push_all_move(s_);
                     }
                 }
@@ -526,7 +533,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
         String(s) => {
             match op {
                 FormatString => {
-                    let mut s = s.as_bytes().to_owned();
+                    let mut s = Vec::from_slice(s.as_bytes());
                     if flags.precision > 0 && flags.precision < s.len() {
                         s.truncate(flags.precision);
                     }
@@ -543,7 +550,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
         if flags.left {
             s.grow(n, &(' ' as u8));
         } else {
-            let mut s_ = slice::with_capacity(flags.width);
+            let mut s_ = Vec::with_capacity(flags.width);
             s_.grow(n, &(' ' as u8));
             s_.push_all_move(s);
             s = s_;
@@ -556,18 +563,19 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
 mod test {
     use super::{expand,String,Variables,Number};
     use std::result::Ok;
+    use std::vec_ng;
 
     #[test]
     fn test_basic_setabf() {
         let s = bytes!("\\E[48;5;%p1%dm");
         assert_eq!(expand(s, [Number(1)], &mut Variables::new()).unwrap(),
-                   bytes!("\\E[48;5;1m").to_owned());
+                   bytes!("\\E[48;5;1m").iter().map(|x| *x).collect());
     }
 
     #[test]
     fn test_multiple_int_constants() {
         assert_eq!(expand(bytes!("%{1}%{2}%d%d"), [], &mut Variables::new()).unwrap(),
-                   bytes!("21").to_owned());
+                   bytes!("21").iter().map(|x| *x).collect());
     }
 
     #[test]
@@ -575,9 +583,9 @@ fn test_op_i() {
         let mut vars = Variables::new();
         assert_eq!(expand(bytes!("%p1%d%p2%d%p3%d%i%p1%d%p2%d%p3%d"),
                           [Number(1),Number(2),Number(3)], &mut vars),
-                   Ok(bytes!("123233").to_owned()));
+                   Ok(bytes!("123233").iter().map(|x| *x).collect()));
         assert_eq!(expand(bytes!("%p1%d%p2%d%i%p1%d%p2%d"), [], &mut vars),
-                   Ok(bytes!("0011").to_owned()));
+                   Ok(bytes!("0011").iter().map(|x| *x).collect()));
     }
 
     #[test]
@@ -590,7 +598,12 @@ fn test_param_stack_failure_conditions() {
             assert!(res.is_err(),
                     "Op {} succeeded incorrectly with 0 stack entries", *cap);
             let p = if *cap == "%s" || *cap == "%l" { String(~"foo") } else { Number(97) };
-            let res = expand((bytes!("%p1")).to_owned() + cap.as_bytes(), [p], vars);
+            let res = expand(vec::append(bytes!("%p1").iter()
+                                                         .map(|x| *x)
+                                                         .collect(),
+                                            cap.as_bytes()).as_slice(),
+                             [p],
+                             vars);
             assert!(res.is_ok(),
                     "Op {} failed with 1 stack entry: {}", *cap, res.unwrap_err());
         }
@@ -599,10 +612,20 @@ fn test_param_stack_failure_conditions() {
             let res = expand(cap.as_bytes(), [], vars);
             assert!(res.is_err(),
                     "Binop {} succeeded incorrectly with 0 stack entries", *cap);
-            let res = expand((bytes!("%{1}")).to_owned() + cap.as_bytes(), [], vars);
+            let res = expand(vec::append(bytes!("%{1}").iter()
+                                                          .map(|x| *x)
+                                                          .collect(),
+                                             cap.as_bytes()).as_slice(),
+                              [],
+                              vars);
             assert!(res.is_err(),
                     "Binop {} succeeded incorrectly with 1 stack entry", *cap);
-            let res = expand((bytes!("%{1}%{2}")).to_owned() + cap.as_bytes(), [], vars);
+            let res = expand(vec::append(bytes!("%{1}%{2}").iter()
+                                                              .map(|x| *x)
+                                                              .collect(),
+                                            cap.as_bytes()).as_slice(),
+                             [],
+                             vars);
             assert!(res.is_ok(),
                     "Binop {} failed with 2 stack entries: {}", *cap, res.unwrap_err());
         }
@@ -620,15 +643,15 @@ fn test_comparison_ops() {
             let s = format!("%\\{1\\}%\\{2\\}%{}%d", op);
             let res = expand(s.as_bytes(), [], &mut Variables::new());
             assert!(res.is_ok(), res.unwrap_err());
-            assert_eq!(res.unwrap(), ~['0' as u8 + bs[0]]);
+            assert_eq!(res.unwrap(), vec!('0' as u8 + bs[0]));
             let s = format!("%\\{1\\}%\\{1\\}%{}%d", op);
             let res = expand(s.as_bytes(), [], &mut Variables::new());
             assert!(res.is_ok(), res.unwrap_err());
-            assert_eq!(res.unwrap(), ~['0' as u8 + bs[1]]);
+            assert_eq!(res.unwrap(), vec!('0' as u8 + bs[1]));
             let s = format!("%\\{2\\}%\\{1\\}%{}%d", op);
             let res = expand(s.as_bytes(), [], &mut Variables::new());
             assert!(res.is_ok(), res.unwrap_err());
-            assert_eq!(res.unwrap(), ~['0' as u8 + bs[2]]);
+            assert_eq!(res.unwrap(), vec!('0' as u8 + bs[2]));
         }
     }
 
@@ -638,13 +661,16 @@ fn test_conditionals() {
         let s = bytes!("\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m");
         let res = expand(s, [Number(1)], &mut vars);
         assert!(res.is_ok(), res.unwrap_err());
-        assert_eq!(res.unwrap(), bytes!("\\E[31m").to_owned());
+        assert_eq!(res.unwrap(),
+                   bytes!("\\E[31m").iter().map(|x| *x).collect());
         let res = expand(s, [Number(8)], &mut vars);
         assert!(res.is_ok(), res.unwrap_err());
-        assert_eq!(res.unwrap(), bytes!("\\E[90m").to_owned());
+        assert_eq!(res.unwrap(),
+                   bytes!("\\E[90m").iter().map(|x| *x).collect());
         let res = expand(s, [Number(42)], &mut vars);
         assert!(res.is_ok(), res.unwrap_err());
-        assert_eq!(res.unwrap(), bytes!("\\E[38;5;42m").to_owned());
+        assert_eq!(res.unwrap(),
+                   bytes!("\\E[38;5;42m").iter().map(|x| *x).collect());
     }
 
     #[test]
@@ -653,13 +679,15 @@ fn test_format() {
         let vars = &mut varstruct;
         assert_eq!(expand(bytes!("%p1%s%p2%2s%p3%2s%p4%.2s"),
                           [String(~"foo"), String(~"foo"), String(~"f"), String(~"foo")], vars),
-                   Ok(bytes!("foofoo ffo").to_owned()));
+                   Ok(bytes!("foofoo ffo").iter().map(|x| *x).collect()));
         assert_eq!(expand(bytes!("%p1%:-4.2s"), [String(~"foo")], vars),
-                   Ok(bytes!("fo  ").to_owned()));
+                   Ok(bytes!("fo  ").iter().map(|x| *x).collect()));
 
         assert_eq!(expand(bytes!("%p1%d%p1%.3d%p1%5d%p1%:+d"), [Number(1)], vars),
-                   Ok(bytes!("1001    1+1").to_owned()));
+                   Ok(bytes!("1001    1+1").iter().map(|x| *x).collect()));
         assert_eq!(expand(bytes!("%p1%o%p1%#o%p2%6.4x%p2%#6.4X"), [Number(15), Number(27)], vars),
-                   Ok(bytes!("17017  001b0X001B").to_owned()));
+                   Ok(bytes!("17017  001b0X001B").iter()
+                                                 .map(|x| *x)
+                                                 .collect()));
     }
 }
index cc97e54709c81e70d835c06e533aa9e8c3fa2a72..e6a1dc70b7050558377ad02643da186773b3ad04 100644 (file)
 
 /// ncurses-compatible compiled terminfo format parsing (term(5))
 
-
-use std::{slice, str};
-use std::io;
 use collections::HashMap;
+use std::io;
+use std::str;
 use super::super::TermInfo;
 
 // These are the orders ncurses uses in its compiled format (as of 5.9). Not sure if portable.
@@ -213,7 +212,7 @@ macro_rules! try( ($e:expr) => (
         Some(s) => s, None => return Err(~"input not utf-8"),
     };
 
-    let term_names: ~[~str] = names_str.split('|').map(|s| s.to_owned()).collect();
+    let term_names: Vec<~str> = names_str.split('|').map(|s| s.to_owned()).collect();
 
     try!(file.read_byte()); // consume NUL
 
@@ -246,7 +245,7 @@ macro_rules! try( ($e:expr) => (
     let mut string_map = HashMap::new();
 
     if string_offsets_count != 0 {
-        let mut string_offsets = slice::with_capacity(10);
+        let mut string_offsets = Vec::with_capacity(10);
         for _ in range(0, string_offsets_count) {
             string_offsets.push(try!(file.read_le_u16()));
         }
@@ -272,7 +271,7 @@ macro_rules! try( ($e:expr) => (
             if offset == 0xFFFE {
                 // undocumented: FFFE indicates cap@, which means the capability is not present
                 // unsure if the handling for this is correct
-                string_map.insert(name.to_owned(), ~[]);
+                string_map.insert(name.to_owned(), Vec::new());
                 continue;
             }
 
@@ -283,8 +282,9 @@ macro_rules! try( ($e:expr) => (
             match nulpos {
                 Some(len) => {
                     string_map.insert(name.to_owned(),
-                                      string_table.slice(offset as uint,
-                                                         offset as uint + len).to_owned())
+                                      Vec::from_slice(
+                                          string_table.slice(offset as uint,
+                                          offset as uint + len)))
                 },
                 None => {
                     return Err(~"invalid file: missing NUL in string_table");
@@ -300,12 +300,12 @@ macro_rules! try( ($e:expr) => (
 /// Create a dummy TermInfo struct for msys terminals
 pub fn msys_terminfo() -> ~TermInfo {
     let mut strings = HashMap::new();
-    strings.insert(~"sgr0", bytes!("\x1b[0m").to_owned());
-    strings.insert(~"bold", bytes!("\x1b[1m").to_owned());
-    strings.insert(~"setaf", bytes!("\x1b[3%p1%dm").to_owned());
-    strings.insert(~"setab", bytes!("\x1b[4%p1%dm").to_owned());
+    strings.insert(~"sgr0", Vec::from_slice(bytes!("\x1b[0m")));
+    strings.insert(~"bold", Vec::from_slice(bytes!("\x1b[1m")));
+    strings.insert(~"setaf", Vec::from_slice(bytes!("\x1b[3%p1%dm")));
+    strings.insert(~"setab", Vec::from_slice(bytes!("\x1b[4%p1%dm")));
     ~TermInfo {
-        names: ~[~"cygwin"], // msys is a fork of an older cygwin version
+        names: vec!(~"cygwin"), // msys is a fork of an older cygwin version
         bools: HashMap::new(),
         numbers: HashMap::new(),
         strings: strings
index ef522da5e8c5f8ae5953604f1929554922695b8a..b29d7b2284e3334d1bd8a5b461c3f939c2929ca7 100644 (file)
@@ -23,7 +23,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
 
     let homedir = os::homedir();
 
-    let mut dirs_to_search = ~[];
+    let mut dirs_to_search = Vec::new();
     let first_char = term.char_at(0);
 
     // Find search directory
index ec7d48cf12bda0368f5e448c3478c4fe34c3bbb1..27f9a2174ced37b068b24df774f955e021fd5474 100644 (file)
@@ -203,7 +203,7 @@ pub enum MetricChange {
 
 // The default console test runner. It accepts the command line
 // arguments and a vector of test_descs.
-pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) {
+pub fn test_main(args: &[~str], tests: Vec<TestDescAndFn> ) {
     let opts =
         match parse_opts(args) {
             Some(Ok(o)) => o,
@@ -225,7 +225,7 @@ pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) {
 // semantics into parallel test runners, which in turn requires a ~[]
 // rather than a &[].
 pub fn test_main_static(args: &[~str], tests: &[TestDescAndFn]) {
-    let owned_tests = tests.map(|t| {
+    let owned_tests = tests.iter().map(|t| {
         match t.testfn {
             StaticTestFn(f) =>
             TestDescAndFn { testfn: StaticTestFn(f), desc: t.desc.clone() },
@@ -237,7 +237,7 @@ pub fn test_main_static(args: &[~str], tests: &[TestDescAndFn]) {
                 fail!("non-static tests passed to test::test_main_static");
             }
         }
-    });
+    }).collect();
     test_main(args, owned_tests)
 }
 
@@ -256,8 +256,8 @@ pub struct TestOpts {
 /// Result of parsing the options.
 pub type OptRes = Result<TestOpts, ~str>;
 
-fn optgroups() -> ~[getopts::OptGroup] {
-    ~[getopts::optflag("", "ignored", "Run ignored tests"),
+fn optgroups() -> Vec<getopts::OptGroup> {
+    vec!(getopts::optflag("", "ignored", "Run ignored tests"),
       getopts::optflag("", "test", "Run tests and not benchmarks"),
       getopts::optflag("", "bench", "Run benchmarks instead of tests"),
       getopts::optflag("h", "help", "Display this message (longer with --help)"),
@@ -273,12 +273,12 @@ fn optgroups() -> ~[getopts::OptGroup] {
       getopts::optopt("", "logfile", "Write logs to the specified file instead \
                           of stdout", "PATH"),
       getopts::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
-                     "A.B")]
+                     "A.B"))
 }
 
 fn usage(binary: &str, helpstr: &str) {
     let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
-    println!("{}", getopts::usage(message, optgroups()));
+    println!("{}", getopts::usage(message, optgroups().as_slice()));
     println!("");
     if helpstr == "help" {
         println!("{}", "\
@@ -308,7 +308,7 @@ fn usage(binary: &str, helpstr: &str) {
 pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
     let args_ = args.tail();
     let matches =
-        match getopts::getopts(args_, optgroups()) {
+        match getopts::getopts(args_, optgroups().as_slice()) {
           Ok(m) => m,
           Err(f) => return Some(Err(f.to_err_msg()))
         };
@@ -318,7 +318,7 @@ pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
 
     let filter =
         if matches.free.len() > 0 {
-            Some((matches).free[0].clone())
+            Some((*matches.free.get(0)).clone())
         } else {
             None
         };
@@ -408,7 +408,7 @@ struct ConsoleTestState<T> {
     ignored: uint,
     measured: uint,
     metrics: MetricMap,
-    failures: ~[(TestDesc, ~[u8])],
+    failures: Vec<(TestDesc, Vec<u8> )> ,
     max_name_len: uint, // number of columns to fill when aligning names
 }
 
@@ -433,7 +433,7 @@ pub fn new(opts: &TestOpts,
             ignored: 0u,
             measured: 0u,
             metrics: MetricMap::new(),
-            failures: ~[],
+            failures: Vec::new(),
             max_name_len: 0u,
         })
     }
@@ -547,14 +547,14 @@ pub fn write_log(&mut self, test: &TestDesc,
 
     pub fn write_failures(&mut self) -> io::IoResult<()> {
         try!(self.write_plain("\nfailures:\n"));
-        let mut failures = ~[];
+        let mut failures = Vec::new();
         let mut fail_out  = ~"";
         for &(ref f, ref stdout) in self.failures.iter() {
             failures.push(f.name.to_str());
             if stdout.len() > 0 {
                 fail_out.push_str(format!("---- {} stdout ----\n\t",
                                   f.name.to_str()));
-                let output = str::from_utf8_lossy(*stdout);
+                let output = str::from_utf8_lossy(stdout.as_slice());
                 fail_out.push_str(output.as_slice().replace("\n", "\n\t"));
                 fail_out.push_str("\n");
             }
@@ -565,7 +565,7 @@ pub fn write_failures(&mut self) -> io::IoResult<()> {
         }
 
         try!(self.write_plain("\nfailures:\n"));
-        failures.sort();
+        failures.as_mut_slice().sort();
         for name in failures.iter() {
             try!(self.write_plain(format!("    {}\n", name.to_str())));
         }
@@ -665,7 +665,7 @@ pub fn write_run_finish(&mut self,
 
 pub fn fmt_metrics(mm: &MetricMap) -> ~str {
     let MetricMap(ref mm) = *mm;
-    let v : ~[~str] = mm.iter()
+    let v : Vec<~str> = mm.iter()
         .map(|(k,v)| format!("{}: {} (+/- {})",
                           *k,
                           v.value as f64,
@@ -689,7 +689,7 @@ pub fn fmt_bench_samples(bs: &BenchSamples) -> ~str {
 
 // A simple console test runner
 pub fn run_tests_console(opts: &TestOpts,
-                         tests: ~[TestDescAndFn]) -> io::IoResult<bool> {
+                         tests: Vec<TestDescAndFn> ) -> io::IoResult<bool> {
     fn callback<T: Writer>(event: &TestEvent,
                            st: &mut ConsoleTestState<T>) -> io::IoResult<()> {
         match (*event).clone() {
@@ -779,7 +779,7 @@ fn should_sort_failures_before_printing_them() {
         measured: 0u,
         max_name_len: 10u,
         metrics: MetricMap::new(),
-        failures: ~[(test_b, ~[]), (test_a, ~[])]
+        failures: vec!((test_b, Vec::new()), (test_a, Vec::new()))
     };
 
     st.write_failures().unwrap();
@@ -797,18 +797,20 @@ fn should_sort_failures_before_printing_them() {
 
 #[deriving(Clone)]
 enum TestEvent {
-    TeFiltered(~[TestDesc]),
+    TeFiltered(Vec<TestDesc> ),
     TeWait(TestDesc, NamePadding),
-    TeResult(TestDesc, TestResult, ~[u8] /* stdout */),
+    TeResult(TestDesc, TestResult, Vec<u8> ),
 }
 
-pub type MonitorMsg = (TestDesc, TestResult, ~[u8] /* stdout */);
+pub type MonitorMsg = (TestDesc, TestResult, Vec<u8> );
 
 fn run_tests(opts: &TestOpts,
-             tests: ~[TestDescAndFn],
+             tests: Vec<TestDescAndFn> ,
              callback: |e: TestEvent| -> io::IoResult<()>) -> io::IoResult<()> {
     let filtered_tests = filter_tests(opts, tests);
-    let filtered_descs = filtered_tests.map(|t| t.desc.clone());
+    let filtered_descs = filtered_tests.iter()
+                                       .map(|t| t.desc.clone())
+                                       .collect();
 
     try!(callback(TeFiltered(filtered_descs)));
 
@@ -880,8 +882,7 @@ fn get_concurrency() -> uint {
 
 pub fn filter_tests(
     opts: &TestOpts,
-    tests: ~[TestDescAndFn]) -> ~[TestDescAndFn]
-{
+    tests: Vec<TestDescAndFn> ) -> Vec<TestDescAndFn> {
     let mut filtered = tests;
 
     // Remove tests that don't match the test filter
@@ -929,11 +930,12 @@ fn filter(test: TestDescAndFn) -> Option<TestDescAndFn> {
     // Shard the remaining tests, if sharding requested.
     match opts.test_shard {
         None => filtered,
-        Some((a,b)) =>
+        Some((a,b)) => {
             filtered.move_iter().enumerate()
             .filter(|&(i,_)| i % b == a)
             .map(|(_,t)| t)
-            .to_owned_vec()
+            .collect()
+        }
     }
 }
 
@@ -944,7 +946,7 @@ pub fn run_test(force_ignore: bool,
     let TestDescAndFn {desc, testfn} = test;
 
     if force_ignore || desc.ignore {
-        monitor_ch.send((desc, TrIgnored, ~[]));
+        monitor_ch.send((desc, TrIgnored, Vec::new()));
         return;
     }
 
@@ -965,7 +967,7 @@ fn run_test_inner(desc: TestDesc,
             let result_future = task.future_result();
             task.spawn(testfn);
 
-            let stdout = reader.read_to_end().unwrap();
+            let stdout = reader.read_to_end().unwrap().move_iter().collect();
             let task_result = result_future.recv();
             let test_result = calc_result(&desc, task_result.is_ok());
             monitor_ch.send((desc.clone(), test_result, stdout));
@@ -975,24 +977,24 @@ fn run_test_inner(desc: TestDesc,
     match testfn {
         DynBenchFn(bencher) => {
             let bs = ::bench::benchmark(|harness| bencher.run(harness));
-            monitor_ch.send((desc, TrBench(bs), ~[]));
+            monitor_ch.send((desc, TrBench(bs), Vec::new()));
             return;
         }
         StaticBenchFn(benchfn) => {
             let bs = ::bench::benchmark(|harness| benchfn(harness));
-            monitor_ch.send((desc, TrBench(bs), ~[]));
+            monitor_ch.send((desc, TrBench(bs), Vec::new()));
             return;
         }
         DynMetricFn(f) => {
             let mut mm = MetricMap::new();
             f(&mut mm);
-            monitor_ch.send((desc, TrMetrics(mm), ~[]));
+            monitor_ch.send((desc, TrMetrics(mm), Vec::new()));
             return;
         }
         StaticMetricFn(f) => {
             let mut mm = MetricMap::new();
             f(&mut mm);
-            monitor_ch.send((desc, TrMetrics(mm), ~[]));
+            monitor_ch.send((desc, TrMetrics(mm), Vec::new()));
             return;
         }
         DynTestFn(f) => run_test_inner(desc, monitor_ch, f),
@@ -1369,8 +1371,8 @@ fn f() { }
 
     #[test]
     fn first_free_arg_should_be_a_filter() {
-        let args = ~[~"progname", ~"filter"];
-        let opts = match parse_opts(args) {
+        let args = vec!(~"progname", ~"filter");
+        let opts = match parse_opts(args.as_slice()) {
             Some(Ok(o)) => o,
             _ => fail!("Malformed arg in first_free_arg_should_be_a_filter")
         };
@@ -1379,8 +1381,8 @@ fn first_free_arg_should_be_a_filter() {
 
     #[test]
     fn parse_ignored_flag() {
-        let args = ~[~"progname", ~"filter", ~"--ignored"];
-        let opts = match parse_opts(args) {
+        let args = vec!(~"progname", ~"filter", ~"--ignored");
+        let opts = match parse_opts(args.as_slice()) {
             Some(Ok(o)) => o,
             _ => fail!("Malformed arg in parse_ignored_flag")
         };
@@ -1404,7 +1406,7 @@ pub fn filter_for_ignored_option() {
             test_shard: None
         };
 
-        let tests = ~[
+        let tests = vec!(
             TestDescAndFn {
                 desc: TestDesc {
                     name: StaticTestName("1"),
@@ -1420,13 +1422,12 @@ pub fn filter_for_ignored_option() {
                     should_fail: false
                 },
                 testfn: DynTestFn(proc() {}),
-            },
-        ];
+            });
         let filtered = filter_tests(&opts, tests);
 
         assert_eq!(filtered.len(), 1);
-        assert_eq!(filtered[0].desc.name.to_str(), ~"1");
-        assert!(filtered[0].desc.ignore == false);
+        assert_eq!(filtered.get(0).desc.name.to_str(), ~"1");
+        assert!(filtered.get(0).desc.ignore == false);
     }
 
     #[test]
@@ -1444,16 +1445,16 @@ pub fn sort_tests() {
         };
 
         let names =
-            ~[~"sha1::test", ~"int::test_to_str", ~"int::test_pow",
+            vec!(~"sha1::test", ~"int::test_to_str", ~"int::test_pow",
              ~"test::do_not_run_ignored_tests",
              ~"test::ignored_tests_result_in_ignored",
              ~"test::first_free_arg_should_be_a_filter",
              ~"test::parse_ignored_flag", ~"test::filter_for_ignored_option",
-             ~"test::sort_tests"];
+             ~"test::sort_tests");
         let tests =
         {
             fn testfn() { }
-            let mut tests = ~[];
+            let mut tests = Vec::new();
             for name in names.iter() {
                 let test = TestDescAndFn {
                     desc: TestDesc {
@@ -1470,13 +1471,13 @@ fn testfn() { }
         let filtered = filter_tests(&opts, tests);
 
         let expected =
-            ~[~"int::test_pow", ~"int::test_to_str", ~"sha1::test",
+            vec!(~"int::test_pow", ~"int::test_to_str", ~"sha1::test",
               ~"test::do_not_run_ignored_tests",
               ~"test::filter_for_ignored_option",
               ~"test::first_free_arg_should_be_a_filter",
               ~"test::ignored_tests_result_in_ignored",
               ~"test::parse_ignored_flag",
-              ~"test::sort_tests"];
+              ~"test::sort_tests");
 
         for (a, b) in expected.iter().zip(filtered.iter()) {
             assert!(*a == b.desc.name.to_str());
index 2e4773fea249a7234d74dcac2651fd6d07ce5846..1cc2d4b8a711157fc014b45c62d6b56f29f2c999 100644 (file)
@@ -1044,7 +1044,7 @@ fn parse_type(ch: char, tm: &Tm) -> ~str {
         }
     }
 
-    let mut buf = ~[];
+    let mut buf = Vec::new();
 
     let mut rdr = BufReader::new(format.as_bytes());
     loop {
@@ -1063,7 +1063,7 @@ fn parse_type(ch: char, tm: &Tm) -> ~str {
         }
     }
 
-    str::from_utf8_owned(buf).unwrap()
+    str::from_utf8(buf.as_slice()).unwrap().to_str()
 }
 
 #[cfg(test)]
index d4a33d6782dd5531c60edd2fedafe22d59244674..75b5a8ffed637f9d643d04df4234000127ba91c5 100644 (file)
@@ -327,13 +327,13 @@ pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
     ///
     /// Example: `936DA01F9ABD4d9d80C702AF85C822A8`
     pub fn to_simple_str(&self) -> ~str {
-        let mut s: ~[u8] = slice::from_elem(32, 0u8);
+        let mut s: Vec<u8> = Vec::from_elem(32, 0u8);
         for i in range(0u, 16u) {
             let digit = format!("{:02x}", self.bytes[i] as uint);
-            s[i*2+0] = digit[0];
-            s[i*2+1] = digit[1];
+            *s.get_mut(i*2+0) = digit[0];
+            *s.get_mut(i*2+1) = digit[1];
         }
-        str::from_utf8_owned(s).unwrap()
+        str::from_utf8(s.as_slice()).unwrap().to_str()
     }
 
     /// Returns a string of hexadecimal digits, separated into groups with a hyphen.
@@ -397,17 +397,17 @@ pub fn parse_string(us: &str) -> Result<Uuid, ParseError> {
         }
 
         // Split string up by hyphens into groups
-        let hex_groups: ~[&str] = us.split_str("-").collect();
+        let hex_groups: Vec<&str> = us.split_str("-").collect();
 
         // Get the length of each group
-        let group_lens: ~[uint] = hex_groups.iter().map(|&v| v.len()).collect();
+        let group_lens: Vec<uint> = hex_groups.iter().map(|&v| v.len()).collect();
 
         // Ensure the group lengths are valid
         match group_lens.len() {
             // Single group, no hyphens
             1 => {
-                if group_lens[0] != 32 {
-                    return Err(ErrorInvalidLength(group_lens[0]));
+                if *group_lens.get(0) != 32 {
+                    return Err(ErrorInvalidLength(*group_lens.get(0)));
                 }
             },
             // Five groups, hyphens in between each
@@ -538,6 +538,7 @@ mod test {
                 Version5Sha1};
     use std::str;
     use std::io::MemWriter;
+    use std::vec_ng::Vec;
 
     #[test]
     fn test_nil() {
@@ -697,7 +698,10 @@ fn test_to_str_matching() {
         let hs = uuid1.to_hyphenated_str();
         let ss = uuid1.to_str();
 
-        let hsn = str::from_chars(hs.chars().filter(|&c| c != '-').collect::<~[char]>());
+        let hsn = str::from_chars(hs.chars()
+                                    .filter(|&c| c != '-')
+                                    .collect::<Vec<char>>()
+                                    .as_slice());
 
         assert!(hsn == ss);
     }
@@ -731,9 +735,9 @@ fn test_from_fields() {
         let d1: u32 = 0xa1a2a3a4;
         let d2: u16 = 0xb1b2;
         let d3: u16 = 0xc1c2;
-        let d4: ~[u8] = ~[0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8];
+        let d4: Vec<u8> = vec!(0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8);
 
-        let u = Uuid::from_fields(d1, d2, d3, d4);
+        let u = Uuid::from_fields(d1, d2, d3, d4.as_slice());
 
         let expected = ~"a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8";
         let result = u.to_simple_str();
@@ -742,10 +746,10 @@ fn test_from_fields() {
 
     #[test]
     fn test_from_bytes() {
-        let b = ~[ 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2,
-                   0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 ];
+        let b = vec!( 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2,
+                   0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 );
 
-        let u = Uuid::from_bytes(b).unwrap();
+        let u = Uuid::from_bytes(b.as_slice()).unwrap();
         let expected = ~"a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8";
 
         assert!(u.to_simple_str() == expected);
index a6d6372f88f2fff45eb8822edb979431786edeea..8258a668f46ef4c10eda750b50a105c16428e0c6 100644 (file)
@@ -9,6 +9,8 @@
 // except according to those terms.
 
 pub mod kitties {
+    use std::vec_ng::Vec;
+
     pub struct cat<U> {
         priv info : Vec<U> ,
         priv meows : uint,
index a9be1e62195ff9665904b52f60f03b769e77220b..8386a6f78c133d22276faee5aaf25f6875aacd5c 100644 (file)
@@ -11,6 +11,7 @@
 #[feature(managed_boxes)];
 
 use std::cell::RefCell;
+use std::vec_ng::Vec;
 
 pub struct Entry<A,B> {
     key: A,
index ac8d3181227d3d5bf5ad4ba7954c821e08c46575..191313263aa9b71ba9012793f366c4baebf27737 100644 (file)
 
 #[crate_id="cci_no_inline_lib"];
 
+use std::vec_ng::Vec;
+
 // same as cci_iter_lib, more-or-less, but not marked inline
 pub fn iter(v: Vec<uint> , f: |uint|) {
     let mut i = 0u;
     let n = v.len();
     while i < n {
-        f(v[i]);
+        f(*v.get(i));
         i += 1u;
     }
 }
index e4b8b9e166d46ace1a308ad3436df214034a0c44..6bea93e953beb75b947766269da6d213c7893f9f 100644 (file)
 extern crate collections;
 
 use std::cell::RefCell;
+use std::vec_ng::Vec;
 use collections::HashMap;
 
-pub type header_map = HashMap<~str, @RefCell<vec!(@~str)>>;
+pub type header_map = HashMap<~str, @RefCell<Vec<@~str>>>;
 
 // the unused ty param is necessary so this gets monomorphized
 pub fn request<T>(req: &header_map) {
-  let _x = (*((**req.get(&~"METHOD")).clone()).get()[0u]).clone();
+  let _x = (**((**req.get(&~"METHOD")).clone()).get().get(0)).clone();
 }
index 3323e56e8f4a96956bc3e678e4fee2ebb12449ea..57acf3a7a9141df2847f4bc998d067a2597b280b 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 pub unsafe fn f(xs: Vec<int> ) {
     xs.map(|_x| { unsafe fn q() { fail!(); } });
 }
index edac363eb1af7234b06fb08f6917d0ea1e529dd9..d0655a43d158984afa05d96852cc27d34066d0e8 100644 (file)
@@ -20,7 +20,6 @@
 use std::mem::swap;
 use std::os;
 use std::str;
-use std::slice;
 use std::vec;
 use std::io::File;
 
@@ -89,11 +88,11 @@ fn vec_plus() {
     let mut v = Vec::new();
     let mut i = 0;
     while i < 1500 {
-        let rv = slice::from_elem(r.gen_range(0u, i + 1), i);
+        let rv = Vec::from_elem(r.gen_range(0u, i + 1), i);
         if r.gen() {
             v.push_all_move(rv);
         } else {
-            v = rv + v;
+            v = vec::append(rv.clone(), v.as_slice());
         }
         i += 1;
     }
@@ -105,12 +104,12 @@ fn vec_append() {
     let mut v = Vec::new();
     let mut i = 0;
     while i < 1500 {
-        let rv = slice::from_elem(r.gen_range(0u, i + 1), i);
+        let rv = Vec::from_elem(r.gen_range(0u, i + 1), i);
         if r.gen() {
-            v = vec::append(v, rv);
+            v = vec::append(v.clone(), rv.as_slice());
         }
         else {
-            v = vec::append(rv, v);
+            v = vec::append(rv.clone(), v.as_slice());
         }
         i += 1;
     }
@@ -121,13 +120,13 @@ fn vec_push_all() {
 
     let mut v = Vec::new();
     for i in range(0u, 1500) {
-        let mut rv = slice::from_elem(r.gen_range(0u, i + 1), i);
+        let mut rv = Vec::from_elem(r.gen_range(0u, i + 1), i);
         if r.gen() {
-            v.push_all(rv);
+            v.push_all(rv.as_slice());
         }
         else {
             swap(&mut v, &mut rv);
-            v.push_all(rv);
+            v.push_all(rv.as_slice());
         }
     }
 }
@@ -136,7 +135,7 @@ fn is_utf8_ascii() {
     let mut v : Vec<u8> = Vec::new();
     for _ in range(0u, 20000) {
         v.push('b' as u8);
-        if !str::is_utf8(v) {
+        if !str::is_utf8(v.as_slice()) {
             fail!("is_utf8 failed");
         }
     }
@@ -147,7 +146,7 @@ fn is_utf8_multibyte() {
     let mut v : Vec<u8> = Vec::new();
     for _ in range(0u, 5000) {
         v.push_all(s.as_bytes());
-        if !str::is_utf8(v) {
+        if !str::is_utf8(v.as_slice()) {
             fail!("is_utf8 failed");
         }
     }
index 07571b17905cf040f7056fbd15031ee047858944..f556617228732334146ca02b353e4125607584cd 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::os;
 use std::uint;
+use std::vec_ng::Vec;
 
 fn main() {
     let args = os::args();
@@ -18,10 +19,10 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"100000")
     } else {
-        args
+        args.move_iter().collect()
     };
 
-    let n = from_str::<uint>(args[1]).unwrap();
+    let n = from_str::<uint>(*args.get(1)).unwrap();
 
     for i in range(0u, n) {
         let x = i.to_str();
index ea07320dd94210811d54808bccad6b1a7d5a57d1..ff7ef27e1b993df207f7fa70f829c26885d4fdf9 100644 (file)
@@ -24,6 +24,7 @@
 use std::os;
 use std::task;
 use std::uint;
+use std::vec_ng::Vec;
 
 fn move_out<T>(_x: T) {}
 
@@ -100,9 +101,9 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"10000", ~"4")
     } else {
-        args.clone()
+        args.clone().move_iter().collect()
     };
 
     println!("{:?}", args);
-    run(args);
+    run(args.as_slice());
 }
index 7e2c5ba46b20a01ae9cb712d7b745354b09fdc15..0f0cb9c59d53f40c6d54a82cfa65c1ce54b385a0 100644 (file)
@@ -19,6 +19,7 @@
 use std::os;
 use std::task;
 use std::uint;
+use std::vec_ng::Vec;
 
 fn move_out<T>(_x: T) {}
 
@@ -110,9 +111,9 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"10000", ~"4")
     } else {
-        args.clone()
+        args.clone().move_iter().collect()
     };
 
     println!("{:?}", args);
-    run(args);
+    run(args.as_slice());
 }
index 7cd904d7d1473860b5850a3983d049b4734835d1..a0758624042423da03a0b3959c2da2770f08f5e5 100644 (file)
@@ -23,6 +23,7 @@
 use sync::Future;
 use std::os;
 use std::uint;
+use std::vec_ng::Vec;
 
 // A poor man's pipe.
 type pipe = MutexArc<Vec<uint> >;
@@ -75,11 +76,11 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"10", ~"100")
     } else {
-        args.clone()
+        args.clone().move_iter().collect()
     };
 
-    let num_tasks = from_str::<uint>(args[1]).unwrap();
-    let msg_per_task = from_str::<uint>(args[2]).unwrap();
+    let num_tasks = from_str::<uint>(*args.get(1)).unwrap();
+    let msg_per_task = from_str::<uint>(*args.get(2)).unwrap();
 
     let (mut num_chan, num_port) = init();
 
index c615c510465e6783858df0c8f1d36b20388248db..de5dff89bada7fe77666e84d6564ecda68b662fe 100644 (file)
@@ -22,6 +22,7 @@
 use sync::Future;
 use std::os;
 use std::uint;
+use std::vec_ng::Vec;
 
 // A poor man's pipe.
 type pipe = RWArc<Vec<uint> >;
@@ -70,11 +71,11 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"10", ~"100")
     } else {
-        args.clone()
+        args.clone().move_iter().collect()
     };
 
-    let num_tasks = from_str::<uint>(args[1]).unwrap();
-    let msg_per_task = from_str::<uint>(args[2]).unwrap();
+    let num_tasks = from_str::<uint>(*args.get(1)).unwrap();
+    let msg_per_task = from_str::<uint>(*args.get(2)).unwrap();
 
     let (mut num_chan, num_port) = init();
 
index 00075415f499d2ff376762d31d438db3e76b4a58..72df2e7b86f09fa6eb1120ae244313175dbc6649 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::os;
+use std::vec_ng::Vec;
 
 fn ack(m: int, n: int) -> int {
     if m == 0 {
@@ -29,8 +30,8 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"8")
     } else {
-        args
+        args.move_iter().collect()
     };
-    let n = from_str::<int>(args[1]).unwrap();
+    let n = from_str::<int>(*args.get(1)).unwrap();
     println!("Ack(3,{}): {}\n", n, ack(3, n));
 }
index c4671b4203f36ab495997fd708f091a63d8d0d88..29513d87153f74dd8d317c968009b07ff36129fc 100644 (file)
@@ -13,6 +13,7 @@
 use std::option;
 use std::os;
 use std::task;
+use std::vec_ng::Vec;
 
 fn print_complements() {
     let all = [Blue, Red, Yellow];
@@ -39,7 +40,7 @@ fn show_color(cc: color) -> ~str {
     }
 }
 
-fn show_color_list(set: vec!(color)) -> ~str {
+fn show_color_list(set: Vec<color>) -> ~str {
     let mut out = ~"";
     for col in set.iter() {
         out.push_char(' ');
@@ -132,7 +133,7 @@ fn creature(
     }
 }
 
-fn rendezvous(nn: uint, set: vec!(color)) {
+fn rendezvous(nn: uint, set: Vec<color>) {
 
     // these ports will allow us to hear from the creatures
     let (to_rendezvous, from_creatures) = channel::<CreatureInfo>();
@@ -141,7 +142,7 @@ fn rendezvous(nn: uint, set: vec!(color)) {
     // these channels will be passed to the creatures so they can talk to us
 
     // these channels will allow us to talk to each creature by 'name'/index
-    let to_creature: Vec<Sender<Option<CreatureInfo>>> =
+    let mut to_creature: Vec<Sender<Option<CreatureInfo>>> =
         set.iter().enumerate().map(|(ii, col)| {
             // create each creature as a listener with a port, and
             // give us a channel to talk to each
@@ -164,13 +165,13 @@ fn rendezvous(nn: uint, set: vec!(color)) {
 
     // set up meetings...
     for _ in range(0, nn) {
-        let fst_creature: CreatureInfo = from_creatures.recv();
-        let snd_creature: CreatureInfo = from_creatures.recv();
+        let mut fst_creature: CreatureInfo = from_creatures.recv();
+        let mut snd_creature: CreatureInfo = from_creatures.recv();
 
         creatures_met += 2;
 
-        to_creature[fst_creature.name].send(Some(snd_creature));
-        to_creature[snd_creature.name].send(Some(fst_creature));
+        to_creature.get_mut(fst_creature.name).send(Some(snd_creature));
+        to_creature.get_mut(snd_creature.name).send(Some(fst_creature));
     }
 
     // tell each creature to stop
@@ -203,10 +204,10 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"600")
     } else {
-        args
+        args.move_iter().collect()
     };
 
-    let nn = from_str::<uint>(args[1]).unwrap();
+    let nn = from_str::<uint>(*args.get(1)).unwrap();
 
     print_complements();
     println!("");
index a21963ee0a9a93e99e3bf624083f29f4b7d5f7cf..f05f80a20d78948e0054d00a0fcd800006d7205e 100644 (file)
@@ -68,7 +68,8 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> {
         a_i.p = p * LOOKUP_SCALE;
         result.push(a_i);
     }
-    result[result.len() - 1].p = LOOKUP_SCALE;
+    let result_len = result.len();
+    result.get_mut(result_len - 1).p = LOOKUP_SCALE;
     result
 }
 
@@ -193,12 +194,12 @@ fn main() {
 
     out.write_line(">TWO IUB ambiguity codes").unwrap();
     let iub = sum_and_scale(IUB);
-    let mut random = RandomFasta::new(&mut out, iub);
+    let mut random = RandomFasta::new(&mut out, iub.as_slice());
     random.make(n * 3).unwrap();
 
     random.out.write_line(">THREE Homo sapiens frequency").unwrap();
     let homo_sapiens = sum_and_scale(HOMO_SAPIENS);
-    random.lookup = make_lookup(homo_sapiens);
+    random.lookup = make_lookup(homo_sapiens.as_slice());
     random.make(n * 5).unwrap();
 
     random.out.write_str("\n").unwrap();
index 76ac8407d60c57a77fb1332d2334445e6f219c40..017099bbafacdc6ad3a3699a671e87dea212a56b 100644 (file)
@@ -18,6 +18,7 @@
 use std::io::{BufferedWriter, File};
 use std::cmp::min;
 use std::os;
+use std::vec_ng::Vec;
 
 static LINE_LENGTH: uint = 60;
 static IM: u32 = 139968;
index eec54198c04700f09a88edabaf3394cf10637d00..a363d19b3282f1ce1eecd1fe01baa60c18c82f0d 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::os;
+use std::vec_ng::Vec;
 
 fn fib(n: int) -> int {
     if n < 2 {
@@ -25,8 +26,8 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"30")
     } else {
-        args
+        args.move_iter().collect()
     };
-    let n = from_str::<int>(args[1]).unwrap();
+    let n = from_str::<int>(*args.get(1)).unwrap();
     println!("{}\n", fib(n));
 }
index 1b1a41e610c2c560cdf0f8b425b56e6d066d764a..fd5e5ca2eed53b08efda0d5abfe683b253890645 100644 (file)
@@ -68,7 +68,10 @@ fn sortKV(mut orig: Vec<(Vec<u8> ,f64)> ) -> Vec<(Vec<u8> ,f64)> {
    for &(ref k, v) in pairs_sorted.iter() {
        unsafe {
            buffer.push_str(format!("{} {:0.3f}\n",
-                                   k.to_ascii().to_upper().into_str(), v));
+                                   k.as_slice()
+                                    .to_ascii()
+                                    .to_upper()
+                                    .into_str(), v));
        }
    }
 
@@ -86,7 +89,7 @@ fn find(mm: &HashMap<Vec<u8> , uint>, key: ~str) -> uint {
 
 // given a map, increment the counter for a key
 fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) {
-    let key = key.to_owned();
+    let key = Vec::from_slice(key);
     let newval = match mm.pop(&key) {
         Some(v) => v + 1,
         None => 1
@@ -94,7 +97,7 @@ fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) {
     mm.insert(key, newval);
 }
 
-// given a ~[u8], for each window call a function
+// given a Vec<u8>, for each window call a function
 // i.e., for "hello" and windows of size four,
 // run it("hell") and it("ello"), then return "llo"
 fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec<u8> {
@@ -106,7 +109,7 @@ fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec<u8> {
       ii += 1u;
    }
 
-   return bb.slice(len - (nn - 1u), len).to_owned();
+   return Vec::from_slice(bb.slice(len - (nn - 1u), len));
 }
 
 fn make_sequence_processor(sz: uint,
@@ -116,14 +119,17 @@ fn make_sequence_processor(sz: uint,
    let mut carry = Vec::new();
    let mut total: uint = 0u;
 
-   let mut line: Vec<u8> ;
+   let mut line: Vec<u8>;
 
    loop {
 
       line = from_parent.recv();
       if line == Vec::new() { break; }
 
-       carry = windows_with_carry(carry + line, sz, |window| {
+       carry = windows_with_carry(vec::append(carry,
+                                                 line.as_slice()).as_slice(),
+                                  sz,
+                                  |window| {
          update_freq(&mut freqs, window);
          total += 1u;
       });
@@ -203,8 +209,8 @@ fn main() {
                let line_bytes = line.as_bytes();
 
                for (ii, _sz) in sizes.iter().enumerate() {
-                   let lb = line_bytes.to_owned();
-                   to_child[ii].send(lb);
+                   let lb = Vec::from_slice(line_bytes);
+                   to_child.get(ii).send(lb);
                }
            }
 
@@ -215,11 +221,11 @@ fn main() {
 
    // finish...
    for (ii, _sz) in sizes.iter().enumerate() {
-       to_child[ii].send(Vec::new());
+       to_child.get(ii).send(Vec::new());
    }
 
    // now fetch and print result messages
    for (ii, _sz) in sizes.iter().enumerate() {
-       println!("{}", from_child[ii].recv());
+       println!("{}", from_child.get(ii).recv());
    }
 }
index d2cf4599df2d4500dd5c07b8b67c1bef7369b9a8..1b9d0e03431454ff32c4ebdb64b1ab27d93a39c6 100644 (file)
@@ -57,7 +57,7 @@ fn unpack(&self, frame: i32) -> ~str {
         }
 
         result.reverse();
-        str::from_utf8_owned(result).unwrap()
+        str::from_utf8_owned(result.move_iter().collect()).unwrap()
     }
 }
 
@@ -103,7 +103,7 @@ impl Table {
     fn new() -> Table {
         Table {
             count: 0,
-            items: slice::from_fn(TABLE_SIZE, |_| None),
+            items: Vec::from_fn(TABLE_SIZE, |_| None),
         }
     }
 
@@ -133,20 +133,20 @@ fn lookup<C:TableCallback>(&mut self, key: Code, c: C) {
         let index = key.hash() % (TABLE_SIZE as u64);
 
         {
-            if self.items[index].is_none() {
+            if self.items.get(index as uint).is_none() {
                 let mut entry = ~Entry {
                     code: key,
                     count: 0,
                     next: None,
                 };
                 c.f(entry);
-                self.items[index] = Some(entry);
+                *self.items.get_mut(index as uint) = Some(entry);
                 return;
             }
         }
 
         {
-            let entry = &mut *self.items[index].get_mut_ref();
+            let entry = &mut *self.items.get_mut(index as uint).get_mut_ref();
             if entry.code == key {
                 c.f(*entry);
                 return;
@@ -240,7 +240,7 @@ fn print_frequencies(frequencies: &Table, frame: i32) {
     for entry in frequencies.iter() {
         vector.push((entry.code, entry.count));
     }
-    vector.sort();
+    vector.as_mut_slice().sort();
 
     let mut total_count = 0;
     for &(_, count) in vector.iter() {
index 81b712cf9c6a7dd8df7f74942e291b096861c21b..fbe19af27fd90d2e2b6d18820c7056ddb6153a63 100644 (file)
@@ -12,6 +12,8 @@
 // Utilities.
 //
 
+use std::vec_ng::Vec;
+
 // returns an infinite iterator of repeated applications of f to x,
 // i.e. [x, f(x), f(f(x)), ...], as haskell iterate function.
 fn iterate<'a, T>(x: T, f: 'a |&T| -> T) -> Iterate<'a, T> {
@@ -63,8 +65,8 @@ fn next(&mut self) -> Option<&'a T> {
 // corresponding mirrored piece), with, as minimum coordinates, (0,
 // 0).  If all is false, only generate half of the possibilities (used
 // to break the symetry of the board).
-fn transform(piece: Vec<(int, int)> , all: bool) -> vec!(Vec<(int, int)> ) {
-    let mut res =
+fn transform(piece: Vec<(int, int)> , all: bool) -> Vec<Vec<(int, int)>> {
+    let mut res: Vec<Vec<(int, int)>> =
         // rotations
         iterate(piece, |rot| rot.iter().map(|&(y, x)| (x + y, -y)).collect())
         .take(if all {6} else {3})
@@ -72,7 +74,7 @@ fn transform(piece: Vec<(int, int)> , all: bool) -> vec!(Vec<(int, int)> ) {
         .flat_map(|cur_piece| {
             iterate(cur_piece, |mir| mir.iter().map(|&(y, x)| (x, y)).collect())
             .take(2)
-        }).to_owned_vec();
+        }).collect();
 
     // translating to (0, 0) as minimum coordinates.
     for cur_piece in res.mut_iter() {
@@ -130,7 +132,7 @@ fn make_masks() -> Vec<Vec<Vec<u64> > > {
             for dx in range(0, 5) {
                 let masks =
                     trans.iter()
-                    .filter_map(|t| mask(dy, dx, id, *t))
+                    .filter_map(|t| mask(dy, dx, id, t.as_slice()))
                     .collect();
                 cur_piece.push(masks);
             }
@@ -147,7 +149,7 @@ fn is_board_unfeasible(board: u64, masks: &[Vec<Vec<u64> > ]) -> bool {
     for i in range(0, 50).filter(|&i| board & 1 << i == 0) {
         for (cur_id, pos_masks) in masks.iter().enumerate() {
             if board & 1 << (50 + cur_id) != 0 {continue;}
-            for &cur_m in pos_masks[i].iter() {
+            for &cur_m in pos_masks.get(i as uint).iter() {
                 if cur_m & board == 0 {coverable |= cur_m;}
             }
         }
@@ -184,10 +186,12 @@ fn to_utf8(raw_sol: &List<u64>) -> ~str {
     for &m in raw_sol.iter() {
         let id = get_id(m);
         for i in range(0, 50) {
-            if m & 1 << i != 0 {sol[i] = '0' as u8 + id;}
+            if m & 1 << i != 0 {
+                *sol.get_mut(i as uint) = '0' as u8 + id;
+            }
         }
     }
-    std::str::from_utf8_owned(sol).unwrap()
+    std::str::from_utf8_owned(sol.move_iter().collect()).unwrap()
 }
 
 // Prints a solution in ~str form.
@@ -252,7 +256,9 @@ fn search(
     // for every unused piece
     for id in range(0, 10).filter(|id| board & (1 << (id + 50)) == 0) {
         // for each mask that fits on the board
-        for &m in masks[id][i].iter().filter(|&m| board & *m == 0) {
+        for &m in masks[id].get(i as uint)
+                           .iter()
+                           .filter(|&m| board & *m == 0) {
             // This check is too costy.
             //if is_board_unfeasible(board | m, masks) {continue;}
             if !search(masks, board | m, i + 1, Cons(m, &cur), data) {
@@ -271,9 +277,9 @@ fn main () {
         from_str(args[1]).unwrap()
     };
     let masks = make_masks();
-    let masks = filter_masks(masks);
+    let masks = filter_masks(masks.as_slice());
     let mut data = Data {stop_after: stop_after, nb: 0, min: ~"", max: ~""};
-    search(masks, 0, 0, Nil, &mut data);
+    search(masks.as_slice(), 0, 0, Nil, &mut data);
     println!("{} solutions found", data.nb);
     print_sol(data.min);
     print_sol(data.max);
index 72ae6c4d0146332077055d57625c7d70ed9bfb21..b4c96a48ded75665a1ec265b8abdd1d2ee3909ad 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::os;
+use std::vec_ng::Vec;
 
 static PI: f64 = 3.141592653589793;
 static SOLAR_MASS: f64 = 4.0 * PI * PI;
@@ -152,10 +153,10 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"1000")
     } else {
-        args
+        args.move_iter().collect()
     };
 
-    let n: i32 = from_str::<i32>(args[1]).unwrap();
+    let n: i32 = from_str::<i32>(*args.get(1)).unwrap();
     let mut bodies = BODIES;
 
     offset_momentum(&mut bodies);
index 6c3b75ef473a9ede269fb5c4c1c7550fc9d45488..2fbc544a8a93f06650ac067e833027c9458d14e8 100644 (file)
@@ -25,6 +25,7 @@
 use std::result::{Ok, Err};
 use std::task;
 use std::uint;
+use std::vec_ng::Vec;
 
 fn fib(n: int) -> int {
     fn pfib(tx: &Sender<int>, n: int) {
@@ -56,7 +57,7 @@ fn parse_opts(argv: Vec<~str> ) -> Config {
 
     let opt_args = argv.slice(1, argv.len());
 
-    match getopts::getopts(opt_args, opts) {
+    match getopts::getopts(opt_args, opts.as_slice()) {
       Ok(ref m) => {
           return Config {stress: m.opt_present("stress")}
       }
@@ -95,7 +96,7 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"8")
     } else {
-        args
+        args.move_iter().collect()
     };
 
     let opts = parse_opts(args.clone());
@@ -103,7 +104,8 @@ fn main() {
     if opts.stress {
         stress(2);
     } else {
-        let max = uint::parse_bytes(args[1].as_bytes(), 10u).unwrap() as int;
+        let max = uint::parse_bytes(args.get(1).as_bytes(), 10u).unwrap() as
+            int;
 
         let num_trials = 10;
 
index cfb950090a2cf78acadb7d6c97c47050b0168960..7ee294b8e632a750654990299404f00eaa82b476 100644 (file)
@@ -56,18 +56,17 @@ fn main() {
 
     let args = if os::getenv("RUST_BENCH").is_some() {
         vec!(~"", ~"2000000", ~"503")
-    }
-    else {
-        os::args()
+    } else {
+        os::args().move_iter().collect()
     };
     let token = if args.len() > 1u {
-        FromStr::from_str(args[1]).unwrap()
+        FromStr::from_str(*args.get(1)).unwrap()
     }
     else {
         1000
     };
     let n_tasks = if args.len() > 2u {
-        FromStr::from_str(args[2]).unwrap()
+        FromStr::from_str(*args.get(2)).unwrap()
     }
     else {
         503
index 674b6a8b36a2468b937534cc42d9fc382313edee..7bafdd81b7cc7210cf60c13606ce0383a7eec814 100644 (file)
@@ -16,6 +16,7 @@
 use collections::SmallIntMap;
 use std::os;
 use std::uint;
+use std::vec_ng::Vec;
 
 fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap<uint>) {
     for i in range(min, max) {
@@ -36,10 +37,10 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"10000", ~"50")
     } else {
-        args
+        args.move_iter().collect()
     };
-    let max = from_str::<uint>(args[1]).unwrap();
-    let rep = from_str::<uint>(args[2]).unwrap();
+    let max = from_str::<uint>(*args.get(1)).unwrap();
+    let rep = from_str::<uint>(*args.get(2)).unwrap();
 
     let mut checkf = 0.0;
     let mut appendf = 0.0;
index 79eee4006ceed3c80b0ff170cfb81b2eb556aab7..d41a19c60a169ab52f11a5eecbe8a61ceba4c905 100644 (file)
@@ -17,7 +17,6 @@
 use std::io::BufferedReader;
 use std::os;
 use std::intrinsics::cttz16;
-use std::slice;
 
 // Computes a single solution to a given 9x9 sudoku
 //
@@ -48,8 +47,8 @@ pub fn new(g: grid) -> Sudoku {
     }
 
     pub fn from_vec(vec: &[[u8, ..9], ..9]) -> Sudoku {
-        let g = slice::from_fn(9u, |i| {
-            slice::from_fn(9u, |j| { vec[i][j] })
+        let g = Vec::from_fn(9u, |i| {
+            Vec::from_fn(9u, |j| { vec[i][j] })
         });
         return Sudoku::new(g)
     }
@@ -57,7 +56,8 @@ pub fn from_vec(vec: &[[u8, ..9], ..9]) -> Sudoku {
     pub fn equal(&self, other: &Sudoku) -> bool {
         for row in range(0u8, 9u8) {
             for col in range(0u8, 9u8) {
-                if self.grid[row][col] != other.grid[row][col] {
+                if *self.grid.get(row as uint).get(col as uint) !=
+                        *other.grid.get(row as uint).get(col as uint) {
                     return false;
                 }
             }
@@ -68,14 +68,15 @@ pub fn equal(&self, other: &Sudoku) -> bool {
     pub fn read(mut reader: BufferedReader<StdReader>) -> Sudoku {
         assert!(reader.read_line().unwrap() == ~"9,9"); /* assert first line is exactly "9,9" */
 
-        let mut g = slice::from_fn(10u, { |_i| vec!(0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8) });
+        let mut g = Vec::from_fn(10u, { |_i| vec!(0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8) });
         for line in reader.lines() {
             let comps: Vec<&str> = line.trim().split(',').collect();
 
             if comps.len() == 3u {
-                let row     = from_str::<uint>(comps[0]).unwrap() as u8;
-                let col     = from_str::<uint>(comps[1]).unwrap() as u8;
-                g[row][col] = from_str::<uint>(comps[2]).unwrap() as u8;
+                let row     = from_str::<uint>(*comps.get(0)).unwrap() as u8;
+                let col     = from_str::<uint>(*comps.get(1)).unwrap() as u8;
+                *g.get_mut(row as uint).get_mut(col as uint) =
+                    from_str::<uint>(*comps.get(2)).unwrap() as u8;
             }
             else {
                 fail!("Invalid sudoku file");
@@ -86,9 +87,11 @@ pub fn read(mut reader: BufferedReader<StdReader>) -> Sudoku {
 
     pub fn write(&self, writer: &mut io::Writer) {
         for row in range(0u8, 9u8) {
-            write!(writer, "{}", self.grid[row][0]);
+            write!(writer, "{}", *self.grid.get(row as uint).get(0));
             for col in range(1u8, 9u8) {
-                write!(writer, " {}", self.grid[row][col]);
+                write!(writer, " {}", *self.grid
+                                           .get(row as uint)
+                                           .get(col as uint));
             }
             write!(writer, "\n");
          }
@@ -99,7 +102,7 @@ pub fn solve(&mut self) {
         let mut work: Vec<(u8, u8)> = Vec::new(); /* queue of uncolored fields */
         for row in range(0u8, 9u8) {
             for col in range(0u8, 9u8) {
-                let color = self.grid[row][col];
+                let color = *self.grid.get(row as uint).get(col as uint);
                 if color == 0u8 {
                     work.push((row, col));
                 }
@@ -109,9 +112,11 @@ pub fn solve(&mut self) {
         let mut ptr = 0u;
         let end = work.len();
         while ptr < end {
-            let (row, col) = work[ptr];
+            let (row, col) = *work.get(ptr);
             // is there another color to try?
-            if self.next_color(row, col, self.grid[row][col] + (1 as u8)) {
+            let the_color = *self.grid.get(row as uint).get(col as uint) +
+                                (1 as u8);
+            if self.next_color(row, col, the_color) {
                 //  yes: advance work list
                 ptr = ptr + 1u;
             } else {
@@ -132,18 +137,22 @@ fn next_color(&mut self, row: u8, col: u8, start_color: u8) -> bool {
 
             // find first remaining color that is available
             let next = avail.next();
-            self.grid[row][col] = next;
+            *self.grid.get_mut(row as uint).get_mut(col as uint) = next;
             return 0u8 != next;
         }
-        self.grid[row][col] = 0u8;
+        *self.grid.get_mut(row as uint).get_mut(col as uint) = 0u8;
         return false;
     }
 
     // find colors available in neighbourhood of (row, col)
     fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) {
         for idx in range(0u8, 9u8) {
-            avail.remove(self.grid[idx][col]); /* check same column fields */
-            avail.remove(self.grid[row][idx]); /* check same row fields */
+            avail.remove(*self.grid
+                              .get(idx as uint)
+                              .get(col as uint)); /* check same column fields */
+            avail.remove(*self.grid
+                              .get(row as uint)
+                              .get(idx as uint)); /* check same row fields */
         }
 
         // check same block fields
@@ -151,7 +160,9 @@ fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) {
         let col0 = (col / 3u8) * 3u8;
         for alt_row in range(row0, row0 + 3u8) {
             for alt_col in range(col0, col0 + 3u8) {
-                avail.remove(self.grid[alt_row][alt_col]);
+                avail.remove(*self.grid
+                                  .get(alt_row as uint)
+                                  .get(alt_col as uint));
             }
         }
     }
index 1a33391a3d2e98fdacd264124f951729052cb4fa..4c8379ee05962e6c57539a7c3c7952f5b680ad3a 100644 (file)
@@ -17,6 +17,8 @@
 use time::precise_time_s;
 use std::os;
 use std::task;
+use std::vec_ng::Vec;
+use std::vec_ng;
 
 enum UniqueList {
     ULNil, ULCons(~UniqueList)
@@ -50,7 +52,7 @@ struct State {
     managed: @nillist,
     unique: ~nillist,
     tuple: (@nillist, ~nillist),
-    vec: vec!(@nillist),
+    vec: Vec<@nillist>,
     res: r
 }
 
@@ -92,7 +94,8 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
                 unique: ~Cons((), @*st.unique),
                 tuple: (@Cons((), st.tuple.ref0().clone()),
                         ~Cons((), @*st.tuple.ref1().clone())),
-                vec: st.vec + &[@Cons((), *st.vec.last().unwrap())],
+                vec: vec::append(st.vec.clone(),
+                     &[@Cons((), *st.vec.last().unwrap())]),
                 res: r(@Cons((), st.res._l))
             }
           }
index 9a57be54362cf6aca0d5d922e64b0e96b0de4f71..0199798273e54e8813eab6f994719710f98d9618 100644 (file)
@@ -21,6 +21,7 @@
 use std::os;
 use std::task;
 use std::uint;
+use std::vec_ng::Vec;
 
 fn child_generation(gens_left: uint, tx: comm::Sender<()>) {
     // This used to be O(n^2) in the number of generations that ever existed.
@@ -45,11 +46,11 @@ fn main() {
     } else if args.len() <= 1 {
         vec!(~"", ~"100")
     } else {
-        args.clone()
+        args.clone().move_iter().collect()
     };
 
     let (tx, rx) = channel();
-    child_generation(from_str::<uint>(args[1]).unwrap(), tx);
+    child_generation(from_str::<uint>(*args.get(1)).unwrap(), tx);
     if rx.recv_opt().is_none() {
         fail!("it happened when we slumbered");
     }
index 3a45e88b81ac132255d555379bddd21c05168830..c5da4a4359364ea8389ce257c5c836e7b15d115c 100644 (file)
@@ -11,6 +11,7 @@
 use std::os;
 use std::task;
 use std::uint;
+use std::vec_ng::Vec;
 
 fn f(n: uint) {
     let mut i = 0u;
@@ -29,9 +30,9 @@ fn main() {
     } else if args.len() <= 1u {
         vec!(~"", ~"10")
     } else {
-        args
+        args.move_iter().collect()
     };
-    let n = from_str::<uint>(args[1]).unwrap();
+    let n = from_str::<uint>(*args.get(1)).unwrap();
     let mut i = 0u;
     while i < n { task::spawn(proc() f(n) ); i += 1u; }
 }
index e1696f0e63ed7607a52fca0aa55f590009b1ba14..8dbf292277be9cda5eb46a2eae8579f56c848449 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
 
 struct sty(Vec<int> );
 
index 7d842e3d5ab2a1a2c7157ce614148f6e86f5b919..24a4c9863f76e6b5a8ec3f269e7a4bd1e870e90c 100644 (file)
@@ -8,16 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 trait foo {
     fn foo(&self) -> int;
 }
 
 impl foo for Vec<uint> {
-    fn foo(&self) -> int {1} //~ NOTE candidate #1 is `~[uint].foo::foo`
+    fn foo(&self) -> int {1} //~ NOTE candidate #1 is `Vec<uint>.foo::foo`
 }
 
 impl foo for Vec<int> {
-    fn foo(&self) -> int {2} //~ NOTE candidate #2 is `~[int].foo::foo`
+    fn foo(&self) -> int {2} //~ NOTE candidate #2 is `Vec<int>.foo::foo`
 }
 
 fn main() {
index 6ba5a3333c5bc1df5993bb484ca5f968722b99e5..6e73427f80f95ba38fb8f7b94f693e7eaa7cb799 100644 (file)
@@ -12,4 +12,4 @@
 
 mod m1 {}
 
-fn main(args: vec!(str)) { log(debug, m1::a); }
+fn main(args: Vec<~str>) { log(debug, m1::a); }
index 4c85ba0763784ac741da5f52d4ad3c877c234148..d2b3a57868683e469c315d639e208bbbbb30c2d1 100644 (file)
@@ -14,4 +14,6 @@ mod m1 {
     pub mod a {}
 }
 
-fn main(args: vec!(str)) { log(debug, m1::a); }
+fn main(args: Vec<~str>) {
+    log(debug, m1::a);
+}
index 2377870c6474a802f5693ba7a6a5458744ac2e89..143ebdaa77399d3a8cbfe2c7be13667ddb9399c5 100644 (file)
@@ -17,9 +17,9 @@ fn a() {
     let mut p = vec!(1);
 
     // Create an immutable pointer into p's contents:
-    let q: &int = &p[0];
+    let q: &int = p.get(0);
 
-    p[0] = 5; //~ ERROR cannot assign
+    *p.get_mut(0) = 5; //~ ERROR cannot borrow
 
     println!("{}", *q);
 }
@@ -33,16 +33,16 @@ fn b() {
     let mut p = vec!(1);
 
     borrow(
-        p,
-        || p[0] = 5); //~ ERROR cannot borrow `p` as mutable
+        p.as_slice(),
+        || *p.get_mut(0) = 5); //~ ERROR cannot borrow `p` as mutable
 }
 
 fn c() {
     // Legal because the scope of the borrow does not include the
     // modification:
     let mut p = vec!(1);
-    borrow(p, ||{});
-    p[0] = 5;
+    borrow(p.as_slice(), ||{});
+    *p.get_mut(0) = 5;
 }
 
 fn main() {
index a9c4fa9a4b5eb4728c66dbe763c26adccbe6e3c2..ef9bee80c2b2db02ddc5caf309dad4ef42e9f818 100644 (file)
@@ -28,6 +28,7 @@ fn defer<'r>(x: &'r [&'r str]) -> defer<'r> {
 }
 
 fn main() {
-    let x = defer(vec!("Goodbye", "world!")); //~ ERROR borrowed value does not live long enough
+    let x = defer(vec!("Goodbye", "world!").as_slice());
+    //~^ ERROR borrowed value does not live long enough
     x.x[0];
 }
index cbe805551c2007011d5c4eff9d379b549562cb78..8d4cb6714bcb06d742ce2674a0f577a53248cbc4 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn test() {
     let v: int;
     v += 1; //~ ERROR use of possibly uninitialized variable: `v`
index 200d208d140b69a054538222bf1d7d10c8fdf4a0..393b528869a940b1d2168144752865d43f835e1c 100644 (file)
@@ -18,15 +18,15 @@ fn takes_imm_elt(_v: &int, f: ||) {
 
 fn has_mut_vec_and_does_not_try_to_change_it() {
     let mut v = vec!(1, 2, 3);
-    takes_imm_elt(&v[0], || {})
+    takes_imm_elt(v.get(0), || {})
 }
 
 fn has_mut_vec_but_tries_to_change_it() {
     let mut v = vec!(1, 2, 3);
     takes_imm_elt(
-        &v[0],
+        v.get(0),
         || { //~ ERROR cannot borrow `v` as mutable
-            v[1] = 4;
+            *v.get_mut(1) = 4;
         })
 }
 
index 30ab71ad10532e5c748b3a4034685942115ae8cb..6724d76d0dc55f11db1787445259e84716c0dbec 100644 (file)
@@ -21,7 +21,7 @@ pub fn main() {
         Foo { string: ~"bar" },
         Foo { string: ~"baz" }
     );
-    let x: &[Foo] = x;
+    let x: &[Foo] = x.as_slice();
     match x {
         [_, ..tail] => {
             match tail {
index b1ca61ebbcfd09bbce185d667c0a4bd6c2c53279..283d6398e9ad38efecfa62565811972839c3c8b1 100644 (file)
@@ -14,5 +14,5 @@ fn write(v: &mut [int]) {
 
 fn main() {
     let v = vec!(1, 2, 3);
-    write(v); //~ ERROR cannot borrow
+    write(v.as_mut_slice()); //~ ERROR cannot borrow
 }
index 22e35e4a84c85af7e058f367e9b1e075ad31d13d..3da284175541d730aeaf130ea1e376705f1b1d67 100644 (file)
@@ -10,7 +10,7 @@
 
 fn a() -> &[int] {
     let vec = vec!(1, 2, 3, 4);
-    let vec: &[int] = vec; //~ ERROR does not live long enough
+    let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough
     let tail = match vec {
         [_, ..tail] => tail,
         _ => fail!("a")
@@ -20,7 +20,7 @@ fn a() -> &[int] {
 
 fn b() -> &[int] {
     let vec = vec!(1, 2, 3, 4);
-    let vec: &[int] = vec; //~ ERROR does not live long enough
+    let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough
     let init = match vec {
         [..init, _] => init,
         _ => fail!("b")
@@ -30,7 +30,7 @@ fn b() -> &[int] {
 
 fn c() -> &[int] {
     let vec = vec!(1, 2, 3, 4);
-    let vec: &[int] = vec; //~ ERROR does not live long enough
+    let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough
     let slice = match vec {
         [_, ..slice, _] => slice,
         _ => fail!("c")
index ca28b3cfd45b6d4d279ab07441e82d20072bb1f6..393ec8b0b1b3ba9d80e8a7a44e6a2e03dbbf9a60 100644 (file)
@@ -10,7 +10,7 @@
 
 fn a() {
     let mut v = vec!(1, 2, 3);
-    let vb: &mut [int] = v;
+    let vb: &mut [int] = v.as_mut_slice();
     match vb {
         [_a, ..tail] => {
             v.push(tail[0] + tail[1]); //~ ERROR cannot borrow
index a3b0c0ea3591d6e9bfcc8a85873d26e7fc6afb77..e96ccd2aa8b209b323a4691ae54e3fca892b2979 100644 (file)
@@ -19,7 +19,7 @@ fn a() {
 
 fn b() {
     let mut vec = vec!(~1, ~2, ~3);
-    let vec: &mut [~int] = vec;
+    let vec: &mut [~int] = vec.as_mut_slice();
     match vec {
         [.._b] => {
             vec[0] = ~4; //~ ERROR cannot assign
@@ -29,7 +29,7 @@ fn b() {
 
 fn c() {
     let mut vec = vec!(~1, ~2, ~3);
-    let vec: &mut [~int] = vec;
+    let vec: &mut [~int] = vec.as_mut_slice();
     match vec {
         [_a, .._b] => {
             //~^ ERROR cannot move out
@@ -47,7 +47,7 @@ fn c() {
 
 fn d() {
     let mut vec = vec!(~1, ~2, ~3);
-    let vec: &mut [~int] = vec;
+    let vec: &mut [~int] = vec.as_mut_slice();
     match vec {
         [.._a, _b] => {
             //~^ ERROR cannot move out
@@ -59,7 +59,7 @@ fn d() {
 
 fn e() {
     let mut vec = vec!(~1, ~2, ~3);
-    let vec: &mut [~int] = vec;
+    let vec: &mut [~int] = vec.as_mut_slice();
     match vec {
         [_a, _b, _c] => {}  //~ ERROR cannot move out
         //~^ ERROR cannot move out
index 7b3db0151f629235fe6eaa905631a2cebfb02923..26dc853859c9256ef286c6e6396a8670fb068b80 100644 (file)
@@ -10,7 +10,7 @@
 
 fn a() -> &int {
     let vec = vec!(1, 2, 3, 4);
-    let vec: &[int] = vec; //~ ERROR `vec[..]` does not live long enough
+    let vec: &[int] = vec.as_slice(); //~ ERROR `vec` does not live long enough
     let tail = match vec {
         [_a, ..tail] => &tail[0],
         _ => fail!("foo")
index 8ab78648ff5ee4b99a6a8371664ebf6979e0838e..09274aaa504452c655bf7fb9af3fe8f15d52f822 100644 (file)
 
 #[feature(managed_boxes)];
 
-type Foo = Vec<u8> ;
+use std::vec_ng::Vec;
 
-impl Drop for Foo {   //~ ERROR the Drop trait may only be implemented
+type Foo = Vec<u8>;
+
+impl Drop for Foo {   //~ ERROR conflicting implementations
 //~^ ERROR cannot provide an extension implementation
+//~^^ ERROR multiple applicable methods
     fn drop(&mut self) {
         println!("kaboom");
     }
diff --git a/src/test/compile-fail/empty-vec-trailing-comma.rs b/src/test/compile-fail/empty-vec-trailing-comma.rs
deleted file mode 100644 (file)
index 41cb351..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
-    let v = vec!(); //~ ERROR unexpected token: `,`
-}
diff --git a/src/test/compile-fail/evec-subtyping.rs b/src/test/compile-fail/evec-subtyping.rs
deleted file mode 100644 (file)
index 562a558..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-fn wants_uniq(x: Vec<uint> ) { }
-fn wants_three(x: [uint, ..3]) { }
-
-fn has_uniq(x: Vec<uint> ) {
-   wants_uniq(x);
-   wants_three(x); //~ ERROR [] storage differs: expected `3` but found `~`
-}
-
-fn has_three(x: [uint, ..3]) {
-   wants_uniq(x); //~ ERROR [] storage differs: expected `~` but found `3`
-   wants_three(x);
-}
-
-fn has_four(x: [uint, ..4]) {
-   wants_uniq(x); //~ ERROR [] storage differs: expected `~` but found `4`
-   wants_three(x); //~ ERROR [] storage differs: expected `3` but found `4`
-}
-
-fn main() {
-}
index c5c6a37595935e24455ccdae617c008c515c966d..35a17f7e0171b7a03887af8efb8e9522017c76cf 100644 (file)
 // error-pattern:failed to resolve import
 use zed::bar;
 use zed::baz;
+
+use std::vec_ng::Vec;
+
 mod zed {
     pub fn bar() { println!("bar"); }
 }
-fn main(args: vec!(str)) { bar(); }
+fn main(args: Vec<~str>) { bar(); }
index 0024f78009de27f47aed8d97352f7a64c6c639d5..759e0c56f51b32fab2f687bb331b2ca882a2befa 100644 (file)
 use baz::zed::bar;  //~ ERROR unresolved import
 //~^ ERROR failed to resolve import
 
+use std::vec_ng::Vec;
+
 mod baz {}
 mod zed {
     pub fn bar() { println!("bar3"); }
 }
-fn main(args: vec!(str)) { bar(); }
+fn main(args: Vec<~str>) { bar(); }
index feb94708520c2d989b1fe3c17309e8ac83ddb902..8920349a27a9630f4cd95eb0e3a392926738b460 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern: import
 
+use std::vec_ng::Vec;
+
 mod a { pub use b::foo; }
 mod b { pub use a::foo; }
 
index 409a5e72fed7023f9d867de11c927f3044338a45..c52199ecedd388b7fae9e5e3c67833cc0d6d3ba7 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern: illegal recursive type
 
-type x = vec!(x);
+use std::vec_ng::Vec;
+
+type x = Vec<x>;
 
 fn main() { let b: x = Vec::new(); }
diff --git a/src/test/compile-fail/issue-10487.rs b/src/test/compile-fail/issue-10487.rs
deleted file mode 100644 (file)
index c2f40f5..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2013 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-static x: Vec<int> = vec!(123, 456); //~ ERROR: static items are not allowed to have owned pointers
-
-fn main() {}
index ed35f3b306bfc17ef87008a7b6a151afefb92a68..29f7e344b3093ba669182bfa0deba4abc51476fe 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 trait vec_monad<A> {
     fn bind<B>(&self, f: |A| -> Vec<B> );
 }
index ca49bd1a48a6182713e9d97c21bb566fdbfa3cf4..69dd24522fb3224a96f62825699b37e4130ac343 100644 (file)
@@ -13,6 +13,8 @@
 #[allow(dead_code)];
 #[allow(deprecated_owned_vector)];
 
+use std::vec_ng::Vec;
+
 fn fail_len(v: Vec<int> ) -> uint {
     let mut i = 3;
     fail!();
diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs
deleted file mode 100644 (file)
index c2f48b7..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-// A test case for #2548.
-
-use std::cell::Cell;
-
-struct foo {
-    x: @Cell<int>,
-}
-
-#[unsafe_destructor]
-impl Drop for foo {
-    fn drop(&mut self) {
-        unsafe {
-            println!("Goodbye, World!");
-            self.x.set(self.x.get() + 1);
-        }
-    }
-}
-
-fn foo(x: @Cell<int>) -> foo {
-    foo { x: x }
-}
-
-fn main() {
-    let x = @Cell::new(0);
-
-    {
-        let mut res = foo(x);
-
-        let mut v = Vec::new();
-        v = vec!((res)) + v; //~ failed to find an implementation of trait
-        assert_eq!(v.len(), 2);
-    }
-
-    assert_eq!(x.get(), 1);
-}
index 94c155fce9b3c9f276f9232e11ecc6cb081ea94f..a3f2da150a3c417126dfd2fc974bf91cbfe1b814 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 struct parser {
     tokens: Vec<int> ,
 }
index 3b1bceb453a937211275a3f2258a171f9bd0b0fa..076c60152684d8b85b74f7c7fdfeebf9b12aaa4e 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn main() {
     let needlesArr: Vec<char> = vec!('a', 'f');
     needlesArr.iter().fold(|x, y| {
index c78e1a150586a7b8f16d134292405c74b57a28a5..633be15ef9922d85b407d2401cc5b82f761fee5d 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 pub struct CrateId {
     local_path: ~str,
     junk: ~str
index 4c9f40397236e6b5b32be41a3ccc4ee5e96fed83..9d7edefbf024b05742bb8972e4061d80d6fbf36a 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#[allow(deprecated_owned_vector)];
-
 // Verify the compiler fails with an error on infinite function
 // recursions.
 
index bf10a029024234878503b26b13c46f5b2f1affc9..c5977678aba11a20af026a2757d2d7ae25b94c96 100644 (file)
@@ -10,6 +10,8 @@
 
 // Test which of the builtin types are considered freezeable.
 
+use std::vec_ng::Vec;
+
 fn assert_freeze<T:Freeze>() { }
 trait Dummy { }
 
index 94902d4e68ea5a50d155453989f933282c2cef44..bc4ee14d89eb5c3a2ea8be8dbb7bf448c4cf48eb 100644 (file)
@@ -13,6 +13,7 @@
 #[feature(managed_boxes)];
 
 use std::rc::Rc;
+use std::vec_ng::Vec;
 
 fn assert_pod<T:Pod>() { }
 trait Dummy { }
index 829bdaa5332753b13f294b7fec07d75c38d8b375..0eb3656cea787c0e8683f6ae4d01ec06c2ba1c41 100644 (file)
@@ -10,6 +10,8 @@
 
 // Test which of the builtin types are considered sendable.
 
+use std::vec_ng::Vec;
+
 fn assert_send<T:Send>() { }
 trait Dummy { }
 
index 5391cd475aa63d990d0d3ece3c94461932aaa2db..f45888010750ef9cca0fb8fae7b79ebe2b58b15a 100644 (file)
@@ -25,8 +25,6 @@ fn main() {
     @2; //~ ERROR type uses managed
 
     ~2; //~ ERROR type uses owned
-    vec!(1); //~ ERROR type uses owned
-    //~^ ERROR type uses owned
     fn g(_: ~Clone) {} //~ ERROR type uses owned
     ~""; //~ ERROR type uses owned
     //~^ ERROR type uses owned
index 275b37d9b7e4986aeaca269173a91124f07ab6cf..2adf833e4e4d4fce31fc81e9ce4b4fbb62bc8353 100644 (file)
@@ -16,6 +16,8 @@
 #[allow(deprecated_owned_vector)];
 #[deny(unused_mut)];
 
+use std::vec_ng::Vec;
+
 fn main() {
     // negative cases
     let mut a = 3; //~ ERROR: variable does not need to be mutable
index 2bf784faf00eca40f9226bcdb4455d2699dcdf0c..81e8c39a28c6dae5f0df1eb6e97f397277448cb6 100644 (file)
@@ -14,6 +14,8 @@
 #[deny(unused_unsafe)];
 #[allow(deprecated_owned_vector)];
 
+use std::vec_ng::Vec;
+
 mod foo {
     extern {
         pub fn bar();
index 3d60195775486c5d8c2fd48b01f459063d225aec..4bfa614063b5097189c2eb174e369426f209544f 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::slice;
+use std::vec::Vec;
 
 fn main() {
     let a: Vec<int> = Vec::new();
index 31fdb220263dba135b8f302030e76a5b34afd5e3..2112af7cd043f5886806eb8dc5d5b1ada0013700 100644 (file)
@@ -8,9 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn main() {
     let x: Vec<(int, int)> = Vec::new();
-    let x: &[(int, int)] = x;
+    let x: &[(int, int)] = x.as_slice();
     match x {
         [a, (2, 3), _] => (),
         [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern
@@ -18,7 +20,7 @@ fn main() {
     }
 
     let x: Vec<~str> = vec!(~"foo", ~"bar", ~"baz");
-    let x: &[~str] = x;
+    let x: &[~str] = x.as_slice();
     match x {
         [a, _, _, ..] => { println!("{}", a); }
         [_, _, _, _, _] => { } //~ ERROR unreachable pattern
@@ -26,7 +28,7 @@ fn main() {
     }
 
     let x: Vec<char> = vec!('a', 'b', 'c');
-    let x: &[char] = x;
+    let x: &[char] = x.as_slice();
     match x {
         ['a', 'b', 'c', .._tail] => {}
         ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
index 59bdc0b8a4d190a42fdd54a63c2f62fa9d38c248..657d5ad03e8a88aa2dac04b396f354fe3fa0c263 100644 (file)
@@ -23,8 +23,8 @@ fn f10() {
 
 fn f20() {
     let x = vec!(~"hi");
-    consume(x[0]);
-    touch(&x[0]); //~ ERROR use of partially moved value: `x`
+    consume(x.move_iter().next().unwrap());
+    touch(x.get(0)); //~ ERROR use of moved value: `x`
 }
 
 fn main() {}
index cfc57af092c7891c56a6727ce0274cf176b10fcb..967612e7c50168866d4e8335bfd7eca2fa4ab6c5 100644 (file)
@@ -31,7 +31,7 @@ fn f20() {
 
 fn f21() {
     let x = vec!(1, 2, 3);
-    let _y = (x[0], 3);
+    let _y = (*x.get(0), 3);
     touch(&x);
 }
 
@@ -84,21 +84,21 @@ fn f80() {
 
 fn f100() {
     let x = vec!(~"hi");
-    let _y = x[0];
-    touch(&x); //~ ERROR use of partially moved value: `x`
+    let _y = x.move_iter().next().unwrap();
+    touch(&x); //~ ERROR use of moved value: `x`
 }
 
 fn f110() {
     let x = vec!(~"hi");
-    let _y = [x[0], ..1];
-    touch(&x); //~ ERROR use of partially moved value: `x`
+    let _y = [x.move_iter().next().unwrap(), ..1];
+    touch(&x); //~ ERROR use of moved value: `x`
 }
 
 fn f120() {
     let mut x = vec!(~"hi", ~"ho");
     x.swap(0, 1);
-    touch(&x[0]);
-    touch(&x[1]);
+    touch(x.get(0));
+    touch(x.get(1));
 }
 
 fn main() {}
index 7311a0d5302f330fade049f0c3cd0d6574feefb3..e76c31469ea44274ce87e8ecec233f1fd4dec1f1 100644 (file)
@@ -21,10 +21,10 @@ fn main() {
 
     task::spawn(proc() {
         let v = arc_v.get();
-        assert_eq!(v[3], 4);
+        assert_eq!(*v.get(3), 4);
     });
 
-    assert_eq!((arc_v.get())[2], 3);
+    assert_eq!(*(arc_v.get()).get(2), 3);
 
     println!("{:?}", arc_v);
 }
index 115be7e148535ee95b5ad2953a3f90fad4899c11..29f62ff6e1b261834001465b7a193a48bb0acf48 100644 (file)
@@ -19,10 +19,10 @@ fn main() {
 
     task::spawn(proc() {
         let v = arc_v.get();
-        assert_eq!(v[3], 4);
+        assert_eq!(*v.get(3), 4);
     });
 
-    assert_eq!((arc_v.get())[2], 3); //~ ERROR use of moved value: `arc_v`
+    assert_eq!(*(arc_v.get()).get(2), 3); //~ ERROR use of moved value: `arc_v`
 
     println!("{:?}", arc_v); //~ ERROR use of moved value: `arc_v`
 }
index 162b84d6cece11b459ab353109c76071d1217e77..fd857129c35690e0371ee8e21109fb4ed44d3024 100644 (file)
@@ -11,6 +11,6 @@
 enum State { ST_NULL, ST_WHITESPACE }
 
 fn main() {
-    vec!(ST_NULL, ..(ST_WHITESPACE as uint));
+    [ST_NULL, ..(ST_WHITESPACE as uint)];
     //~^ ERROR expected constant integer for repeat count but found variable
 }
index bd9547d5e1c4af74d1e38e4bffe1ec8c1b52c496..2b3722196c11946c9ac4e730fcafc244d723ef9c 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::libc;
+use std::vec_ng::Vec;
 
 fn main() {
     let x : *Vec<int> = &vec!(1,2,3);
index 3bed415600fd9170798fd85350a35b5fa0deb7d0..a07fec853fc52b57076040f87c86793616439478 100644 (file)
@@ -36,7 +36,7 @@ fn main() {
       (b, b) => {}
     }
     let vec = vec!(Some(42), None, Some(21));
-    let vec: &[Option<int>] = vec;
+    let vec: &[Option<int>] = vec.as_slice();
     match vec {
         //~^ ERROR non-exhaustive patterns: vectors of length 0 not covered
         [Some(..), None, ..tail] => {}
@@ -44,13 +44,13 @@ fn main() {
         [None] => {}
     }
     let vec = vec!(1);
-    let vec: &[int] = vec;
+    let vec: &[int] = vec.as_slice();
     match vec {
         [_, ..tail] => (),
         [] => ()
     }
     let vec = vec!(0.5);
-    let vec: &[f32] = vec;
+    let vec: &[f32] = vec.as_slice();
     match vec { //~ ERROR non-exhaustive patterns: vectors of length 4 not covered
         [0.1, 0.2, 0.3] => (),
         [0.1, 0.2] => (),
@@ -58,7 +58,7 @@ fn main() {
         [] => ()
     }
     let vec = vec!(Some(42), None, Some(21));
-    let vec: &[Option<int>] = vec;
+    let vec: &[Option<int>] = vec.as_slice();
     match vec {
         [Some(..), None, ..tail] => {}
         [Some(..), Some(..), ..tail] => {}
index a7340df83b488a22f28949afcd03c5abf154406d..38669a99b498f1964e8f7405c26ed6857335d57b 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
 enum bar { t1((), Option<Vec<int>>), t2, }
 
 // n.b. my change changes this error message, but I think it's right -- tjc
index 08c8eba696dcd5900f1ed1dc89e5ffe851611f32..692c51b5b5ff720cf16dbc25183b949faa9b89f9 100644 (file)
@@ -12,5 +12,5 @@
 
 fn main() {
     let n = 1;
-    let a = vec!(0, ..n); //~ ERROR expected constant integer for repeat count but found variable
+    let a = [0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
 }
index a135af29356f3330927b00c7409a9b98589c2a57..59c80474c4c7738ffc4ec9fc506b71511200cc74 100644 (file)
@@ -13,6 +13,8 @@
 
 #[no_implicit_prelude];
 
+use std::vec_ng::Vec;
+
 fn last<T>(v: Vec<&T> ) -> std::option::Option<T> {
     fail!();
 }
diff --git a/src/test/compile-fail/uninstantiable-fixed-length-vec.rs b/src/test/compile-fail/uninstantiable-fixed-length-vec.rs
deleted file mode 100644 (file)
index a440103..0000000
+++ /dev/null
@@ -1,26 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// issue #11659, the compiler needs to know that a fixed length vector
-// always requires instantiable contents to instantiable itself
-// (unlike a ~[] vector which can have length zero).
-
-// ~ to avoid infinite size.
-struct Uninstantiable { //~ ERROR cannot be instantiated without an instance of itself
-    p: vec!(Uninstantiable, .. 1)
-}
-
-struct Instantiable { p: vec!(Instantiable, .. 0) }
-
-
-fn main() {
-    let _ = None::<Uninstantiable>;
-    let _ = Instantiable { p: ~([]) };
-}
index c76a6f2453e243b30f1661e57654641bbcba120e..e35a0c607c8e885cbdc1209199b2d3edbe695354 100644 (file)
@@ -11,6 +11,7 @@
 #[feature(managed_boxes)];
 
 use std::cell::Cell;
+use std::vec_ng::Vec;
 
 struct r {
   i: @Cell<int>,
index 4d57470a721655d20c16204f51378caac5f91f47..4dd3b26bad966cb3910d6eb851e396e52aca6389 100644 (file)
@@ -11,6 +11,7 @@
 // ignore-tidy-linelength
 
 use std::fmt;
+use std::vec_ng::Vec;
 
 struct Number {
     n: i64
index be226b2e16e55bd279bb1c7fb82864e673465204..985a094d5a8c2fbc03c2a307ca713b84aebf06f3 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn main() {
     let _foo = Vec::new(); //~ ERROR unconstrained type
 }
index 987a3c1674c28ab56205b0a611c39ad2e087fc70..00d537f95bf984df0de8f5a8a2e6ef355d579c51 100644 (file)
@@ -8,7 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn main() {
     let v: Vec<int> = vec!(1, 2, 3);
-    v[1] = 4; //~ ERROR cannot assign
+    *v.get(1) = 4; //~ ERROR cannot assign
 }
index 8e4427d9dd4e9f8e5cdb72d1e536245ba036d00f..acc03831290d0fe06a289bbca51362c6bc59383f 100644 (file)
@@ -15,6 +15,7 @@
 #[feature(managed_boxes)];
 
 use std::cell::Cell;
+use std::vec_ng::Vec;
 
 fn test1() { let val = @0; { } *val; }
 
@@ -61,7 +62,7 @@ fn test9() {
 fn test10() -> int {
     let regs = @vec!(0);
     match true { true => { } _ => { } }
-    (*regs)[0]
+    *(*regs).get(0)
 }
 
 fn test11() -> Vec<int> { if true { } vec!(1, 2) }
index 56ffc41c76ccf558aecd8ab4f9e8665178af6fc4..5b52acdff50691628c60addf9e6babded5c1fa97 100644 (file)
@@ -14,7 +14,7 @@ fn main() {
     let x = Some(3);
     let _y =
         match x {
-            Some(_) => vec!(~"some(_)", ~"not", ~"SO", ~"long", ~"string"),
-            None => vec!(~"none")
+            Some(_) => [~"some(_)", ~"not", ~"SO", ~"long", ~"string"],
+            None => [~"none", ~"a", ~"a", ~"a", ~"a"]
         };
 }
index a09e341a9402fb1c6265b0a7490a214e8a64fce2..dc2dae1044dac2354ef981979bce687c4384e4cd 100644 (file)
 // pp-exact:vec-comments.pp
 fn main() {
     let _v1 =
-        ~[
-          // Comment
-          0,
-          // Comment
-          1,
-          // Comment
-          2];
+        [
+         // Comment
+         0,
+         // Comment
+         1,
+         // Comment
+         2];
     let _v2 =
-        ~[0, // Comment
-          1, // Comment
-          2]; // Comment
+        [0, // Comment
+         1, // Comment
+         2]; // Comment
     let _v3 =
-        ~[
-          /* Comment */
-          0,
-          /* Comment */
-          1,
-          /* Comment */
-          2];
+        [
+         /* Comment */
+         0,
+         /* Comment */
+         1,
+         /* Comment */
+         2];
     let _v4 =
-        ~[0, /* Comment */
-          1, /* Comment */
-          2]; /* Comment */
+        [0, /* Comment */
+         1, /* Comment */
+         2]; /* Comment */
 }
index d685ad49a27defc73173d531ea6e6b3496ed55aa..dc2dae1044dac2354ef981979bce687c4384e4cd 100644 (file)
 // pp-exact:vec-comments.pp
 fn main() {
     let _v1 =
-        vec!(
-          // Comment
-          0,
-          // Comment
-          1,
-          // Comment
-          2);
+        [
+         // Comment
+         0,
+         // Comment
+         1,
+         // Comment
+         2];
     let _v2 =
-        vec!(0, // Comment
-          1, // Comment
-          2); // Comment
+        [0, // Comment
+         1, // Comment
+         2]; // Comment
     let _v3 =
-        vec!(
-          /* Comment */
-          0,
-          /* Comment */
-          1,
-          /* Comment */
-          2);
+        [
+         /* Comment */
+         0,
+         /* Comment */
+         1,
+         /* Comment */
+         2];
     let _v4 =
-        vec!(0, /* Comment */
-          1, /* Comment */
-          2); /* Comment */
+        [0, /* Comment */
+         1, /* Comment */
+         2]; /* Comment */
 }
diff --git a/src/test/pretty/vec-type.pp b/src/test/pretty/vec-type.pp
deleted file mode 100644 (file)
index d84f43d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// pp-exact:vec-type.pp
-
-fn f1(_x: ~[int]) { }
-
-fn g1() { f1(~[1, 2, 3]); }
diff --git a/src/test/pretty/vec-type.rs b/src/test/pretty/vec-type.rs
deleted file mode 100644 (file)
index 5e37123..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// pp-exact:vec-type.pp
-
-fn f1(_x: Vec<int> ) { }
-
-fn g1() { f1(vec!(1, 2, 3)); }
index 29e57925af5d2860bf98a39cbaf9c4e4368e6631..0e116bcede5499e76a7c94314377bcda262dcd5d 100644 (file)
@@ -31,5 +31,5 @@ fn main() {
            idx * mem::size_of::<uint>());
 
     // This should fail.
-    println!("ov1 0x{:x}",  x[idx]);
+    println!("ov1 0x{:x}", *x.get(idx));
 }
index d51865d782ccf229364fcbee457819f69bbf3ce8..365be5b75275a19204bc20b39905312630440213 100644 (file)
@@ -12,6 +12,8 @@
 #[allow(unreachable_code)];
 #[allow(unused_variable)];
 
+use std::vec_ng::Vec;
+
 // error-pattern:so long
 fn main() {
     let mut x = Vec::new();
index 9fb53d0f9e872706fd7c23d6c14e8f13ea5375d9..545012d93222472579eb5c2c2eebd49571529544 100644 (file)
 
 extern crate collections;
 
+use std::vec_ng::Vec;
+use std::vec_ng;
+
 fn main() {
     let _count = @0u;
     let mut map = collections::HashMap::new();
     let mut arr = Vec::new();
     for _i in range(0u, 10u) {
         arr.push(@~"key stuff");
-        map.insert(arr.clone(), arr + &[@~"value stuff"]);
+        map.insert(arr.clone(),
+                   vec::append(arr.clone(), &[@~"value stuff"]));
         if arr.len() == 5 {
             fail!();
         }
index e13c818ee44be8f8d871704fb73e90212593506f..80e1b60ee5a9e9e2c8572f854f3b13970fa17c47 100644 (file)
@@ -12,6 +12,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 fn f() -> Vec<int> { fail!(); }
 
 // Voodoo. In unwind-alt we had to do this to trigger the bug. Might
index 4dd2b35e2de64b36dca0c99e7a7e02baef029d3c..7f163a2a9e43fe3478793e0c1f25d100a101e153 100644 (file)
@@ -12,6 +12,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 fn f() -> Vec<int> { fail!(); }
 
 // Voodoo. In unwind-alt we had to do this to trigger the bug. Might
index eac4bf541574508f3337f0b319db67d77241654b..669edb4544bd3b2863d7db0b0c4042a9e6e15c61 100644 (file)
@@ -12,6 +12,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 fn f() -> Vec<int> { fail!(); }
 
 // Voodoo. In unwind-alt we had to do this to trigger the bug. Might
index 7604f568fe79f3312b4be17a467d7b727b4bc242..053bc0cb58c64182a06913f1bdb52b308f6e0499 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern:fail
 
+use std::vec_ng::Vec;
+
 fn build() -> Vec<int> {
     fail!();
 }
index 12990722d7b60efb6dc6ce72352a506e74096d83..7b18c678be6f71bb4126c05198b8b03e74deefb9 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern:fail
 
+use std::vec_ng::Vec;
+
 fn build1() -> Vec<int> {
     vec!(0,0,0,0,0,0,0)
 }
index 0d97923393466d2f5d7e83a236a3aed3d8fd5f24..fd1c13a5018f682c6c690c2323944a2f288b6ef5 100644 (file)
@@ -10,6 +10,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 // error-pattern:fail
 
 fn fold_local() -> @Vec<int> {
index 1112e108d2d148980dddafd8349a969baede554f..6735168e83a913e8edd6e13989f33f5e5b03dad3 100644 (file)
@@ -10,6 +10,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 // error-pattern:fail
 
 fn fold_local() -> @Vec<int> {
index 1542984c1d363e230d29a25147e033eeecac8d8b..169c00182dd396857acd6d2df092f4f4c5cff848 100644 (file)
@@ -8,13 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
 // error-pattern:index out of bounds: the len is 1 but the index is 2
+
+use std::vec_ng::Vec;
+
 fn main() {
     let v: Vec<int> = vec!(10);
-    let x: int = 0;
-    assert_eq!(v[x], 10);
+    let x: uint = 0;
+    assert_eq!(*v.get(x), 10);
     // Bounds-check failure.
 
-    assert_eq!(v[x + 2], 20);
+    assert_eq!(*v.get(x + 2), 20);
 }
index eba7e8c7ffb1ee510c427810362156471f66d981..f9320f6b039238c5106df2fc68025d2bb895aa41 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 enum option<T> { some(T), none, }
 
 struct R<T> {v: Vec<option<T>> }
index aa3e28c875e402f8d8b54ffaba35e9f454d69c81..60a7101c8201db4ba3ce647db72c841e5cb1431b 100644 (file)
@@ -12,6 +12,8 @@
 // making method calls, but only if there aren't any matches without
 // it.
 
+use std::vec_ng::Vec;
+
 trait iterable<A> {
     fn iterate(&self, blk: |x: &A| -> bool) -> bool;
 }
@@ -38,14 +40,14 @@ fn length<A, T: iterable<A>>(x: T) -> uint {
 }
 
 pub fn main() {
-    let x = vec!(0,1,2,3);
+    let x: Vec<int> = vec!(0,1,2,3);
     // Call a method
-    x.iterate(|y| { assert!(x[*y] == *y); true });
+    x.iterate(|y| { assert!(*x.get(*y as uint) == *y); true });
     // Call a parameterized function
     assert_eq!(length(x.clone()), x.len());
     // Call a parameterized function, with type arguments that require
     // a borrow
-    assert_eq!(length::<int, &[int]>(x), x.len());
+    assert_eq!(length::<int, &[int]>(x.as_slice()), x.len());
 
     // Now try it with a type that *needs* to be borrowed
     let z = [0,1,2,3];
index 0cc02d7a28bce9b845f1fdac09cd068029ddca47..86e1b18a57416589e23af9a410c30c56857f078f 100644 (file)
@@ -29,7 +29,7 @@ pub fn main() {
     // NB: Associativity of ~, etc. in this context is surprising. These must be parenthesized
 
     ([1]).test_imm();
-    (vec!(1)).test_imm();
+    (vec!(1)).as_slice().test_imm();
     (&[1]).test_imm();
     ("test").test_imm();
     (~"test").test_imm();
index 6b36746d230e92636fe21b829bbbaeaa8ff9bfc9..82d2a58a556e605f24718b9ad43dcb4c94ca9c04 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 trait Pushable<T> {
     fn push_val(&mut self, t: T);
 }
index 2fe5ce7a1180647af1c4b722f93f91e2a8a1b68d..db528c4fd08773ddfed725e44662de8f9a78d17a 100644 (file)
@@ -8,7 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f<T>(x: Vec<T> ) -> T { return x[0]; }
+use std::vec_ng::Vec;
+
+fn f<T>(x: Vec<T>) -> T { return x.move_iter().next().unwrap(); }
 
 fn g(act: |Vec<int> | -> int) -> int { return act(vec!(1, 2, 3)); }
 
index ba6a94fa6ff60e3630254454c613ff185af04279..97ae7d8cdef1a0b2c569021e7bea07da8682a5e1 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-fast
 
+use std::vec_ng::Vec;
+
 fn iter_vec<T>(v: Vec<T> , f: |&T|) { for x in v.iter() { f(x); } }
 
 pub fn main() {
index ba4bdbe636caf997ea6e4661fca320e09d720a60..a8d65dbdeca8b6833937261c5789f6023e3e5436 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-fast
 
+use std::vec_ng::Vec;
+
 fn iter_vec<T>(v: Vec<T> , f: |&T|) { for x in v.iter() { f(x); } }
 
 pub fn main() {
index 374c3e7fc539feeb230ffd1ee3436bd00082446f..df334a6fcec55fdd23a01b25a1da9206b58627b8 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 trait Foo {
     fn foo(self);
 }
@@ -18,5 +20,5 @@ fn foo(self) {}
 
 pub fn main() {
     let items = vec!( 3, 5, 1, 2, 4 );
-    items.foo();
+    items.as_slice().foo();
 }
index 126f0fd7ac5eabd8b5b0f50f011b1a08269114aa..67233c29258b1e73c08b24cd3981ca7b9582ffec 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 struct F { f: Vec<int> }
 
 fn impure(_v: &[int]) {
@@ -18,7 +20,7 @@ pub fn main() {
 
     match x {
       F {f: ref mut v} => {
-        impure(*v);
+        impure(v.as_slice());
       }
     }
 }
index ac6ea8dec051fdf97562bf1169eca1925aefd84c..88230cbb1c434a2b78bf4a2ec868d6fab3880be2 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::mem::swap;
+use std::vec_ng::Vec;
 
 struct Ints {sum: ~int, values: Vec<int> }
 
@@ -22,7 +23,7 @@ fn add_int(x: &mut Ints, v: int) {
 
 fn iter_ints(x: &Ints, f: |x: &int| -> bool) -> bool {
     let l = x.values.len();
-    range(0u, l).advance(|i| f(&x.values[i]))
+    range(0u, l).advance(|i| f(x.values.get(i)))
 }
 
 pub fn main() {
index e6fcb1ca9514926bcba512a1bd80fb5e47c6ed76..0b46f49ad93609172792d09ff093fd38d4fd6974 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn want_slice(v: &[int]) -> int {
     let mut sum = 0;
     for i in v.iter() { sum += *i; }
@@ -15,7 +17,7 @@ fn want_slice(v: &[int]) -> int {
 }
 
 fn has_mut_vec(v: Vec<int> ) -> int {
-    want_slice(v)
+    want_slice(v.as_slice())
 }
 
 pub fn main() {
index 3b07ffa26da25339e91e643ae1c8ec99573bae5a..bb346bccd515219d146f22c18ff9f7e27a4890c2 100644 (file)
@@ -10,6 +10,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 struct F { f: @G }
 struct G { g: Vec<int> }
 
index a2d4991abc018f468a8fb090c345990966213ada..03ea9178eb90c82df23d0a71b684363ee88b97b3 100644 (file)
@@ -10,6 +10,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 fn borrow<'r,T>(x: &'r T) -> &'r T {x}
 
 struct Rec { f: @int }
index d27dd8f92d13fc280cdaabaa26dbc00252f0204d..34f6e5ab8fd83404340048db6d657430ee2d7fe0 100644 (file)
@@ -8,10 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn foo() -> int { 22 }
 
 pub fn main() {
-    let mut x: vec!(extern "Rust" fn() -> int) = Vec::new();
+    let mut x: Vec<extern "Rust" fn() -> int> = Vec::new();
     x.push(foo);
-    assert_eq!((x[0])(), 22);
+    assert_eq!((*x.get(0))(), 22);
 }
index cddb5bb7e1580ddb73776cad0278b59f48d9183b..02ba8b900be728350f3f47e82935f1ae7f67e88f 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 struct cat<U> {
     info : Vec<U> ,
     meows : uint,
index 6d1c3aab66257bfd1c0c1dc56bed484e12b9486b..2911df412d817bf508d028cdab87db762966ad0e 100644 (file)
@@ -15,6 +15,7 @@
 #[feature(macro_rules)];
 
 use std::ops::Drop;
+use std::vec_ng::Vec;
 
 static mut FLAGS: u64 = 0;
 
@@ -116,7 +117,6 @@ pub fn main() {
     end_of_block!(_, { { check_flags(0); &AddFlags(1) } });
     end_of_block!(_, &((Box { f: AddFlags(1) }).f));
     end_of_block!(_, &(([AddFlags(1)])[0]));
-    end_of_block!(_, &((&vec!(AddFlags(1)))[0]));
 
     // LHS does not create a ref binding, so temporary lives as long
     // as statement, and we do not move the AddFlags out:
index b9587c57787082f63b8206b09d43f2102583e168..7bf7920fe070df21927b9c0bf4104b724d84e10c 100644 (file)
@@ -25,6 +25,7 @@
 // scenario worth testing.
 
 use std::task;
+use std::vec_ng::Vec;
 
 enum Conzabble {
     Bickwick(Foo)
@@ -41,7 +42,7 @@ fn get_bar(x: uint) -> Vec<uint> { vec!(x * 2) }
 pub fn fails() {
     let x = 2;
     let mut y = Vec::new();
-    y.push(~Bickwick(do_it(get_bar(x))));
+    y.push(~Bickwick(do_it(get_bar(x).as_slice())));
 }
 
 pub fn main() {
index ffac7cbdab0de33d9b63510423372b576fd1d0df..937cb0f0dac84d17dc922c1b5d7cedc31f15496b 100644 (file)
@@ -8,16 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn bar(v: &mut [uint]) -> Vec<uint> {
-    v.to_owned()
+    Vec::from_slice(v)
 }
 
 fn bip(v: &[uint]) -> Vec<uint> {
-    v.to_owned()
+    Vec::from_slice(v)
 }
 
 pub fn main() {
     let mut the_vec = vec!(1u, 2, 3, 100);
-    assert_eq!(the_vec.clone(), bar(the_vec));
-    assert_eq!(the_vec.clone(), bip(the_vec));
+    assert_eq!(the_vec.clone(), bar(the_vec.as_mut_slice()));
+    assert_eq!(the_vec.clone(), bip(the_vec.as_slice()));
 }
index 67d81ab8684c1939192a2f98cc5312e9481910da..be8bb861345b955ac9e0d1fda0a3ea50f6da6d11 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn reverse(v: &mut [uint]) {
     v.reverse();
 }
@@ -20,6 +22,6 @@ fn bar(v: &mut [uint]) {
 
 pub fn main() {
     let mut the_vec = vec!(1, 2, 3, 100);
-    bar(the_vec);
+    bar(the_vec.as_mut_slice());
     assert_eq!(the_vec, vec!(100, 3, 2, 1));
 }
index 31620973ce77281862d5ec17c1022844d0141564..686b8545b5ef8964a98660d87afbf2dec65da9a7 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn bar(v: &mut [uint]) {
     v.reverse();
     v.reverse();
@@ -16,6 +18,6 @@ fn bar(v: &mut [uint]) {
 
 pub fn main() {
     let mut the_vec = vec!(1, 2, 3, 100);
-    bar(the_vec);
+    bar(the_vec.as_mut_slice());
     assert_eq!(the_vec, vec!(100, 3, 2, 1));
 }
diff --git a/src/test/run-pass/const-enum-vec-repeat.rs b/src/test/run-pass/const-enum-vec-repeat.rs
deleted file mode 100644 (file)
index 5470b1d..0000000
+++ /dev/null
@@ -1,15 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-enum State { ST_NULL, ST_WHITESPACE = 1 }
-
-pub fn main() {
-    vec!(ST_NULL, ..(ST_WHITESPACE as uint));
-}
index e6ae892093c8ffb6947124fead4303ff0edd53fd..6a05dafb17cec30130ca4a53ee69eb97b1d0611b 100644 (file)
@@ -8,8 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-test
+// ignore-fast
+//
+// Too big for our poor macro infrastructure.
+
 pub fn main() {
-    let _x = ~[
+    let _x = vec!(
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -2008,5 +2013,5 @@ pub fn main() {
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-    ];
+    );
 }
index b644d1a8b1f9db95f2bf73997af7e2c9017b0691..615e94c3f4e59fc1dc70de7319dcfbb0da0e4d71 100644 (file)
@@ -8,8 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-test
+// ignore-fast
+//
+// Too big for our poor macro infrastructure.
+
 pub fn main() {
-    let _x = ~[
+    let _x = vec!(
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -8008,5 +8013,5 @@ pub fn main() {
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-    ];
+    );
 }
index f3d9eba87b6c929e356c3593a2d0865af1cb8d16..aafea1ef1ef0ea64630aad3eb11e33b3564d51f8 100644 (file)
@@ -10,4 +10,6 @@
 
 #[allow(unused_mut)];
 
+use std::vec_ng::Vec;
+
 pub fn main() { let mut _v: Vec<int> = Vec::new(); }
index 25dae36bcb1546439949a170b4e9f8f031f757f4..c8a207cd4bd2df4c40a60c676c798fbc0bc8c69f 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn test_int() {
     fn f() -> int { 10 }
     assert_eq!(f(), 10);
@@ -15,7 +17,8 @@ fn f() -> int { 10 }
 
 fn test_vec() {
     fn f() -> Vec<int> { vec!(10, 11) }
-    assert_eq!(f()[1], 11);
+    let vect = f();
+    assert_eq!(*vect.get(1), 11);
 }
 
 fn test_generic() {
index 71306a43f23b6156ba60f15ccfb8fae9edfd2a9d..46ba63e452d5c898ac7db18ba0d7274c267f6315 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn test_simple() {
     let r = match true { true => { true } false => { fail!() } };
     assert_eq!(r, true);
@@ -15,7 +17,7 @@ fn test_simple() {
 
 fn test_box() {
     let r = match true { true => { vec!(10) } false => { fail!() } };
-    assert_eq!(r[0], 10);
+    assert_eq!(*r.get(0), 10);
 }
 
 pub fn main() { test_simple(); test_box(); }
diff --git a/src/test/run-pass/expr-repeat-vstore.rs b/src/test/run-pass/expr-repeat-vstore.rs
deleted file mode 100644 (file)
index a111a87..0000000
+++ /dev/null
@@ -1,20 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-pub fn main() {
-    let v: Vec<int> = vec!( 1, ..5 );
-    println!("{}", v[0]);
-    println!("{}", v[1]);
-    println!("{}", v[2]);
-    println!("{}", v[3]);
-    println!("{}", v[4]);
-}
index d93f90937a177e48b71bc863df43e717a535a423..bc9f1f642d283205d1fd86464d12bd95fff1be1a 100644 (file)
@@ -8,4 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 pub fn main() { let x: Vec<int> = Vec::new(); for _ in x.iter() { fail!("moop"); } }
index 26395ed51f603715f2656da28cadcd28ffdae91c..9aed300c5648cc6e995b96bcf3d20b70549913e2 100644 (file)
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
+use std::vec_ng::Vec;
 
 fn two(it: |int|) { it(0); it(1); }
 
@@ -17,10 +16,10 @@ pub fn main() {
     let mut a: Vec<int> = vec!(-1, -1, -1, -1);
     let mut p: int = 0;
     two(|i| {
-        two(|j| { a[p] = 10 * i + j; p += 1; })
+        two(|j| { *a.get_mut(p as uint) = 10 * i + j; p += 1; })
     });
-    assert_eq!(a[0], 0);
-    assert_eq!(a[1], 1);
-    assert_eq!(a[2], 10);
-    assert_eq!(a[3], 11);
+    assert_eq!(*a.get(0), 0);
+    assert_eq!(*a.get(1), 1);
+    assert_eq!(*a.get(2), 10);
+    assert_eq!(*a.get(3), 11);
 }
index ccc1936fa994892f258c0592e3a61979f46077e3..f0dcc5e2809b07546b47e61c2f49864216624085 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 trait vec_utils<T> {
     fn map_<U>(x: &Self, f: |&T| -> U) -> Vec<U> ;
 }
index 5dea08ce6462eaa5f8a470ee21b9ec954ccf335f..314d045145bb9f7d14998fa8008a5eaf564fe69c 100644 (file)
 extern crate getopts;
 
 use getopts::{optopt, getopts};
+use std::vec_ng::Vec;
 
 pub fn main() {
     let args = Vec::new();
     let opts = vec!(optopt("b", "", "something", "SMTHNG"));
 
-    match getopts(args, opts) {
+    match getopts(args.as_slice(), opts.as_slice()) {
         Ok(ref m)  =>
             assert!(!m.opt_present("b")),
         Err(ref f) => fail!("{:?}", (*f).clone().to_err_msg())
index a11e286b96987be9cf5799c7a869472fd0eb05de..c6fa702aeca4cc1a5f2d14661e0958d12bd73fcb 100644 (file)
@@ -14,6 +14,8 @@
 
 extern crate collections;
 
+use std::vec_ng::Vec;
+
 /**
    A somewhat reduced test case to expose some Valgrind issues.
 
@@ -26,6 +28,7 @@ mod map_reduce {
     use collections::HashMap;
     use std::str;
     use std::task;
+    use std::vec_ng::Vec;
 
     pub type putter<'a> = 'a |~str, ~str|;
 
@@ -52,7 +55,7 @@ fn emit(im: &mut HashMap<~str, int>,
             }
             let (tx, rx) = channel();
             println!("sending find_reducer");
-            ctrl.send(find_reducer(key.as_bytes().to_owned(), tx));
+            ctrl.send(find_reducer(Vec::from_slice(key.as_bytes()), tx));
             println!("receiving");
             let c = rx.recv();
             println!("{:?}", c);
@@ -83,7 +86,8 @@ pub fn map_reduce(inputs: Vec<~str>) {
               mapper_done => { num_mappers -= 1; }
               find_reducer(k, cc) => {
                 let mut c;
-                match reducers.find(&str::from_utf8(k).unwrap().to_owned()) {
+                match reducers.find(&str::from_utf8(k.as_slice()).unwrap()
+                                                                 .to_owned()) {
                   Some(&_c) => { c = _c; }
                   None => { c = 0; }
                 }
index 5141be1f178b331b05025f3cd45d21fbdbe72702..aadb372fa12a84aa3196a5233bab9f04bd61e6e0 100644 (file)
@@ -12,6 +12,8 @@
 
 #[feature(macro_rules)];
 
+use std::vec_ng::Vec;
+
 /*
 
 This is an HTML parser written as a macro. It's all CPS, and we have
index 753e98422b3d4823cd344422020df9a5117fa491..7e9afc4de564f531b83d07c53297d5bbb4e5a2b3 100644 (file)
@@ -182,7 +182,7 @@ fn test_write() {
 // can do with them just yet (to test the output)
 fn test_print() {
     print!("hi");
-    print!("{:?}", ~[0u8]);
+    print!("{:?}", vec!(0u8));
     println!("hello");
     println!("this is a {}", "test");
     println!("{foo}", foo="bar");
index e3ea5886fa3b186db147663f1aa8941b5e52e930..aeb2fdae9020390774c07337b07d66b701023fa8 100644 (file)
 #[feature(globs)];
 #[allow(dead_assignment)];
 
-use std::slice::*;
+use std::mem::*;
 
 pub fn main() {
-    let mut v = from_elem(0u, 0);
-    v = append(v, [4, 2]);
-    assert_eq!(from_fn(2, |i| 2*(i+1)), vec!(2, 4));
+    assert_eq!(size_of::<u8>(), 1);
+    let (mut x, mut y) = (1, 2);
+    swap(&mut x, &mut y);
+    assert_eq!(x, 2);
+    assert_eq!(x, 1);
 }
index 6642d1a5a8e52b43eaf92fd40f1fde30a27c34b6..a3d1be5b4f12fcd76ea484ac9476dad6a5201ff0 100644 (file)
@@ -10,6 +10,8 @@
 
 // issue #680
 
+use std::vec_ng::Vec;
+
 fn f() -> Vec<int> { Vec::new() }
 
 pub fn main() { }
index cbbe101c58a34fc73a67c49be0156604bfa9b3d5..e0d0f3409eea05ae814857f2b8f1d14d8d9671c6 100644 (file)
@@ -8,19 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
+use std::vec_ng::Vec;
 
 // This is a testcase for issue #94.
 pub fn main() {
     let v: Vec<int> = vec!(0, 1, 2, 3, 4, 5);
     let s: ~str = ~"abcdef";
-    assert_eq!(v[3u], 3);
-    assert_eq!(v[3u8], 3);
-    assert_eq!(v[3i8], 3);
-    assert_eq!(v[3u32], 3);
-    assert_eq!(v[3i32], 3);
-    println!("{}", v[3u8]);
+    assert_eq!(v.as_slice()[3u], 3);
+    assert_eq!(v.as_slice()[3u8], 3);
+    assert_eq!(v.as_slice()[3i8], 3);
+    assert_eq!(v.as_slice()[3u32], 3);
+    assert_eq!(v.as_slice()[3i32], 3);
+    println!("{}", v.as_slice()[3u8]);
     assert_eq!(s[3u], 'd' as u8);
     assert_eq!(s[3u8], 'd' as u8);
     assert_eq!(s[3i8], 'd' as u8);
index ccd2399a06dec53c589f319d48885c0772723dc7..ef66a1e3a67e38606a0c89119f1ee6bafc030313 100644 (file)
@@ -9,7 +9,10 @@
 // except according to those terms.
 
 // Issue #1821 - Don't recurse trying to typecheck this
+
+use std::vec_ng::Vec;
+
 enum t {
-    foo(vec!(t))
+    foo(Vec<t>)
 }
 pub fn main() {}
index cfdd226ef5c28939254a081e4f8479df2e0537da..33cac672b3933b392da9817ef5f44e62aa8bd2c4 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 struct font<'a> {
     fontbuf: &'a Vec<u8> ,
 }
index eeda79e1355a8976efbbd5048bc95749daed185d..d5cf80d24406925480701e47bc1dbac4b1987cba 100644 (file)
@@ -16,6 +16,7 @@
 use collections::HashMap;
 use serialize::json;
 use std::option;
+use std::vec_ng::Vec;
 
 enum object {
     bool_value(bool),
@@ -60,9 +61,9 @@ fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, json::Json
     {
         &json::List(ref interfaces) =>
         {
-          interfaces.map(|interface| {
+          interfaces.iter().map(|interface| {
                 add_interface(store, managed_ip.clone(), (*interface).clone())
-          })
+          }).collect()
         }
         _ =>
         {
index 9ffe4bc4d7e5d67b86cb011d2edf967c23fb7bc0..8093c08816562f12f0611f699e227cfebe59f341 100644 (file)
@@ -16,6 +16,7 @@
 
 use std::io;
 use std::fmt;
+use std::vec_ng::Vec;
 
 enum square {
     bot,
@@ -60,7 +61,8 @@ fn square_from_char(c: char) -> square {
     }
 }
 
-fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr) -> vec!(vec!(square)) {
+fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr)
+                   -> Vec<Vec<square>> {
     let mut input: &mut io::Reader = &mut input;
     let mut grid = Vec::new();
     let mut line = [0, ..10];
@@ -70,7 +72,7 @@ fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr) -> vec!(vec!(square
         row.push(square_from_char(*c as char))
     }
     grid.push(row);
-    let width = grid[0].len();
+    let width = grid.get(0).len();
     for row in grid.iter() { assert!(row.len() == width) }
     grid
 }
index d625f6bcf92fa3d0abcb82b474d76776fae912ca..c88f8b42d4242fa35533f21619c40b6409508f46 100644 (file)
@@ -24,7 +24,7 @@ fn to_bools(bitv: Storage) -> Vec<bool> {
     Vec::from_fn(8, |i| {
         let w = i / 64;
         let b = i % 64;
-        let x = 1u64 & (bitv.storage[w] >> b);
+        let x = 1u64 & (*bitv.storage.get(w) >> b);
         x == 1u64
     })
 }
@@ -36,7 +36,7 @@ pub fn main() {
     let bools2 = to_bools(Storage{storage: vec!(0b01100100)});
 
     for i in range(0u, 8) {
-        println!("{} => {} vs {}", i, bools[i], bools2[i]);
+        println!("{} => {} vs {}", i, *bools.get(i), *bools2.get(i));
     }
 
     assert_eq!(bools, bools2);
index bc33bb72aa81a1e703e7c1016d55b0e45505834a..d2acf66003d7d2468d32e0ce28161fcd9d119d71 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 type Connection = 'static |Vec<u8> |;
 
 fn f() -> Option<Connection> {
index 96ecc81edccc63f39d3ca4521094df258556b3c9..fb4d7cedd4b0bb8e8b4c3de8bb652315f33705aa 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 struct trie_node {
     content: Vec<~str> ,
     children: Vec<trie_node> ,
index 330cfdba24529872ae4d54d4a108be845daa3a22..a107670075d238b29e43bcd85e213d4753b67b52 100644 (file)
 
 // Extern mod controls linkage. Use controls the visibility of names to modules that are
 // already linked in. Using WriterUtil allows us to use the write_line method.
+
 use std::str;
 use std::slice;
 use std::fmt;
+use std::vec_ng::Vec;
 
 // Represents a position on a canvas.
 struct Point {
@@ -62,9 +64,10 @@ fn drop(&mut self) {}
 fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt {
     // Use an anonymous function to build a vector of vectors containing
     // blank characters for each position in our canvas.
-    let lines = slice::build(Some(height), |push| {
-        for _ in range(0, height) { push(slice::from_elem(width, '.')); }
-    });
+    let mut lines = Vec::new();
+    for _ in range(0, height) {
+        lines.push(Vec::from_elem(width, '.'));
+    }
 
     // Rust code often returns values by omitting the trailing semi-colon
     // instead of using an explicit return statement.
@@ -85,8 +88,8 @@ fn add_pt(&mut self, x: int, y: int) {
                 // element is:
                 // 1) potentially large
                 // 2) needs to be modified
-                let row = &mut self.lines[v];
-                row[h] = self.fill;
+                let row = self.lines.get_mut(v);
+                *row.get_mut(h) = self.fill;
             }
         }
     }
@@ -97,7 +100,7 @@ fn add_pt(&mut self, x: int, y: int) {
 impl fmt::Show for AsciiArt {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         // Convert each line into a string.
-        let lines = self.lines.map(|line| str::from_chars(*line));
+        let lines = self.lines.map(|line| str::from_chars(line.as_slice()));
 
         // Concatenate the lines together using a new-line.
         write!(f.buf, "{}", lines.connect("\n"))
index c5ae1460a2cdcc528df40cb1bd24e950a8d6e0da..d27de2ea0ca4c9c7e234f203cc6810e5ca46cf7e 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::task;
+use std::vec_ng::Vec;
 
 type RingBuffer = Vec<f64> ;
 type SamplesFn = proc(samples: &RingBuffer);
@@ -23,7 +24,7 @@ fn foo(name: ~str, samples_chan: Sender<Msg>) {
         let mut samples_chan = samples_chan;
         let callback: SamplesFn = proc(buffer) {
             for i in range(0u, buffer.len()) {
-                println!("{}: {}", i, buffer[i])
+                println!("{}: {}", i, *buffer.get(i))
             }
         };
         samples_chan.send(GetSamples(name.clone(), callback));
index 07a520db20b98bc9ebf802ce703f347368cbea5c..7fb6b4664794ae65cbf2b166c641c7aba91ddf8d 100644 (file)
@@ -8,13 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 struct HasNested {
     nest: Vec<Vec<int> > ,
 }
 
 impl HasNested {
     fn method_push_local(&mut self) {
-        self.nest[0].push(0);
+        self.nest.get_mut(0).push(0);
     }
 }
 
index fbd4e2cd7425a197fb125f140220429d47afeefa..13285179df8ca8ca00d023e72b941b7418bbbc48 100644 (file)
@@ -14,7 +14,9 @@
 // byproducts in vtable records.
 
 extern crate serialize;
+
 use serialize::{json, Decodable};
+use std::vec_ng::Vec;
 
 pub fn main() {
     let json = json::from_str("[1]").unwrap();
index 0a79b1335c80c866958ba0dce9e42af329e47350..56461b647d87a2597694a5cec7ffb7989768b940 100644 (file)
@@ -18,6 +18,8 @@ struct with that reference results in an ICE.
 to traits.
 */
 
+use std::vec_ng::Vec;
+
 // original
 trait Inner {
     fn print(&self);
index 079c2d9a1c4f6f5b229e7ac66b95d2abc8d0d5f7..ce87b0adde5f40d7d2c0c2a081f2bff19c33ec1e 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn swap(f: |Vec<int> | -> Vec<int> ) -> Vec<int> {
     let x = vec!(1, 2, 3);
     f(x)
index b2918b3ea391a0c45171b568da3d71dec60c79da..66ddc1118d0ddccc4a9106042dadf5dbe66e828c 100644 (file)
@@ -11,7 +11,6 @@
 #[feature(managed_boxes)];
 
 fn assert_repr_eq<T>(obj : T, expected : ~str) {
-
     assert_eq!(expected, format!("{:?}", obj));
 }
 
@@ -19,14 +18,12 @@ pub fn main() {
     let abc = [1, 2, 3];
     let tf = [true, false];
     let x  = [(), ()];
-    let y = vec!((), ());
     let slice = x.slice(0,1);
     let z = @x;
 
     assert_repr_eq(abc, ~"[1, 2, 3]");
     assert_repr_eq(tf, ~"[true, false]");
     assert_repr_eq(x, ~"[(), ()]");
-    assert_repr_eq(y, ~"~[(), ()]");
     assert_repr_eq(slice, ~"&[()]");
     assert_repr_eq(&x, ~"&[(), ()]");
     assert_repr_eq(z, ~"@[(), ()]");
index 6926018bafa09b8065c4859801b03600ee646d2f..32ec1e674db7f9449aa9f263d600a858b1d19ad2 100644 (file)
@@ -16,6 +16,8 @@
 // from a vector to a slice. The drop glue was being invoked on
 // the temporary slice with a wrong type, triggering an LLVM assert.
 
+use std::vec_ng::Vec;
+
 struct Thing1<'a> {
     baz: &'a [~int],
     bar: ~u64,
@@ -32,7 +34,7 @@ pub fn main() {
         bar: ~32,
     };
     Thing1 {
-        baz: Vec::new(),
+        baz: Vec::new().as_slice(),
         bar: ~32,
     };
     let _t2_fixed = Thing2 {
@@ -40,7 +42,7 @@ pub fn main() {
         bar: 32,
     };
     Thing2 {
-        baz: Vec::new(),
+        baz: Vec::new().as_slice(),
         bar: 32,
     };
 }
diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs
deleted file mode 100644 (file)
index f215958..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn double<T:Clone>(a: T) -> Vec<T> { return vec!(a.clone()) + vec!(a); }
-
-fn double_int(a: int) -> Vec<int> { return vec!(a) + vec!(a); }
-
-pub fn main() {
-    let mut d = double(1);
-    assert_eq!(d[0], 1);
-    assert_eq!(d[1], 1);
-
-    d = double_int(1);
-    assert_eq!(d[0], 1);
-    assert_eq!(d[1], 1);
-}
index cd58689a19e311badd7c2b91a28d85f5e0280435..9c8dd152e25b5e0935ec6d9a3972b9107bdac1bf 100644 (file)
@@ -8,5 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn f(_a: Vec<int> ) { }
 pub fn main() { f(vec!(1, 2, 3, 4, 5)); }
index 81ff6fd7adc9419b85724a7f4770e18760ca44d6..1d617de30ea723e74b73c63a209e81c9556ea318 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::task;
+use std::vec_ng::Vec;
 
 fn producer(tx: &Sender<Vec<u8>>) {
     tx.send(
index 39eef6526a60dbabb0d72e9d86b0c3ba95be6f11..05941b0142c8a428259108f8740d8de9084efed9 100644 (file)
@@ -11,6 +11,8 @@
 // This should typecheck even though the type of e is not fully
 // resolved when we finish typechecking the ||.
 
+use std::vec_ng::Vec;
+
 struct Refs { refs: Vec<int> , n: int }
 
 pub fn main() {
index c04a595ac2407ef788cf39b5452398bcfa62047d..22a0c9005bafc3dbacf37501f5e7eb40ec6fde0f 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn take(x: int) -> int {x}
 
 fn the_loop() {
diff --git a/src/test/run-pass/log-str.rs b/src/test/run-pass/log-str.rs
deleted file mode 100644 (file)
index c912fd6..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::repr;
-
-pub fn main() {
-    let act = repr::repr_to_str(&vec!(1, 2, 3));
-    assert_eq!(~"~[1, 2, 3]", act);
-
-    let act = format!("{:?}/{:6?}", vec!(1, 2, 3), ~"hi");
-    assert_eq!(act, ~"~[1, 2, 3]/~\"hi\" ");
-}
index ba8ba6263df0784c20dedda5338c609632271439..38952fc4daad27f9578d4eda7ead27ea27e5ddef 100644 (file)
 
 // Tests that matching rvalues with drops does not crash.
 
+use std::vec_ng::Vec;
+
 pub fn main() {
     match vec!(1, 2, 3) {
         x => {
             assert_eq!(x.len(), 3);
-            assert_eq!(x[0], 1);
-            assert_eq!(x[1], 2);
-            assert_eq!(x[2], 3);
+            assert_eq!(*x.get(0), 1);
+            assert_eq!(*x.get(1), 2);
+            assert_eq!(*x.get(2), 3);
         }
     }
 }
index 5df6738797d795576b662ce04b1f0741f7343ba1..182aa94700658b9aca998019f9d33d4c6260ceb1 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-fast
 
+use std::vec_ng::Vec;
+
 trait vec_monad<A> {
     fn bind<B>(&self, f: |&A| -> Vec<B> ) -> Vec<B> ;
 }
index b27914fff80be1a7739277e3f63e6bb777260c5d..34e169f3d61a925acb39f09d0f63c7fa4232ae9f 100644 (file)
@@ -8,7 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn test(foo: ~Vec<int> ) { assert!((foo[0] == 10)); }
+use std::vec_ng::Vec;
+
+fn test(foo: ~Vec<int> ) { assert!((*foo.get(0) == 10)); }
 
 pub fn main() {
     let x = ~vec!(10);
index 2cc56ec9227070febc37cdf7de1b18b0da09bed2..89316c37a3edaf5e3dd49334c74189b33f6e6d8a 100644 (file)
@@ -10,7 +10,9 @@
 
 #[feature(managed_boxes)];
 
-fn test(foo: @Vec<int> ) { assert!((foo[0] == 10)); }
+use std::vec_ng::Vec;
+
+fn test(foo: @Vec<int> ) { assert!((*foo.get(0) == 10)); }
 
 pub fn main() {
     let x = @vec!(10);
index eb236b29263bcb85368350d8ce87c9cb1b369213..28dd89edd629d79d758dc2c49bc5090342be3bc7 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn grow(v: &mut Vec<int>) {
+fn grow(v: &mut Vec<int> ) {
     v.push(1);
 }
 
index 9a83907c66f34bbc38827e587cba4c4ce3ba21c6..1f4196ef06f847b9c06bcf312ccfbcac72a2740d 100644 (file)
@@ -11,6 +11,8 @@
 #[feature(managed_boxes)];
 #[allow(unused_mut)];
 
+use std::vec_ng::Vec;
+
 struct Pair { a: int, b: int}
 
 pub fn main() {
index 20e2675fccf85098d481b4a4f510df64424bf6b1..3d4639b2506a05ce0f22bdd9ae8b641959441cbc 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 #[deriving(Clone)]
 struct myvec<X>(Vec<X> );
 
@@ -18,13 +20,15 @@ fn myvec_deref<X:Clone>(mv: myvec<X>) -> Vec<X> {
 
 fn myvec_elt<X>(mv: myvec<X>) -> X {
     let myvec(v) = mv;
-    return v[0];
+    return v.move_iter().next().unwrap();
 }
 
 pub fn main() {
     let mv = myvec(vec!(1, 2, 3));
-    assert_eq!(myvec_deref(mv.clone())[1], 2);
+    let mv_clone = mv.clone();
+    let mv_clone = myvec_deref(mv_clone);
+    assert_eq!(*mv_clone.get(1), 2);
     assert_eq!(myvec_elt(mv.clone()), 1);
     let myvec(v) = mv;
-    assert_eq!(v[2], 3);
+    assert_eq!(*v.get(2), 3);
 }
index 117cd6d572ee06e071abf40c91a1a184c866f80b..c071983fdf334333d51755e77236da28654137ce 100644 (file)
@@ -11,6 +11,7 @@
 #[feature(macro_rules)];
 
 use std::{option, cast};
+use std::vec_ng::Vec;
 
 // Iota-reduction is a rule in the Calculus of (Co-)Inductive Constructions,
 // which "says that a destructor applied to an object built from a constructor
index 9ce68fa8ffcdb3453a8e978c68f17f3ea8e8dea1..75a98913c971a49e26eccf90ac734dc230109427 100644 (file)
@@ -11,6 +11,7 @@
 #[feature(macro_rules)];
 
 use std::mem;
+use std::vec_ng::Vec;
 
 enum E<T> { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) }
 struct S<T>(int, T);
@@ -41,6 +42,5 @@ pub fn main() {
     check_type!(~int);
     check_type!(@int);
     check_type!(~str);
-    check_type!(Vec<int> );
     check_type!(extern fn());
 }
index 7a0c7b34d2f3705e2371a3acd822d82f4a33022e..ec284b24dbd1a9b70dea0b19cb569f35f96d953b 100644 (file)
@@ -12,6 +12,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 // Test invoked `&self` methods on owned objects where the values
 // closed over contain managed values. This implies that the ~ boxes
 // will have headers that must be skipped over.
@@ -31,13 +33,13 @@ fn foo(&self) -> uint {
 }
 
 pub fn main() {
-    let foos: vec!( ~FooTrait: ) = vec!(
+    let foos: Vec<~FooTrait:> = vec!(
         ~BarStruct{ x: @0 } as ~FooTrait:,
         ~BarStruct{ x: @1 } as ~FooTrait:,
         ~BarStruct{ x: @2 } as ~FooTrait:
     );
 
     for i in range(0u, foos.len()) {
-        assert_eq!(i, foos[i].foo());
+        assert_eq!(i, foos.get(i).foo());
     }
 }
index f9f59f88bf1fdf53d36f1f26e7d6cc9cc146537b..13258bed80f6c1761fe79cef92e1d1f6e57cf60a 100644 (file)
@@ -12,6 +12,8 @@
 // closed over do not contain managed values, and thus the ~ boxes do
 // not have headers.
 
+use std::vec_ng::Vec;
+
 trait FooTrait {
     fn foo(&self) -> uint;
 }
@@ -27,13 +29,13 @@ fn foo(&self) -> uint {
 }
 
 pub fn main() {
-    let foos: vec!( ~FooTrait ) = vec!(
+    let foos: Vec<~FooTrait> = vec!(
         ~BarStruct{ x: 0 } as ~FooTrait,
         ~BarStruct{ x: 1 } as ~FooTrait,
         ~BarStruct{ x: 2 } as ~FooTrait
     );
 
     for i in range(0u, foos.len()) {
-        assert_eq!(i, foos[i].foo());
+        assert_eq!(i, foos.get(i).foo());
     }
 }
index 865e1cc601b3960805db16e921f3ecdaba79e882..c918202b31c1f21a1aebcdfa7226636e7a867799 100644 (file)
@@ -12,6 +12,7 @@
 // takes its argument *by reference*.
 
 use std::ops::Index;
+use std::vec_ng::Vec;
 
 struct AssociationList<K,V> {
     pairs: Vec<AssociationPair<K,V>> }
index 0ff282b68f8deeca196a6c48d960fe9d72339012..43f68b42329105bbceaf85a3446822985d0947ac 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::cell::RefCell;
 use std::rc::Rc;
+use std::vec_ng::Vec;
 
 #[deriving(Eq, Show)]
 struct Point {
@@ -43,7 +44,9 @@ pub fn main() {
     assert_eq!(*(*p).borrow(), Point {x: 3, y: 5});
 
     let v = Rc::new(RefCell::new(vec!(1, 2, 3)));
-    (*(*v).borrow_mut())[0] = 3;
-    (*(*v).borrow_mut())[1] += 3;
-    assert_eq!(((*(*v).borrow())[0], (*(*v).borrow())[1], (*(*v).borrow())[2]), (3, 5, 3));
+    *(*(*v).borrow_mut()).get_mut(0) = 3;
+    *(*(*v).borrow_mut()).get_mut(1) += 3;
+    assert_eq!((*(*(*v).borrow()).get(0),
+                *(*(*v).borrow()).get(1),
+                *(*(*v).borrow()).get(2)), (3, 5, 3));
 }
index b297fc7e13f77b232905f5d37942374673acd9d3..02c030f3845c309804579347d45215228c57cdba 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::mem;
+use std::vec_ng::Vec;
 
 #[packed]
 struct S<T, S> {
index d5f1caaf74da1570b70580abb0d1a8d3067ad241..cd5ce150bcb0d5412207f29107417be09f7c971d 100644 (file)
 
 // Check that functions can modify local state.
 
+use std::vec_ng::Vec;
+
 fn sums_to(v: Vec<int> , sum: int) -> bool {
     let mut i = 0u;
     let mut sum0 = 0;
     while i < v.len() {
-        sum0 += v[i];
+        sum0 += *v.get(i);
         i += 1u;
     }
     return sum0 == sum;
@@ -24,7 +26,7 @@ fn sums_to_using_uniq(v: Vec<int> , sum: int) -> bool {
     let mut i = 0u;
     let mut sum0 = ~0;
     while i < v.len() {
-        *sum0 += v[i];
+        *sum0 += *v.get(i);
         i += 1u;
     }
     return *sum0 == sum;
@@ -34,7 +36,7 @@ fn sums_to_using_rec(v: Vec<int> , sum: int) -> bool {
     let mut i = 0u;
     let mut sum0 = F {f: 0};
     while i < v.len() {
-        sum0.f += v[i];
+        sum0.f += *v.get(i);
         i += 1u;
     }
     return sum0.f == sum;
@@ -46,7 +48,7 @@ fn sums_to_using_uniq_rec(v: Vec<int> , sum: int) -> bool {
     let mut i = 0u;
     let mut sum0 = F {f: ~0};
     while i < v.len() {
-        *sum0.f += v[i];
+        *sum0.f += *v.get(i);
         i += 1u;
     }
     return *sum0.f == sum;
index 8597bf39e0ef5346d71555b8a7fa28344996d811..9e2be5178557517abe41449a46746f2037371067 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 trait sum {
     fn sum_(self) -> int;
 }
@@ -23,17 +25,17 @@ fn call_sum(x: &[int]) -> int { x.sum_() }
 
 pub fn main() {
     let x = vec!(1, 2, 3);
-    let y = call_sum(x);
+    let y = call_sum(x.as_slice());
     println!("y=={}", y);
     assert_eq!(y, 6);
 
     let x = vec!(1, 2, 3);
-    let y = x.sum_();
+    let y = x..as_slice().sum_();
     println!("y=={}", y);
     assert_eq!(y, 6);
 
     let x = vec!(1, 2, 3);
-    let y = x.sum_();
+    let y = x.as_slice().sum_();
     println!("y=={}", y);
     assert_eq!(y, 6);
 }
index 22f301410285aa87281ed74f0d9a521b76c4231f..3b8f7c4ae610124d8f7f938d39791a935e3f60a7 100644 (file)
@@ -11,6 +11,7 @@
 #[feature(managed_boxes)];
 
 use std::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque};
+use std::vec_ng::Vec;
 
 struct MyVisitor {
     types: Vec<~str> ,
@@ -151,10 +152,11 @@ pub fn main() {
     visit_ty::<int>(&mut v);
     visit_ty::<i8>(&mut v);
     visit_ty::<i16>(&mut v);
-    visit_ty::<Vec<int> >(&mut v);
 
     for s in v.types.iter() {
         println!("type: {}", (*s).clone());
     }
-    assert_eq!(v.types.clone(), vec!(~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"));
+
+    let vec_types: Vec<~str> = v.types.clone().move_iter().collect();
+    assert_eq!(vec_types, vec!(~"bool", ~"int", ~"i8", ~"i16"));
 }
index b17b025eb58a8a0ec06856c6ff0786ab781693e3..f3f0724bd574a470e333402e32f657a979fa7da8 100644 (file)
@@ -8,16 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn foo(x: &[int]) -> int {
     x[0]
 }
 
 pub fn main() {
     let p = vec!(1,2,3,4,5);
-    let r = foo(p);
+    let r = foo(p.as_slice());
     assert_eq!(r, 1);
 
     let p = vec!(5,4,3,2,1);
-    let r = foo(p);
+    let r = foo(p.as_slice());
     assert_eq!(r, 5);
 }
index 3b5ff3f6092fc18b2bbed10dc99cbfffece812c7..3f86f8612ed4c9983bea6078a20192afa2756ea4 100644 (file)
@@ -11,6 +11,8 @@
 // Test lifetimes are linked properly when we create dependent region pointers.
 // Issue #3148.
 
+use std::vec_ng::Vec;
+
 struct A {
     value: B
 }
@@ -41,7 +43,7 @@ fn get_v2<'v>(a: &'v A, i: uint) -> &'v int {
 
 fn get_v3<'v>(a: &'v A, i: uint) -> &'v int {
     let foo = &a.value;
-    &foo.v3[i]
+    foo.v3.get(i)
 }
 
 fn get_v4<'v>(a: &'v A, _i: uint) -> &'v int {
@@ -96,7 +98,7 @@ pub fn main() {
     assert_eq!(*p, a.value.v2[1]);
 
     let p = get_v3(&a, 1);
-    assert_eq!(*p, a.value.v3[1]);
+    assert_eq!(*p, *a.value.v3.get(1));
 
     let p = get_v4(&a, 1);
     assert_eq!(*p, a.value.v4.f);
index 8cbdff6691a4a73085811762bf6fa444097aafcc..3a472decc7c28d59fee40d96b483b042a0c75ad0 100644 (file)
@@ -11,6 +11,8 @@
 // Test lifetimes are linked properly when we autoslice a vector.
 // Issue #3148.
 
+use std::vec_ng::Vec;
+
 fn subslice1<'r>(v: &'r [uint]) -> &'r [uint] { v }
 
 fn both<'r>(v: &'r [uint]) -> &'r [uint] {
@@ -19,5 +21,5 @@ fn both<'r>(v: &'r [uint]) -> &'r [uint] {
 
 pub fn main() {
     let v = vec!(1,2,3);
-    both(v);
+    both(v.as_slice());
 }
index 67542a5ded1d844c305749eda55b1bb7ca8b56b1..b031cfea93e06e1772932ad8d27e06cbdd9acbd7 100644 (file)
@@ -8,11 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn view<'r, T>(x: &'r [T]) -> &'r [T] {x}
 
 pub fn main() {
     let v = vec!(1, 2, 3);
-    let x = view(v);
-    let y = view(x);
-    assert!((v[0] == x[0]) && (v[0] == y[0]));
+    let x = view(v.as_slice());
+    let y = view(x.as_slice());
+    assert!((*v.get(0) == x[0]) && (*v.get(0) == y[0]));
 }
index 7c87c858d42a734f0ec7f04c9dfa2b8236ad2c47..fa2050c69f234b2a89e6d0c5e49f45699fc74083 100644 (file)
@@ -24,6 +24,7 @@
 use std::cast;
 use std::libc;
 use std::mem;
+use std::vec_ng::Vec;
 
 type Type<'tcx> = &'tcx TypeStructure<'tcx>;
 
index ddb34edad98614a63cc5bf4bf68dda6937c81e60..8694040269c48db832e704995c5d5cfe9ce65421 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+use std::vec_ng::Vec;
 
 pub fn main() {
     assert!((~"hello" < ~"hellr"));
index e4b96856560f575439fa423153f10681a3688c82..02ea8f61938818e551d43bfda745883b19895893 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 fn foo(c: Vec<int> ) {
     let a: int = 5;
     let mut b: Vec<int> = Vec::new();
index 058041ff7107ea81975fa9f49f20e26eeb322b98..c52a0e54279a8f6588c9158003e2348450e04c67 100644 (file)
@@ -15,6 +15,8 @@
 // interior record which is then itself interior to
 // something else, shape calculations were off.
 
+use std::vec_ng::Vec;
+
 #[deriving(Clone)]
 enum opt_span {
     //hack (as opposed to option), to make `span` compile
@@ -41,7 +43,7 @@ struct Spanned<T> {
 struct Path_ {
     global: bool,
     idents: Vec<~str> ,
-    types: vec!(@ty),
+    types: Vec<@ty>,
 }
 
 type path = Spanned<Path_>;
@@ -56,7 +58,11 @@ struct X {
 pub fn main() {
     let sp: Span = Span {lo: 57451u, hi: 57542u, expanded_from: os_none};
     let t: @ty = @Spanned { data: 3u, span: sp };
-    let p_: Path_ = Path_ { global: true, idents: vec!(~"hi"), types: Vec<t> };
+    let p_: Path_ = Path_ {
+        global: true,
+        idents: vec!(~"hi"),
+        types: vec!(t),
+    };
     let p: path = Spanned { data: p_, span: sp };
     let x = X { sp: sp, path: p };
     println!("{:?}", x.path.clone());
index f43011df4c257affa3966a65f3a5038def87802d..9b06e1758863f11655f539f58954a04c5fa7686b 100644 (file)
@@ -8,13 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
+use std::vec_ng::Vec;
 
 enum clam<T> { a(T, int), b, }
 
 fn uhoh<T>(v: Vec<clam<T>> ) {
-    match v[1] {
+    match *v.get(1) {
       a::<T>(ref _t, ref u) => {
           println!("incorrect");
           println!("{:?}", u);
index d727f66d948f8097f388c422d044f1f90aa9a588..5a5e9f7353dc6a35ba854ec10597572d78ba0efd 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-fast
 
+use std::vec_ng::Vec;
+
 pub trait plus {
     fn plus(&self) -> int;
 }
@@ -60,8 +62,10 @@ pub fn main() {
     assert_eq!((~"hi").plus(), 200);
 
     assert_eq!((vec!(1)).length_().str(), ~"1");
-    assert_eq!((vec!(3, 4)).map_(|a| *a + 4 )[0], 7);
-    assert_eq!((vec!(3, 4)).map_::<uint>(|a| *a as uint + 4u )[0], 7u);
+    let vect = vec!(3, 4).map_(|a| *a + 4);
+    assert_eq!(*vect.get(0), 7);
+    let vect = (vec!(3, 4)).map_::<uint>(|a| *a as uint + 4u);
+    assert_eq!(*vect.get(0), 7u);
     let mut x = 0u;
     10u.multi(|_n| x += 2u );
     assert_eq!(x, 20u);
index 1dbd29a781effb127c488a3769c1a88a39dfbc5b..1a844061888286106f64e19fe0e529653680569d 100644 (file)
@@ -9,14 +9,15 @@
 // except according to those terms.
 
 use std::mem::swap;
+use std::vec_ng::Vec;
 
 pub fn main() {
     let mut a: Vec<int> = vec!(0, 1, 2, 3, 4, 5, 6);
     a.swap(2, 4);
-    assert_eq!(a[2], 4);
-    assert_eq!(a[4], 2);
+    assert_eq!(*a.get(2), 4);
+    assert_eq!(*a.get(4), 2);
     let mut n = 42;
-    swap(&mut n, &mut a[0]);
-    assert_eq!(a[0], 42);
+    swap(&mut n, a.get_mut(0));
+    assert_eq!(*a.get(0), 42);
     assert_eq!(n, 0);
 }
index 416aaec40f17bd76f22ae5cafbe0dc120bc3a15c..69ede9b4d0508a9788ca2f56352a12d30d37880d 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::cmp;
+use std::vec_ng::Vec;
 
 // Tests of ports and channels on various types
 fn test_rec() {
@@ -29,9 +30,9 @@ fn test_vec() {
     let v0: Vec<int> = vec!(0, 1, 2);
     tx.send(v0);
     let v1 = rx.recv();
-    assert_eq!(v1[0], 0);
-    assert_eq!(v1[1], 1);
-    assert_eq!(v1[2], 2);
+    assert_eq!(*v1.get(0), 0);
+    assert_eq!(*v1.get(1), 1);
+    assert_eq!(*v1.get(2), 2);
 }
 
 fn test_str() {
index a239a2de78aa264e5d0c6440188de2bfcca2b2d7..471a55ee418d1b1adf26bfd4adfd8ee4e9c0cefe 100644 (file)
@@ -11,6 +11,7 @@
 // ignore-fast
 
 use std::task;
+use std::vec_ng::Vec;
 
 pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); }
 
index 7d37993ad7589604740b6d28f7590ec58a229d39..40d0f4017589380a5a20f885f0619921a2dcfd74 100644 (file)
@@ -19,6 +19,7 @@
 
 use sync::Arc;
 use std::task;
+use std::vec_ng::Vec;
 
 trait Pet {
     fn name(&self, blk: |&str|);
@@ -90,22 +91,14 @@ fn check_legs(arc: Arc<Vec<~Pet:Share+Send>>) {
     }
     assert!(legs == 12);
 }
-<<<<<<< HEAD
-fn check_names(arc: Arc<~[~Pet:Share+Send]>) {
-=======
-fn check_names(arc: Arc<Vec<~Pet:Freeze+Send> >) {
->>>>>>> test: Automatically remove all `~[T]` from tests.
+fn check_names(arc: Arc<Vec<~Pet:Share+Send>>) {
     for pet in arc.get().iter() {
         pet.name(|name| {
             assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8);
         })
     }
 }
-<<<<<<< HEAD
-fn check_pedigree(arc: Arc<~[~Pet:Share+Send]>) {
-=======
-fn check_pedigree(arc: Arc<Vec<~Pet:Freeze+Send> >) {
->>>>>>> test: Automatically remove all `~[T]` from tests.
+fn check_pedigree(arc: Arc<Vec<~Pet:Share+Send>>) {
     for pet in arc.get().iter() {
         assert!(pet.of_good_pedigree());
     }
index a75a1b61c593c8edf463de528cc29446b9970ab0..5cc40f2dd37cb6f92b99d2772da6851a1c5074f2 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-fast
 
+use std::vec_ng::Vec;
+
 trait to_str {
     fn to_string(&self) -> ~str;
 }
@@ -31,7 +33,7 @@ fn map<U>(&self, f: |&T| -> U) -> Vec<U> {
         let mut r = Vec::new();
         // FIXME: #7355 generates bad code with VecIterator
         for i in range(0u, self.len()) {
-            r.push(f(&self[i]));
+            r.push(f(self.get(i)));
         }
         r
     }
@@ -48,5 +50,5 @@ pub fn main() {
     assert_eq!(foo(vec!(1)), vec!(~"hi"));
     assert_eq!(bar::<int, Vec<int> >(vec!(4, 5)), vec!(~"4", ~"5"));
     assert_eq!(bar::<~str, Vec<~str> >(vec!(~"x", ~"y")), vec!(~"x", ~"y"));
-    assert_eq!(bar::<(), vec!(())>(vec!(())), vec!(~"()"));
+    assert_eq!(bar::<(), Vec<()>>(vec!(())), vec!(~"()"));
 }
index f16f5c1a419c759b63a393c63f6da318b40b5edf..fa320bba982565695b5693d6c5b68a579e75ff09 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-fast
 
+use std::vec_ng::Vec;
+
 trait to_str {
     fn to_string(&self) -> ~str;
 }
index f37bfe19ad3a05789c2b790dfc60e86531e5a5eb..42ce18dccaff9e47a0e4d1efecbb8ce4ace10336 100644 (file)
@@ -19,7 +19,6 @@ struct Foo<T> {
 pub fn main() {
     unsafe {
         assert_eq!((*get_tydesc::<int>()).name, "int");
-        assert_eq!((*get_tydesc::<Vec<int> >()).name, "~[int]");
         assert_eq!((*get_tydesc::<Foo<uint>>()).name, "Foo<uint>");
     }
 }
index b8312bcb2823a5888c0db62411c6ad0215b98a50..c0a22bacfd21eb4fe706daa03f5e55edf45fa03d 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 struct S<T> {
     a: T,
     b: uint,
index 1c026bf91d11b0fbf973b15696f31e0a8f4784c7..87ce07c596ce5f9332a5652113656405a8772f06 100644 (file)
@@ -8,7 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 pub fn main() {
     let i = ~vec!(100);
-    assert_eq!(i[0], 100);
+    assert_eq!(*i.get(0), 100);
 }
index 762afbe15e8075b28997b9f2ec0113e726a98528..9e73039a0a76529f88d02206f5a91a875f8b4d9a 100644 (file)
@@ -8,16 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
+
 pub fn main() {
     let mut a = vec!(~10);
     let b = a.clone();
 
-    assert_eq!(*a[0], 10);
-    assert_eq!(*b[0], 10);
+    assert_eq!(**a.get(0), 10);
+    assert_eq!(**b.get(0), 10);
 
     // This should only modify the value in a, not b
-    *a[0] = 20;
+    **a.get_mut(0) = 20;
 
-    assert_eq!(*a[0], 20);
-    assert_eq!(*b[0], 10);
+    assert_eq!(**a.get(0), 20);
+    assert_eq!(**b.get(0), 10);
 }
index 7f0aa93042a1673456ff9fce807799f26d586b3d..82d3a29d901ba07e7a57f5cb603ce149e1d40118 100644 (file)
@@ -9,5 +9,6 @@
 // except according to those terms.
 
 pub fn main() {
-    assert!((vec!(~100))[0] == ~100);
+    let vect = vec!(~100);
+    assert!(*vect.get(0) == ~100);
 }
index 0e85c67edb7846a086ac2f21b41c4e4daa1afda2..f63934159558fcb523449ba5dacf5bf5493347b7 100644 (file)
@@ -9,17 +9,18 @@
 // except according to those terms.
 
 use std::str;
+use std::vec_ng::Vec;
 
 pub fn main() {
     // Chars of 1, 2, 3, and 4 bytes
-    let chs: ~[char] = ~['e', 'é', '€', '\U00010000'];
-    let s: ~str = str::from_chars(chs);
-    let schs: ~[char] = s.chars().collect();
+    let chs: Vec<char> = vec!('e', 'é', '€', '\U00010000');
+    let s: ~str = str::from_chars(chs.as_slice());
+    let schs: Vec<char> = s.chars().collect();
 
     assert!(s.len() == 10u);
     assert!(s.char_len() == 4u);
     assert!(schs.len() == 4u);
-    assert!(str::from_chars(schs) == s);
+    assert!(str::from_chars(schs.as_slice()) == s);
     assert!(s.char_at(0u) == 'e');
     assert!(s.char_at(1u) == 'é');
 
index 9b42a25956ee90482e66a38623267f1ffd71424e..0a9a65ac0e7550a21edca89dd2afe8355764e2c2 100644 (file)
@@ -8,12 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec;
+
 pub fn main() {
-    let a: ~[int] = ~[1, 2, 3, 4, 5];
-    let b: ~[int] = ~[6, 7, 8, 9, 0];
-    let v: ~[int] = a + b;
+    let a: Vec<int> = vec!(1, 2, 3, 4, 5);
+    let b: Vec<int> = vec!(6, 7, 8, 9, 0);
+    let v: Vec<int> = vec::append(a, b.as_slice());
     println!("{}", v[9]);
-    assert_eq!(v[0], 1);
-    assert_eq!(v[7], 8);
-    assert_eq!(v[9], 0);
+    assert_eq!(*v.get(0), 1);
+    assert_eq!(*v.get(7), 8);
+    assert_eq!(*v.get(9), 0);
 }
index 270b1cb895d599871580c5117894edb14048296e..675c06c257042f595c7c0a0ae160e5c4ec3d4a0c 100644 (file)
@@ -10,6 +10,8 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 struct Pair { x: int, y: int }
 
 pub fn main() {
index e51d898e1d46effb237de4a41b3b148f6a2a9f48..4414da91ce7650f77321de771f91881a4bad4132 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+use std::vec_ng::Vec;
 
 pub fn main() {
     let mut v = vec!(1);
@@ -16,9 +16,9 @@ pub fn main() {
     v.push(3);
     v.push(4);
     v.push(5);
-    assert_eq!(v[0], 1);
-    assert_eq!(v[1], 2);
-    assert_eq!(v[2], 3);
-    assert_eq!(v[3], 4);
-    assert_eq!(v[4], 5);
+    assert_eq!(*v.get(0), 1);
+    assert_eq!(*v.get(1), 2);
+    assert_eq!(*v.get(2), 3);
+    assert_eq!(*v.get(3), 4);
+    assert_eq!(*v.get(4), 5);
 }
diff --git a/src/test/run-pass/vec-ivec-deadlock.rs b/src/test/run-pass/vec-ivec-deadlock.rs
deleted file mode 100644 (file)
index fc9ab27..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[allow(dead_assignment)];
-
-pub fn main() {
-    let a = vec!(1, 2, 3, 4, 5);
-    let mut b = vec!(a.clone(), a.clone());
-    b = b + b; // FIXME(#3387)---can't write b += b
-}
index 7239ae8a1d680e70c69f2188d6941cfbdc7b4571..815235ef980b7f087150b663ab795de9f29e5064 100644 (file)
@@ -8,10 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+use std::vec_ng::Vec;
 
 pub fn main() {
     let mut later: Vec<int> ;
     if true { later = vec!(1); } else { later = vec!(2); }
-    println!("{}", later[0]);
+    println!("{}", *later.get(0));
 }
diff --git a/src/test/run-pass/vec-trailing-comma.rs b/src/test/run-pass/vec-trailing-comma.rs
deleted file mode 100644 (file)
index 6831611..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Issue #2482.
-
-pub fn main() {
-    let v1: Vec<int> = vec!(10, 20, 30);
-    let v2: Vec<int> = vec!(10, 20, 30);
-    assert_eq!(v1[2], v2[2]);
-    let v3: Vec<int> = vec!(10);
-    let v4: Vec<int> = vec!(10);
-    assert_eq!(v3[0], v4[0]);
-}
index 06869bcb76e0e8118421642f9d1b02013d882dec..7fd3b57b0e524f9f14a7a855e39a79e51d67b9af 100644 (file)
@@ -8,17 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
+use std::vec_ng::Vec;
 
 pub fn main() {
     let v: Vec<int> = vec!(10, 20);
-    assert_eq!(v[0], 10);
-    assert_eq!(v[1], 20);
-    let mut x: int = 0;
-    assert_eq!(v[x], 10);
-    assert_eq!(v[x + 1], 20);
+    assert_eq!(*v.get(0), 10);
+    assert_eq!(*v.get(1), 20);
+    let mut x: uint = 0;
+    assert_eq!(*v.get(x), 10);
+    assert_eq!(*v.get(x + 1), 20);
     x = x + 1;
-    assert_eq!(v[x], 20);
-    assert_eq!(v[x - 1], 10);
+    assert_eq!(*v.get(x), 20);
+    assert_eq!(*v.get(x - 1), 10);
 }
index 72e1676bccb5a3745bfa88a8132eae9783bafccc..56624cecdca35517b5e9d7ea8b7db5b7d7aa6354 100644 (file)
@@ -10,4 +10,6 @@
 
 #[feature(managed_boxes)];
 
+use std::vec_ng::Vec;
+
 pub fn main() { let _quux: @Vec<uint> = @Vec::new(); }
index a7328267541ab9b7c47bef68edbf3a7b5b7ef106..9b3baf80f8fa919f676f5d9b25a5e2eba745bb3a 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::vec_ng::Vec;
 
 pub fn main() {
     let mut i: int = 90;