]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Remove ~[T] from the language
authorAlex Crichton <alex@alexcrichton.com>
Fri, 6 Jun 2014 17:27:49 +0000 (10:27 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 11 Jun 2014 22:02:17 +0000 (15:02 -0700)
The following features have been removed

* box [a, b, c]
* ~[a, b, c]
* box [a, ..N]
* ~[a, ..N]
* ~[T] (as a type)
* deprecated_owned_vector lint

All users of ~[T] should move to using Vec<T> instead.

68 files changed:
src/liballoc/heap.rs
src/libcollections/hash/mod.rs
src/libcollections/hash/sip.rs
src/libcollections/slice.rs
src/libcollections/str.rs
src/libcollections/vec.rs
src/libcore/clone.rs
src/libcore/failure.rs
src/libcore/fmt/mod.rs
src/libcore/intrinsics.rs
src/libcore/iter.rs
src/libcore/lib.rs
src/libcore/option.rs
src/libcore/ptr.rs
src/libcore/raw.rs
src/libcore/slice.rs
src/libdebug/reflect.rs
src/libdebug/repr.rs
src/libflate/lib.rs
src/libfourcc/lib.rs
src/libgetopts/lib.rs
src/libglob/lib.rs
src/libgraphviz/maybe_owned_vec.rs
src/libgreen/context.rs
src/libgreen/lib.rs
src/libhexfloat/lib.rs
src/liblog/lib.rs
src/libnum/lib.rs
src/libregex/lib.rs
src/librustc/driver/mod.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/lint.rs
src/librustrt/local_data.rs
src/libsemver/lib.rs
src/libserialize/json.rs
src/libserialize/serialize.rs
src/libstd/ascii.rs
src/libstd/io/comm_adapters.rs
src/libstd/io/extensions.rs
src/libstd/io/fs.rs
src/libstd/io/mem.rs
src/libstd/io/process.rs
src/libstd/io/util.rs
src/libstd/os.rs
src/libstd/path/mod.rs
src/libstd/path/posix.rs
src/libstd/path/windows.rs
src/libstd/prelude.rs
src/libstd/rand/reader.rs
src/libstd/to_str.rs
src/libsync/lib.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/libtest/lib.rs
src/libtest/stats.rs
src/libtime/lib.rs
src/test/bench/shootout-regex-dna.rs
src/test/compile-fail/borrowck-use-in-index-lvalue.rs
src/test/compile-fail/issue-2150.rs
src/test/compile-fail/lint-deprecated-owned-vector.rs [deleted file]
src/test/compile-fail/lint-heap-memory.rs
src/test/compile-fail/lint-unused-imports.rs
src/test/compile-fail/lint-unused-mut-variables.rs
src/test/compile-fail/lint-unused-unsafe.rs
src/test/run-pass/empty-allocation-non-null.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/overloaded-autoderef.rs
src/test/run-pass/reflect-visit-type.rs

index ba3180cefd665fc68dfb92155c84944f8ffb18ef..b03486a6c224c5ccd4cf580f5f686e0adb21e684 100644 (file)
@@ -155,24 +155,6 @@ unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint, align: uin
     alloc as *mut u8
 }
 
-// hack for libcore
-#[no_mangle]
-#[doc(hidden)]
-#[deprecated]
-#[cfg(not(test))]
-pub unsafe extern "C" fn rust_allocate(size: uint, align: uint) -> *mut u8 {
-    allocate(size, align)
-}
-
-// hack for libcore
-#[no_mangle]
-#[doc(hidden)]
-#[deprecated]
-#[cfg(not(test))]
-pub unsafe extern "C" fn rust_deallocate(ptr: *mut u8, size: uint, align: uint) {
-    deallocate(ptr, size, align)
-}
-
 #[cfg(test)]
 mod bench {
     extern crate test;
@@ -184,11 +166,4 @@ fn alloc_owned_small(b: &mut Bencher) {
             box 10
         })
     }
-
-    #[bench]
-    fn alloc_owned_big(b: &mut Bencher) {
-        b.iter(|| {
-            box [10, ..1000]
-        })
-    }
 }
index b484b2c8128f13f7b903ace57837b8d3a55e3aef..bd7bab456ba012cb962336c9498d895459d7ccf9 100644 (file)
@@ -213,13 +213,6 @@ fn hash(&self, state: &mut S) {
     }
 }
 
-impl<S: Writer, T: Hash<S>> Hash<S> for ~[T] {
-    #[inline]
-    fn hash(&self, state: &mut S) {
-        self.as_slice().hash(state);
-    }
-}
-
 impl<S: Writer, T: Hash<S>> Hash<S> for Vec<T> {
     #[inline]
     fn hash(&self, state: &mut S) {
index 74e93284d2ac4ff67d6ee222eeac98a86f0896d5..887b0fb0b8abe22b51facc05e4721fc023c24d66 100644 (file)
@@ -276,6 +276,7 @@ mod tests {
     use str::Str;
     use string::String;
     use slice::{Vector, ImmutableVector};
+    use vec::Vec;
 
     use super::super::{Hash, Writer};
     use super::{SipState, hash, hash_with_keys};
@@ -376,8 +377,8 @@ fn to_hex_str(r: &[u8, ..8]) -> String {
             s
         }
 
-        fn result_bytes(h: u64) -> ~[u8] {
-            box [(h >> 0) as u8,
+        fn result_bytes(h: u64) -> Vec<u8> {
+            vec![(h >> 0) as u8,
               (h >> 8) as u8,
               (h >> 16) as u8,
               (h >> 24) as u8,
index 1bc563686933e5efa23a23d4407ad8b8c878f55c..865da9eff136a1a6527965bb427ae0dcf104b04a 100644 (file)
 
 use core::prelude::*;
 
-use alloc::heap::{allocate, deallocate};
 use core::cmp;
-use core::finally::try_finally;
 use core::mem::size_of;
-use core::mem::transmute;
 use core::mem;
 use core::ptr;
 use core::iter::{range_step, MultiplicativeIterator};
@@ -255,18 +252,18 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 /// Generates even and odd permutations alternately.
 pub struct Permutations<T> {
     swaps: ElementSwaps,
-    v: ~[T],
+    v: Vec<T>,
 }
 
-impl<T: Clone> Iterator<~[T]> for Permutations<T> {
+impl<T: Clone> Iterator<Vec<T>> for Permutations<T> {
     #[inline]
-    fn next(&mut self) -> Option<~[T]> {
+    fn next(&mut self) -> Option<Vec<T>> {
         match self.swaps.next() {
             None => None,
             Some((0,0)) => Some(self.v.clone()),
             Some((a, b)) => {
                 let elt = self.v.clone();
-                self.v.swap(a, b);
+                self.v.as_mut_slice().swap(a, b);
                 Some(elt)
             }
         }
@@ -281,73 +278,20 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 /// Extension methods for vector slices with cloneable elements
 pub trait CloneableVector<T> {
     /// Copy `self` into a new owned vector
-    fn to_owned(&self) -> ~[T];
+    fn to_owned(&self) -> Vec<T>;
 
     /// Convert `self` into an owned vector, not making a copy if possible.
-    fn into_owned(self) -> ~[T];
+    fn into_owned(self) -> Vec<T>;
 }
 
 /// Extension methods for vector slices
 impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
     /// Returns a copy of `v`.
     #[inline]
-    fn to_owned(&self) -> ~[T] {
-        use RawVec = core::raw::Vec;
-        use core::num::{CheckedAdd, CheckedMul};
-        use core::ptr;
-
-        let len = self.len();
-        let data_size = len.checked_mul(&mem::size_of::<T>());
-        let data_size = data_size.expect("overflow in to_owned()");
-        let size = mem::size_of::<RawVec<()>>().checked_add(&data_size);
-        let size = size.expect("overflow in to_owned()");
-
-        unsafe {
-            // this should pass the real required alignment
-            let ret = allocate(size, 8) as *mut RawVec<()>;
-
-            let a_size = mem::size_of::<T>();
-            let a_size = if a_size == 0 {1} else {a_size};
-            (*ret).fill = len * a_size;
-            (*ret).alloc = len * a_size;
-
-            // Be careful with the following loop. We want it to be optimized
-            // to a memcpy (or something similarly fast) when T is Copy. LLVM
-            // is easily confused, so any extra operations during the loop can
-            // prevent this optimization.
-            let mut i = 0;
-            let p = &mut (*ret).data as *mut _ as *mut T;
-            try_finally(
-                &mut i, (),
-                |i, ()| while *i < len {
-                    ptr::write(
-                        &mut(*p.offset(*i as int)),
-                        self.unsafe_ref(*i).clone());
-                    *i += 1;
-                },
-                |i| if *i < len {
-                    // we must be failing, clean up after ourselves
-                    for j in range(0, *i as int) {
-                        ptr::read(&*p.offset(j));
-                    }
-                    // FIXME: #13994 (should pass align and size here)
-                    deallocate(ret as *mut u8, 0, 8);
-                });
-            mem::transmute(ret)
-        }
-    }
+    fn to_owned(&self) -> Vec<T> { Vec::from_slice(*self) }
 
     #[inline(always)]
-    fn into_owned(self) -> ~[T] { self.to_owned() }
-}
-
-/// Extension methods for owned vectors
-impl<T: Clone> CloneableVector<T> for ~[T] {
-    #[inline]
-    fn to_owned(&self) -> ~[T] { self.clone() }
-
-    #[inline(always)]
-    fn into_owned(self) -> ~[T] { self }
+    fn into_owned(self) -> Vec<T> { self.to_owned() }
 }
 
 /// Extension methods for vectors containing `Clone` elements.
@@ -387,57 +331,6 @@ fn permutations(self) -> Permutations<T> {
 
 }
 
-/// Extension methods for owned vectors.
-pub trait OwnedVector<T> {
-    /// Creates a consuming iterator, that is, one that moves each
-    /// value out of the vector (from start to end). The vector cannot
-    /// be used after calling this.
-    ///
-    /// # Examples
-    ///
-    /// ```rust
-    /// let v = ~["a".to_string(), "b".to_string()];
-    /// for s in v.move_iter() {
-    ///   // s has type ~str, not &~str
-    ///   println!("{}", s);
-    /// }
-    /// ```
-    fn move_iter(self) -> MoveItems<T>;
-
-    /**
-     * Partitions the vector into two vectors `(A,B)`, where all
-     * elements of `A` satisfy `f` and all elements of `B` do not.
-     */
-    fn partition(self, f: |&T| -> bool) -> (Vec<T>, Vec<T>);
-}
-
-impl<T> OwnedVector<T> for ~[T] {
-    #[inline]
-    fn move_iter(self) -> MoveItems<T> {
-        unsafe {
-            let iter = transmute(self.iter());
-            let ptr = transmute(self);
-            MoveItems { allocation: ptr, iter: iter }
-        }
-    }
-
-    #[inline]
-    fn partition(self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
-        let mut lefts  = Vec::new();
-        let mut rights = Vec::new();
-
-        for elt in self.move_iter() {
-            if f(&elt) {
-                lefts.push(elt);
-            } else {
-                rights.push(elt);
-            }
-        }
-
-        (lefts, rights)
-    }
-}
-
 fn insertion_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
     let len = v.len() as int;
     let buf_v = v.as_mut_ptr();
@@ -676,7 +569,7 @@ pub trait MutableVectorAllocating<'a, T> {
      * * start - The index into `src` to start copying from
      * * end - The index into `str` to stop copying from
      */
-    fn move_from(self, src: ~[T], start: uint, end: uint) -> uint;
+    fn move_from(self, src: Vec<T>, start: uint, end: uint) -> uint;
 }
 
 impl<'a,T> MutableVectorAllocating<'a, T> for &'a mut [T] {
@@ -686,7 +579,7 @@ fn sort_by(self, compare: |&T, &T| -> Ordering) {
     }
 
     #[inline]
-    fn move_from(self, mut src: ~[T], start: uint, end: uint) -> uint {
+    fn move_from(self, mut src: Vec<T>, start: uint, end: uint) -> uint {
         for (a, b) in self.mut_iter().zip(src.mut_slice(start, end).mut_iter()) {
             mem::swap(a, b);
         }
@@ -815,47 +708,6 @@ pub mod raw {
     pub use core::slice::raw::{shift_ptr, pop_ptr};
 }
 
-/// An iterator that moves out of a vector.
-pub struct MoveItems<T> {
-    allocation: *mut u8, // the block of memory allocated for the vector
-    iter: Items<'static, T>
-}
-
-impl<T> Iterator<T> for MoveItems<T> {
-    #[inline]
-    fn next(&mut self) -> Option<T> {
-        unsafe {
-            self.iter.next().map(|x| ptr::read(x))
-        }
-    }
-
-    #[inline]
-    fn size_hint(&self) -> (uint, Option<uint>) {
-        self.iter.size_hint()
-    }
-}
-
-impl<T> DoubleEndedIterator<T> for MoveItems<T> {
-    #[inline]
-    fn next_back(&mut self) -> Option<T> {
-        unsafe {
-            self.iter.next_back().map(|x| ptr::read(x))
-        }
-    }
-}
-
-#[unsafe_destructor]
-impl<T> Drop for MoveItems<T> {
-    fn drop(&mut self) {
-        // destroy the remaining elements
-        for _x in *self {}
-        unsafe {
-            // FIXME: #13994 (should pass align and size here)
-            deallocate(self.allocation, 0, 8)
-        }
-    }
-}
-
 #[cfg(test)]
 mod tests {
     use std::cell::Cell;
@@ -944,92 +796,92 @@ fn test_len_divzero() {
 
     #[test]
     fn test_get() {
-        let mut a = box [11];
-        assert_eq!(a.get(1), None);
-        a = box [11, 12];
-        assert_eq!(a.get(1).unwrap(), &12);
-        a = box [11, 12, 13];
-        assert_eq!(a.get(1).unwrap(), &12);
+        let mut a = vec![11];
+        assert_eq!(a.as_slice().get(1), None);
+        a = vec![11, 12];
+        assert_eq!(a.as_slice().get(1).unwrap(), &12);
+        a = vec![11, 12, 13];
+        assert_eq!(a.as_slice().get(1).unwrap(), &12);
     }
 
     #[test]
     fn test_head() {
-        let mut a = box [];
-        assert_eq!(a.head(), None);
-        a = box [11];
-        assert_eq!(a.head().unwrap(), &11);
-        a = box [11, 12];
-        assert_eq!(a.head().unwrap(), &11);
+        let mut a = vec![];
+        assert_eq!(a.as_slice().head(), None);
+        a = vec![11];
+        assert_eq!(a.as_slice().head().unwrap(), &11);
+        a = vec![11, 12];
+        assert_eq!(a.as_slice().head().unwrap(), &11);
     }
 
     #[test]
     fn test_tail() {
-        let mut a = box [11];
+        let mut a = vec![11];
         assert_eq!(a.tail(), &[]);
-        a = box [11, 12];
+        a = vec![11, 12];
         assert_eq!(a.tail(), &[12]);
     }
 
     #[test]
     #[should_fail]
     fn test_tail_empty() {
-        let a: ~[int] = box [];
+        let a: Vec<int> = vec![];
         a.tail();
     }
 
     #[test]
     fn test_tailn() {
-        let mut a = box [11, 12, 13];
+        let mut a = vec![11, 12, 13];
         assert_eq!(a.tailn(0), &[11, 12, 13]);
-        a = box [11, 12, 13];
+        a = vec![11, 12, 13];
         assert_eq!(a.tailn(2), &[13]);
     }
 
     #[test]
     #[should_fail]
     fn test_tailn_empty() {
-        let a: ~[int] = box [];
+        let a: Vec<int> = vec![];
         a.tailn(2);
     }
 
     #[test]
     fn test_init() {
-        let mut a = box [11];
+        let mut a = vec![11];
         assert_eq!(a.init(), &[]);
-        a = box [11, 12];
+        a = vec![11, 12];
         assert_eq!(a.init(), &[11]);
     }
 
     #[test]
     #[should_fail]
     fn test_init_empty() {
-        let a: ~[int] = box [];
+        let a: Vec<int> = vec![];
         a.init();
     }
 
     #[test]
     fn test_initn() {
-        let mut a = box [11, 12, 13];
-        assert_eq!(a.initn(0), &[11, 12, 13]);
-        a = box [11, 12, 13];
-        assert_eq!(a.initn(2), &[11]);
+        let mut a = vec![11, 12, 13];
+        assert_eq!(a.as_slice().initn(0), &[11, 12, 13]);
+        a = vec![11, 12, 13];
+        assert_eq!(a.as_slice().initn(2), &[11]);
     }
 
     #[test]
     #[should_fail]
     fn test_initn_empty() {
-        let a: ~[int] = box [];
-        a.initn(2);
+        let a: Vec<int> = vec![];
+        a.as_slice().initn(2);
     }
 
     #[test]
     fn test_last() {
-        let mut a = box [];
-        assert_eq!(a.last(), None);
-        a = box [11];
-        assert_eq!(a.last().unwrap(), &11);
-        a = box [11, 12];
-        assert_eq!(a.last().unwrap(), &12);
+        let mut a = vec![];
+        assert_eq!(a.as_slice().last(), None);
+        a = vec![11];
+        assert_eq!(a.as_slice().last().unwrap(), &11);
+        a = vec![11, 12];
+        assert_eq!(a.as_slice().last().unwrap(), &12);
     }
 
     #[test]
@@ -1038,6 +890,7 @@ fn test_slice() {
         let vec_fixed = [1, 2, 3, 4];
         let v_a = vec_fixed.slice(1u, vec_fixed.len()).to_owned();
         assert_eq!(v_a.len(), 3u);
+        let v_a = v_a.as_slice();
         assert_eq!(v_a[0], 2);
         assert_eq!(v_a[1], 3);
         assert_eq!(v_a[2], 4);
@@ -1046,13 +899,15 @@ fn test_slice() {
         let vec_stack = &[1, 2, 3];
         let v_b = vec_stack.slice(1u, 3u).to_owned();
         assert_eq!(v_b.len(), 2u);
+        let v_b = v_b.as_slice();
         assert_eq!(v_b[0], 2);
         assert_eq!(v_b[1], 3);
 
         // Test `Box<[T]>`
-        let vec_unique = box [1, 2, 3, 4, 5, 6];
+        let vec_unique = vec![1, 2, 3, 4, 5, 6];
         let v_d = vec_unique.slice(1u, 6u).to_owned();
         assert_eq!(v_d.len(), 5u);
+        let v_d = v_d.as_slice();
         assert_eq!(v_d[0], 2);
         assert_eq!(v_d[1], 3);
         assert_eq!(v_d[2], 4);
@@ -1295,15 +1150,15 @@ fn test_permutations() {
             let (min_size, max_opt) = it.size_hint();
             assert_eq!(min_size, 3*2);
             assert_eq!(max_opt.unwrap(), 3*2);
-            assert_eq!(it.next(), Some(box [1,2,3]));
-            assert_eq!(it.next(), Some(box [1,3,2]));
-            assert_eq!(it.next(), Some(box [3,1,2]));
+            assert_eq!(it.next(), Some(vec![1,2,3]));
+            assert_eq!(it.next(), Some(vec![1,3,2]));
+            assert_eq!(it.next(), Some(vec![3,1,2]));
             let (min_size, max_opt) = it.size_hint();
             assert_eq!(min_size, 3);
             assert_eq!(max_opt.unwrap(), 3);
-            assert_eq!(it.next(), Some(box [3,2,1]));
-            assert_eq!(it.next(), Some(box [2,3,1]));
-            assert_eq!(it.next(), Some(box [2,1,3]));
+            assert_eq!(it.next(), Some(vec![3,2,1]));
+            assert_eq!(it.next(), Some(vec![2,3,1]));
+            assert_eq!(it.next(), Some(vec![2,1,3]));
             assert_eq!(it.next(), None);
         }
         {
@@ -1378,11 +1233,11 @@ fn test_lexicographic_permutations_empty_and_short() {
     fn test_position_elem() {
         assert!([].position_elem(&1).is_none());
 
-        let v1 = box [1, 2, 3, 3, 2, 5];
-        assert_eq!(v1.position_elem(&1), Some(0u));
-        assert_eq!(v1.position_elem(&2), Some(1u));
-        assert_eq!(v1.position_elem(&5), Some(5u));
-        assert!(v1.position_elem(&4).is_none());
+        let v1 = vec![1, 2, 3, 3, 2, 5];
+        assert_eq!(v1.as_slice().position_elem(&1), Some(0u));
+        assert_eq!(v1.as_slice().position_elem(&2), Some(1u));
+        assert_eq!(v1.as_slice().position_elem(&5), Some(5u));
+        assert!(v1.as_slice().position_elem(&4).is_none());
     }
 
     #[test]
@@ -1432,14 +1287,14 @@ fn test_bsearch_elem() {
 
     #[test]
     fn test_reverse() {
-        let mut v: ~[int] = box [10, 20];
-        assert_eq!(v[0], 10);
-        assert_eq!(v[1], 20);
+        let mut v: Vec<int> = vec![10, 20];
+        assert_eq!(*v.get(0), 10);
+        assert_eq!(*v.get(1), 20);
         v.reverse();
-        assert_eq!(v[0], 20);
-        assert_eq!(v[1], 10);
+        assert_eq!(*v.get(0), 20);
+        assert_eq!(*v.get(1), 10);
 
-        let mut v3: ~[int] = box [];
+        let mut v3: Vec<int> = vec![];
         v3.reverse();
         assert!(v3.is_empty());
     }
@@ -1505,10 +1360,10 @@ fn test_sort_stability() {
 
     #[test]
     fn test_partition() {
-        assert_eq!((box []).partition(|x: &int| *x < 3), (vec![], vec![]));
-        assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![]));
-        assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 2), (vec![1], vec![2, 3]));
-        assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3]));
+        assert_eq!((vec![]).partition(|x: &int| *x < 3), (vec![], vec![]));
+        assert_eq!((vec![1, 2, 3]).partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![]));
+        assert_eq!((vec![1, 2, 3]).partition(|x: &int| *x < 2), (vec![1], vec![2, 3]));
+        assert_eq!((vec![1, 2, 3]).partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3]));
     }
 
     #[test]
@@ -1521,19 +1376,19 @@ fn test_partitioned() {
 
     #[test]
     fn test_concat() {
-        let v: [~[int], ..0] = [];
+        let v: [Vec<int>, ..0] = [];
         assert_eq!(v.concat_vec(), vec![]);
-        assert_eq!([box [1], box [2,3]].concat_vec(), vec![1, 2, 3]);
+        assert_eq!([vec![1], vec![2,3]].concat_vec(), vec![1, 2, 3]);
 
         assert_eq!([&[1], &[2,3]].concat_vec(), vec![1, 2, 3]);
     }
 
     #[test]
     fn test_connect() {
-        let v: [~[int], ..0] = [];
+        let v: [Vec<int>, ..0] = [];
         assert_eq!(v.connect_vec(&0), vec![]);
-        assert_eq!([box [1], box [2, 3]].connect_vec(&0), vec![1, 0, 2, 3]);
-        assert_eq!([box [1], box [2], box [3]].connect_vec(&0), vec![1, 0, 2, 0, 3]);
+        assert_eq!([vec![1], vec![2, 3]].connect_vec(&0), vec![1, 0, 2, 3]);
+        assert_eq!([vec![1], vec![2], vec![3]].connect_vec(&0), vec![1, 0, 2, 0, 3]);
 
         assert_eq!([&[1], &[2, 3]].connect_vec(&0), vec![1, 0, 2, 3]);
         assert_eq!([&[1], &[2], &[3]].connect_vec(&0), vec![1, 0, 2, 0, 3]);
@@ -1808,13 +1663,13 @@ fn test_mut_rev_iterator() {
 
     #[test]
     fn test_move_iterator() {
-        let xs = box [1u,2,3,4,5];
+        let xs = vec![1u,2,3,4,5];
         assert_eq!(xs.move_iter().fold(0, |a: uint, b: uint| 10*a + b), 12345);
     }
 
     #[test]
     fn test_move_rev_iterator() {
-        let xs = box [1u,2,3,4,5];
+        let xs = vec![1u,2,3,4,5];
         assert_eq!(xs.move_iter().rev().fold(0, |a: uint, b: uint| 10*a + b), 54321);
     }
 
@@ -1927,19 +1782,19 @@ fn test_chunksator_0() {
     #[test]
     fn test_move_from() {
         let mut a = [1,2,3,4,5];
-        let b = box [6,7,8];
+        let b = vec![6,7,8];
         assert_eq!(a.move_from(b, 0, 3), 3);
         assert!(a == [6,7,8,4,5]);
         let mut a = [7,2,8,1];
-        let b = box [3,1,4,1,5,9];
+        let b = vec![3,1,4,1,5,9];
         assert_eq!(a.move_from(b, 0, 6), 4);
         assert!(a == [3,1,4,1]);
         let mut a = [1,2,3,4];
-        let b = box [5,6,7,8,9,0];
+        let b = vec![5,6,7,8,9,0];
         assert_eq!(a.move_from(b, 2, 3), 1);
         assert!(a == [7,2,3,4]);
         let mut a = [1,2,3,4,5];
-        let b = box [5,6,7,8,9,0];
+        let b = vec![5,6,7,8,9,0];
         assert_eq!(a.mut_slice(2,4).move_from(b,1,6), 2);
         assert!(a == [1,2,6,7,5]);
     }
@@ -1972,11 +1827,11 @@ macro_rules! test_show_vec(
                 assert_eq!(format!("{}", x.as_slice()), x_str);
             })
         )
-        let empty: ~[int] = box [];
+        let empty: Vec<int> = vec![];
         test_show_vec!(empty, "[]".to_string());
-        test_show_vec!(box [1], "[1]".to_string());
-        test_show_vec!(box [1, 2, 3], "[1, 2, 3]".to_string());
-        test_show_vec!(box [box [], box [1u], box [1u, 1u]],
+        test_show_vec!(vec![1], "[1]".to_string());
+        test_show_vec!(vec![1, 2, 3], "[1, 2, 3]".to_string());
+        test_show_vec!(vec![vec![], vec![1u], vec![1u, 1u]],
                        "[[], [1], [1, 1]]".to_string());
 
         let empty_mut: &mut [int] = &mut[];
@@ -1997,7 +1852,6 @@ macro_rules! t (
         );
 
         t!(&[int]);
-        t!(~[int]);
         t!(Vec<int>);
     }
 
@@ -2392,13 +2246,6 @@ fn zero_1kb_set_memory(b: &mut Bencher) {
         });
     }
 
-    #[bench]
-    fn zero_1kb_fixed_repeat(b: &mut Bencher) {
-        b.iter(|| {
-            box [0u8, ..1024]
-        });
-    }
-
     #[bench]
     fn zero_1kb_loop_set(b: &mut Bencher) {
         b.iter(|| {
index 49d8775dd9cb649a97570ac2416828c7779b7e7d..83601be83dec0f194ae923a26edcd6aa54d968b0 100644 (file)
@@ -707,7 +707,7 @@ fn test_from_buf_len() {
         use str::StrAllocating;
 
         unsafe {
-            let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
+            let a = vec![65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
             let b = a.as_ptr();
             let c = from_buf_len(b, 3u);
             assert_eq!(c, "AAA".to_string());
@@ -1124,7 +1124,7 @@ fn half_a_million_letter_a() -> String {
         assert!(half_a_million_letter_a() ==
             unsafe {raw::slice_bytes(letters.as_slice(),
                                      0u,
-                                     500000)}.to_owned());
+                                     500000)}.to_string());
     }
 
     #[test]
@@ -1219,7 +1219,7 @@ fn test_slice() {
         assert_eq!("", data.slice(3, 3));
         assert_eq!("华", data.slice(30, 33));
 
-        fn a_million_letter_X() -> String {
+        fn a_million_letter_x() -> String {
             let mut i = 0;
             let mut rs = String::new();
             while i < 100000 {
@@ -1228,7 +1228,7 @@ fn a_million_letter_X() -> String {
             }
             rs
         }
-        fn half_a_million_letter_X() -> String {
+        fn half_a_million_letter_x() -> String {
             let mut i = 0;
             let mut rs = String::new();
             while i < 100000 {
@@ -1237,9 +1237,9 @@ fn half_a_million_letter_X() -> String {
             }
             rs
         }
-        let letters = a_million_letter_X();
-        assert!(half_a_million_letter_X() ==
-            letters.as_slice().slice(0u, 3u * 500000u).to_owned());
+        let letters = a_million_letter_x();
+        assert!(half_a_million_letter_x() ==
+            letters.as_slice().slice(0u, 3u * 500000u).to_string());
     }
 
     #[test]
@@ -1464,7 +1464,7 @@ fn test_is_utf16() {
     #[test]
     fn test_raw_from_c_str() {
         unsafe {
-            let a = box [65, 65, 65, 65, 65, 65, 65, 0];
+            let a = vec![65, 65, 65, 65, 65, 65, 65, 0];
             let b = a.as_ptr();
             let c = raw::from_c_str(b);
             assert_eq!(c, "AAAAAAA".to_string());
@@ -1682,7 +1682,7 @@ fn test_truncate_utf16_at_nul() {
     #[test]
     fn test_char_at() {
         let s = "ศไทย中华Việt Nam";
-        let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
+        let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
         let mut pos = 0;
         for ch in v.iter() {
             assert!(s.char_at(pos) == *ch);
@@ -1693,7 +1693,7 @@ fn test_char_at() {
     #[test]
     fn test_char_at_reverse() {
         let s = "ศไทย中华Việt Nam";
-        let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
+        let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
         let mut pos = s.len();
         for ch in v.iter().rev() {
             assert!(s.char_at_reverse(pos) == *ch);
@@ -1756,7 +1756,7 @@ fn test_char_range_at_reverse_underflow() {
     #[test]
     fn test_iterator() {
         let s = "ศไทย中华Việt Nam";
-        let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
+        let v = ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
 
         let mut pos = 0;
         let mut it = s.chars();
@@ -1771,7 +1771,7 @@ fn test_iterator() {
     #[test]
     fn test_rev_iterator() {
         let s = "ศไทย中华Việt Nam";
-        let v = box ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
+        let v = ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
 
         let mut pos = 0;
         let mut it = s.chars().rev();
index dbef73efc479462b1539acf7ed8d47eb305648c8..acb7b2c27040fd384f0fe82d3d57d256f88ee39a 100644 (file)
@@ -13,7 +13,6 @@
 use core::prelude::*;
 
 use alloc::heap::{allocate, reallocate, deallocate};
-use RawVec = core::raw::Vec;
 use core::raw::Slice;
 use core::cmp::max;
 use core::default::Default;
@@ -25,7 +24,7 @@
 use core::uint;
 
 use {Collection, Mutable};
-use slice::{MutableOrdVector, OwnedVector, MutableVectorAllocating};
+use slice::{MutableOrdVector, MutableVectorAllocating, CloneableVector};
 use slice::{Items, MutItems};
 
 /// An owned, growable vector.
@@ -387,6 +386,11 @@ fn lt(&self, other: &Vec<T>) -> bool {
 
 impl<T: Eq> Eq for Vec<T> {}
 
+impl<T: PartialEq, V: Vector<T>> Equiv<V> for Vec<T> {
+    #[inline]
+    fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
+}
+
 impl<T: Ord> Ord for Vec<T> {
     #[inline]
     fn cmp(&self, other: &Vec<T>) -> Ordering {
@@ -401,6 +405,11 @@ fn len(&self) -> uint {
     }
 }
 
+impl<T: Clone> CloneableVector<T> for Vec<T> {
+    fn to_owned(&self) -> Vec<T> { self.clone() }
+    fn into_owned(self) -> Vec<T> { self }
+}
+
 // FIXME: #13996: need a way to mark the return value as `noalias`
 #[inline(never)]
 unsafe fn alloc_or_realloc<T>(ptr: *mut T, size: uint, old_size: uint) -> *mut T {
@@ -1511,52 +1520,6 @@ pub fn unzip<T, U, V: Iterator<(T, U)>>(mut iter: V) -> (Vec<T>, Vec<U>) {
     (ts, us)
 }
 
-/// Mechanism to convert from a `Vec<T>` to a `[T]`.
-///
-/// In a post-DST world this will be used to convert to any `Ptr<[T]>`.
-///
-/// This could be implemented on more types than just pointers to vectors, but
-/// the recommended approach for those types is to implement `FromIterator`.
-// FIXME(#12938): Update doc comment when DST lands
-pub trait FromVec<T> {
-    /// Convert a `Vec<T>` into the receiver type.
-    fn from_vec(v: Vec<T>) -> Self;
-}
-
-impl<T> FromVec<T> for ~[T] {
-    fn from_vec(mut v: Vec<T>) -> ~[T] {
-        let len = v.len();
-        let data_size = len.checked_mul(&mem::size_of::<T>());
-        let data_size = data_size.expect("overflow in from_vec()");
-        let size = mem::size_of::<RawVec<()>>().checked_add(&data_size);
-        let size = size.expect("overflow in from_vec()");
-
-        // In a post-DST world, we can attempt to reuse the Vec allocation by calling
-        // shrink_to_fit() on it. That may involve a reallocation+memcpy, but that's no
-        // different than what we're doing manually here.
-
-        let vp = v.as_mut_ptr();
-
-        unsafe {
-            let ret = allocate(size, 8) as *mut RawVec<()>;
-
-            let a_size = mem::size_of::<T>();
-            let a_size = if a_size == 0 {1} else {a_size};
-            (*ret).fill = len * a_size;
-            (*ret).alloc = len * a_size;
-
-            ptr::copy_nonoverlapping_memory(&mut (*ret).data as *mut _ as *mut u8,
-                                            vp as *u8, data_size);
-
-            // we've transferred ownership of the contents from v, but we can't drop it
-            // as it still needs to free its own allocation.
-            v.set_len(0);
-
-            mem::transmute(ret)
-        }
-    }
-}
-
 /// Unsafe operations
 pub mod raw {
     use super::Vec;
@@ -1580,8 +1543,7 @@ pub unsafe fn from_buf<T>(ptr: *T, elts: uint) -> Vec<T> {
 mod tests {
     use std::prelude::*;
     use std::mem::size_of;
-    use std::kinds::marker;
-    use super::{unzip, raw, FromVec, Vec};
+    use super::{unzip, raw, Vec};
 
     #[test]
     fn test_small_vec_struct() {
@@ -1830,39 +1792,13 @@ fn test_unsafe_ptrs() {
             assert_eq!(b, vec![1, 2, 3]);
 
             // Test on-heap copy-from-buf.
-            let c = box [1, 2, 3, 4, 5];
+            let c = vec![1, 2, 3, 4, 5];
             let ptr = c.as_ptr();
             let d = raw::from_buf(ptr, 5u);
             assert_eq!(d, vec![1, 2, 3, 4, 5]);
         }
     }
 
-    #[test]
-    fn test_from_vec() {
-        let a = vec![1u, 2, 3];
-        let b: ~[uint] = FromVec::from_vec(a);
-        assert_eq!(b.as_slice(), &[1u, 2, 3]);
-
-        let a = vec![];
-        let b: ~[u8] = FromVec::from_vec(a);
-        assert_eq!(b.as_slice(), &[]);
-
-        let a = vec!["one".to_string(), "two".to_string()];
-        let b: ~[String] = FromVec::from_vec(a);
-        assert_eq!(b.as_slice(), &["one".to_string(), "two".to_string()]);
-
-        struct Foo {
-            x: uint,
-            nocopy: marker::NoCopy
-        }
-
-        let a = vec![Foo{x: 42, nocopy: marker::NoCopy}, Foo{x: 84, nocopy: marker::NoCopy}];
-        let b: ~[Foo] = FromVec::from_vec(a);
-        assert_eq!(b.len(), 2);
-        assert_eq!(b[0].x, 42);
-        assert_eq!(b[1].x, 84);
-    }
-
     #[test]
     fn test_vec_truncate_drop() {
         static mut drops: uint = 0;
index f7680e6f8479cdb11e42d8e199b713d233fecea3..e6c462c62d2979fd98757d508783b70da07f3e60 100644 (file)
@@ -159,7 +159,7 @@ impl Empty for int {}
 
         fn test_fn_a() -> f64 { 1.0 }
         fn test_fn_b<T: Empty>(x: T) -> T { x }
-        fn test_fn_c(_: int, _: f64, _: ~[int], _: int, _: int, _: int) {}
+        fn test_fn_c(_: int, _: f64, _: int, _: int, _: int) {}
 
         let _ = test_fn_a.clone();
         let _ = test_fn_b::<int>.clone();
index d4571eb3a43511ca61d4b1ca9dafa414addc6130..763ca843c11e97035262e4e3a9b5568a5ad9a2f9 100644 (file)
@@ -29,7 +29,7 @@
 #![allow(dead_code, missing_doc)]
 
 use fmt;
-use intrinsics;
+#[cfg(not(test))] use intrinsics;
 
 #[cold] #[inline(never)] // this is the slow path, always
 #[lang="fail_"]
index 0e6a0d1c6f5770c24ea44aab36f716ca236f1198..2464dfc9b5e3270848a6bcb61e1aab558d8dc55a 100644 (file)
@@ -828,12 +828,6 @@ fn fmt(&self, f: &mut Formatter) -> Result {
     }
 }
 
-impl<T: Show> Show for ~[T] {
-    fn fmt(&self, f: &mut Formatter) -> Result {
-        secret_show(&self.as_slice(), f)
-    }
-}
-
 impl Show for () {
     fn fmt(&self, f: &mut Formatter) -> Result {
         f.pad("()")
index 35c8afee4b6be8c129ec9dbb40348aae47c82026..d61416a68e0d0298b4d210314fd6f37790799a63 100644 (file)
@@ -100,7 +100,9 @@ pub trait TyVisitor {
 
     fn visit_char(&mut self) -> bool;
 
+    #[cfg(stage0)]
     fn visit_estr_box(&mut self) -> bool;
+    #[cfg(stage0)]
     fn visit_estr_uniq(&mut self) -> bool;
     fn visit_estr_slice(&mut self) -> bool;
     fn visit_estr_fixed(&mut self, n: uint, sz: uint, align: uint) -> bool;
@@ -110,7 +112,9 @@ pub trait TyVisitor {
     fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
     fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
 
+    #[cfg(stage0)]
     fn visit_evec_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    #[cfg(stage0)]
     fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
     fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
     fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
index 64c53b658eff12006d8b3d5e974a339fcf78a986..bb11ec5502e83ce991a7b00aa874fe3f899c71ec 100644 (file)
@@ -35,7 +35,7 @@ trait defined in this module. For loops can be viewed as a syntactical expansion
 translated to the `loop` below.
 
 ```rust
-let values = ~[1, 2, 3];
+let values = vec![1, 2, 3];
 
 // "Syntactical sugar" taking advantage of an iterator
 for &x in values.iter() {
@@ -378,7 +378,7 @@ fn flat_map<'r, B, U: Iterator<B>>(self, f: |A|: 'r -> U)
     ///     }
     ///     sum
     /// }
-    /// let x = ~[1,2,3,7,8,9];
+    /// let x = vec![1,2,3,7,8,9];
     /// assert_eq!(process(x.move_iter()), 1006);
     /// ```
     #[inline]
@@ -2425,7 +2425,7 @@ fn test_iterator_enumerate() {
 
     #[test]
     fn test_iterator_peekable() {
-        let xs = box [0u, 1, 2, 3, 4, 5];
+        let xs = vec![0u, 1, 2, 3, 4, 5];
         let mut it = xs.iter().map(|&x|x).peekable();
         assert_eq!(it.peek().unwrap(), &0);
         assert_eq!(it.next().unwrap(), 0);
@@ -2809,7 +2809,7 @@ fn test_double_ended_filter_map() {
     #[test]
     fn test_double_ended_chain() {
         let xs = [1, 2, 3, 4, 5];
-        let ys = box [7, 9, 11];
+        let ys = [7, 9, 11];
         let mut it = xs.iter().chain(ys.iter()).rev();
         assert_eq!(it.next().unwrap(), &11)
         assert_eq!(it.next().unwrap(), &9)
@@ -2826,7 +2826,7 @@ fn test_double_ended_chain() {
     fn test_rposition() {
         fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
         fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' }
-        let v = box [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+        let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
 
         assert_eq!(v.iter().rposition(f), Some(3u));
         assert!(v.iter().rposition(g).is_none());
@@ -2887,7 +2887,7 @@ fn test_double_ended_flat_map() {
     #[test]
     fn test_random_access_chain() {
         let xs = [1, 2, 3, 4, 5];
-        let ys = box [7, 9, 11];
+        let ys = [7, 9, 11];
         let mut it = xs.iter().chain(ys.iter());
         assert_eq!(it.idx(0).unwrap(), &1);
         assert_eq!(it.idx(5).unwrap(), &7);
@@ -3131,7 +3131,7 @@ fn test_min_max() {
     }
 
     #[test]
-    fn test_MinMaxResult() {
+    fn test_min_max_result() {
         let r: MinMaxResult<int> = NoElements;
         assert_eq!(r.into_option(), None)
 
index 5661c6683739b58ffb7b80c7d0a8218265dc7a1e..5c7b588a9c9a529ae44083cefc5298f2249dba73 100644 (file)
 pub mod tuple;
 pub mod fmt;
 
-// FIXME: this module should not exist. Once owned allocations are no longer a
-//        language type, this module can move outside to the owned allocation
-//        crate.
-mod should_not_exist;
-
 #[doc(hidden)]
 mod core {
     pub use failure;
index 45ccf657dbdd1251050a5e322b8a41f0f9ad2c6a..a71727c3f8ee2b87ee754d1d61927afd181a8419 100644 (file)
@@ -660,7 +660,7 @@ fn drop(&mut self) {
             }
         }
 
-        fn R(i: Rc<RefCell<int>>) -> R {
+        fn r(i: Rc<RefCell<int>>) -> R {
             R {
                 i: i
             }
@@ -673,7 +673,7 @@ fn realclone<T: ::realstd::clone::Clone>(t: &T) -> T {
 
         let i = Rc::new(RefCell::new(0));
         {
-            let x = R(realclone(&i));
+            let x = r(realclone(&i));
             let opt = Some(x);
             let _y = opt.unwrap();
         }
index b2776b78b1ce3bdcc5f62664f54cca133716dab0..c37c66f9862174ffe3f4fd29289cbc4f93fe2906 100644 (file)
@@ -503,7 +503,8 @@ fn lt(&self, other: &*mut T) -> bool { *self < *other }
 }
 
 #[cfg(test)]
-pub mod ptr_tests {
+#[allow(deprecated, experimental)]
+pub mod test {
     use super::*;
     use prelude::*;
 
@@ -512,6 +513,8 @@ pub mod ptr_tests {
     use libc;
     use realstd::str;
     use realstd::str::Str;
+    use realstd::vec::Vec;
+    use realstd::collections::Collection;
     use slice::{ImmutableVector, MutableVector};
 
     #[test]
@@ -534,20 +537,24 @@ struct Pair {
             assert_eq!(p.fst, 50);
             assert_eq!(p.snd, 60);
 
-            let v0 = box [32000u16, 32001u16, 32002u16];
-            let mut v1 = box [0u16, 0u16, 0u16];
+            let v0 = vec![32000u16, 32001u16, 32002u16];
+            let mut v1 = vec![0u16, 0u16, 0u16];
 
             copy_memory(v1.as_mut_ptr().offset(1),
                         v0.as_ptr().offset(1), 1);
-            assert!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16));
+            assert!((*v1.get(0) == 0u16 &&
+                     *v1.get(1) == 32001u16 &&
+                     *v1.get(2) == 0u16));
             copy_memory(v1.as_mut_ptr(),
                         v0.as_ptr().offset(2), 1);
-            assert!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
-                     v1[2] == 0u16));
+            assert!((*v1.get(0) == 32002u16 &&
+                     *v1.get(1) == 32001u16 &&
+                     *v1.get(2) == 0u16));
             copy_memory(v1.as_mut_ptr().offset(2),
                         v0.as_ptr(), 1u);
-            assert!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
-                     v1[2] == 32000u16));
+            assert!((*v1.get(0) == 32002u16 &&
+                     *v1.get(1) == 32001u16 &&
+                     *v1.get(2) == 32000u16));
         }
     }
 
@@ -569,7 +576,7 @@ fn test_buf_len() {
         "hello".with_c_str(|p0| {
             "there".with_c_str(|p1| {
                 "thing".with_c_str(|p2| {
-                    let v = box [p0, p1, p2, null()];
+                    let v = vec![p0, p1, p2, null()];
                     unsafe {
                         assert_eq!(buf_len(v.as_ptr()), 3u);
                     }
@@ -617,7 +624,7 @@ fn test_to_option() {
     #[test]
     fn test_ptr_addition() {
         unsafe {
-            let xs = box [5, ..16];
+            let xs = Vec::from_elem(16, 5);
             let mut ptr = xs.as_ptr();
             let end = ptr.offset(16);
 
@@ -626,7 +633,7 @@ fn test_ptr_addition() {
                 ptr = ptr.offset(1);
             }
 
-            let mut xs_mut = xs.clone();
+            let mut xs_mut = xs;
             let mut m_ptr = xs_mut.as_mut_ptr();
             let m_end = m_ptr.offset(16);
 
@@ -635,14 +642,14 @@ fn test_ptr_addition() {
                 m_ptr = m_ptr.offset(1);
             }
 
-            assert_eq!(xs_mut, box [10, ..16]);
+            assert!(xs_mut == Vec::from_elem(16, 10));
         }
     }
 
     #[test]
     fn test_ptr_subtraction() {
         unsafe {
-            let xs = box [0,1,2,3,4,5,6,7,8,9];
+            let xs = vec![0,1,2,3,4,5,6,7,8,9];
             let mut idx = 9i8;
             let ptr = xs.as_ptr();
 
@@ -651,7 +658,7 @@ fn test_ptr_subtraction() {
                 idx = idx - 1i8;
             }
 
-            let mut xs_mut = xs.clone();
+            let mut xs_mut = xs;
             let m_start = xs_mut.as_mut_ptr();
             let mut m_ptr = m_start.offset(9);
 
@@ -660,7 +667,7 @@ fn test_ptr_subtraction() {
                 m_ptr = m_ptr.offset(-1);
             }
 
-            assert_eq!(xs_mut, box [0,2,4,6,8,10,12,14,16,18]);
+            assert!(xs_mut == vec![0,2,4,6,8,10,12,14,16,18]);
         }
     }
 
@@ -670,10 +677,10 @@ fn test_ptr_array_each_with_len() {
             let one = "oneOne".to_c_str();
             let two = "twoTwo".to_c_str();
             let three = "threeThree".to_c_str();
-            let arr = box [
+            let arr = vec![
                 one.with_ref(|buf| buf),
                 two.with_ref(|buf| buf),
-                three.with_ref(|buf| buf),
+                three.with_ref(|buf| buf)
             ];
             let expected_arr = [
                 one, two, three
@@ -700,12 +707,12 @@ fn test_ptr_array_each() {
             let one = "oneOne".to_c_str();
             let two = "twoTwo".to_c_str();
             let three = "threeThree".to_c_str();
-            let arr = box [
+            let arr = vec![
                 one.with_ref(|buf| buf),
                 two.with_ref(|buf| buf),
                 three.with_ref(|buf| buf),
                 // fake a null terminator
-                null(),
+                null()
             ];
             let expected_arr = [
                 one, two, three
index 56db4ee8059fab8596cda3a784f6e1489e8f6dae..0a2a756c6b1c24739813d3dfdfb3d087617b6547 100644 (file)
@@ -29,16 +29,6 @@ pub struct Box<T> {
     pub data: T,
 }
 
-/// The representation of a Rust vector
-pub struct Vec<T> {
-    pub fill: uint,
-    pub alloc: uint,
-    pub data: T,
-}
-
-/// The representation of a Rust string
-pub type String = Vec<u8>;
-
 /// The representation of a Rust slice
 pub struct Slice<T> {
     pub data: *T,
@@ -79,7 +69,6 @@ fn repr(&self) -> T { unsafe { mem::transmute_copy(self) } }
 
 impl<'a, T> Repr<Slice<T>> for &'a [T] {}
 impl<'a> Repr<Slice<u8>> for &'a str {}
-impl<T> Repr<*Vec<T>> for ~[T] {}
 
 #[cfg(test)]
 mod tests {
index 585373ec70ca560cea9de2e4b4d2b953a8ca29b4..d579d04489240abed234aaa410fc6d8f2948bc4e 100644 (file)
@@ -266,38 +266,19 @@ fn ne(&self, other: & &'a [T]) -> bool {
         }
     }
 
-    impl<T:PartialEq> PartialEq for ~[T] {
-        #[inline]
-        fn eq(&self, other: &~[T]) -> bool { self.as_slice() == *other }
-        #[inline]
-        fn ne(&self, other: &~[T]) -> bool { !self.eq(other) }
-    }
-
     impl<'a,T:Eq> Eq for &'a [T] {}
 
-    impl<T:Eq> Eq for ~[T] {}
-
     impl<'a,T:PartialEq, V: Vector<T>> Equiv<V> for &'a [T] {
         #[inline]
         fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
     }
 
-    impl<'a,T:PartialEq, V: Vector<T>> Equiv<V> for ~[T] {
-        #[inline]
-        fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
-    }
-
     impl<'a,T:Ord> Ord for &'a [T] {
         fn cmp(&self, other: & &'a [T]) -> Ordering {
             order::cmp(self.iter(), other.iter())
         }
     }
 
-    impl<T: Ord> Ord for ~[T] {
-        #[inline]
-        fn cmp(&self, other: &~[T]) -> Ordering { self.as_slice().cmp(&other.as_slice()) }
-    }
-
     impl<'a, T: PartialOrd> PartialOrd for &'a [T] {
         fn lt(&self, other: & &'a [T]) -> bool {
             order::lt(self.iter(), other.iter())
@@ -315,17 +296,6 @@ fn gt(&self, other: & &'a [T]) -> bool {
             order::gt(self.iter(), other.iter())
         }
     }
-
-    impl<T: PartialOrd> PartialOrd for ~[T] {
-        #[inline]
-        fn lt(&self, other: &~[T]) -> bool { self.as_slice() < other.as_slice() }
-        #[inline]
-        fn le(&self, other: &~[T]) -> bool { self.as_slice() <= other.as_slice() }
-        #[inline]
-        fn ge(&self, other: &~[T]) -> bool { self.as_slice() >= other.as_slice() }
-        #[inline]
-        fn gt(&self, other: &~[T]) -> bool { self.as_slice() > other.as_slice() }
-    }
 }
 
 #[cfg(test)]
@@ -342,11 +312,6 @@ impl<'a,T> Vector<T> for &'a [T] {
     fn as_slice<'a>(&'a self) -> &'a [T] { *self }
 }
 
-impl<T> Vector<T> for ~[T] {
-    #[inline(always)]
-    fn as_slice<'a>(&'a self) -> &'a [T] { let v: &'a [T] = *self; v }
-}
-
 impl<'a, T> Collection for &'a [T] {
     /// Returns the length of a vector
     #[inline]
@@ -355,14 +320,6 @@ fn len(&self) -> uint {
     }
 }
 
-impl<T> Collection for ~[T] {
-    /// Returns the length of a vector
-    #[inline]
-    fn len(&self) -> uint {
-        self.as_slice().len()
-    }
-}
-
 /// Extension methods for vectors
 pub trait ImmutableVector<'a, T> {
     /**
@@ -927,7 +884,7 @@ pub trait MutableVector<'a, T> {
     /// # Example
     ///
     /// ```rust
-    /// let mut v = ~["foo".to_string(), "bar".to_string(), "baz".to_string()];
+    /// let mut v = ["foo".to_string(), "bar".to_string(), "baz".to_string()];
     ///
     /// unsafe {
     ///     // `"baz".to_string()` is deallocated.
@@ -1455,7 +1412,3 @@ fn next_back(&mut self) -> Option<&'a mut [T]> {
 impl<'a, T> Default for &'a [T] {
     fn default() -> &'a [T] { &[] }
 }
-
-impl<T> Default for ~[T] {
-    fn default() -> ~[T] { ~[] }
-}
index 997d3427122e8daf373b2b6660d231b70147c850..3a12aec39a18718c8537268e86b578afcb12fc59 100644 (file)
@@ -192,15 +192,14 @@ fn visit_char(&mut self) -> bool {
         true
     }
 
+    #[cfg(stage0)]
     fn visit_estr_box(&mut self) -> bool {
         true
     }
 
+    #[cfg(stage0)]
     fn visit_estr_uniq(&mut self) -> bool {
-        self.align_to::<~str>();
-        if ! self.inner.visit_estr_uniq() { return false; }
-        self.bump_past::<~str>();
-        true
+        false
     }
 
     fn visit_estr_slice(&mut self) -> bool {
@@ -247,15 +246,14 @@ fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
         true
     }
 
+    #[cfg(stage0)]
     fn visit_evec_box(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
         true
     }
 
-    fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
-        self.align_to::<~[u8]>();
-        if ! self.inner.visit_evec_uniq(mtbl, inner) { return false; }
-        self.bump_past::<~[u8]>();
-        true
+    #[cfg(stage0)]
+    fn visit_evec_uniq(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
+        false
     }
 
     fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
index e6cc9785b44e72b4576b65028acd769aaaf85e94..86b71eb5b8d692610bd0b8048ac881ccd0040509 100644 (file)
@@ -203,10 +203,6 @@ pub fn write_vec_range(&mut self, ptr: *(), len: uint, inner: *TyDesc) -> bool {
         true
     }
 
-    pub fn write_unboxed_vec_repr(&mut self, _: uint, v: &raw::Vec<()>, inner: *TyDesc) -> bool {
-        self.write_vec_range(&v.data, v.fill, inner)
-    }
-
     fn write_escaped_char(&mut self, ch: char, is_str: bool) -> bool {
         try!(self, match ch {
             '\t' => self.writer.write("\\t".as_bytes()),
@@ -271,15 +267,14 @@ fn visit_char(&mut self) -> bool {
         })
     }
 
+    #[cfg(stage0)]
     fn visit_estr_box(&mut self) -> bool {
-        true
+        false
     }
 
+    #[cfg(stage0)]
     fn visit_estr_uniq(&mut self) -> bool {
-        self.get::<~str>(|this, s| {
-            try!(this, this.writer.write(['~' as u8]));
-            this.write_escaped_slice(*s)
-        })
+        false
     }
 
     fn visit_estr_slice(&mut self) -> bool {
@@ -323,19 +318,14 @@ fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
         })
     }
 
-    fn visit_evec_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
-        self.get::<&raw::Box<raw::Vec<()>>>(|this, b| {
-            try!(this, this.writer.write(['@' as u8]));
-            this.write_mut_qualifier(mtbl);
-            this.write_unboxed_vec_repr(mtbl, &b.data, inner)
-        })
+    #[cfg(stage0)]
+    fn visit_evec_box(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
+        true
     }
 
-    fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
-        self.get::<&raw::Vec<()>>(|this, b| {
-            try!(this, this.writer.write("box ".as_bytes()));
-            this.write_unboxed_vec_repr(mtbl, *b, inner)
-        })
+    #[cfg(stage0)]
+    fn visit_evec_uniq(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
+        true
     }
 
     fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
index 8d8fe8ffe8cfe404c10aa577d9cd0f4207bc3cc3..955f697dce3bee0547853baa6f029a6853f4b205 100644 (file)
@@ -26,7 +26,6 @@
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/")]
 #![feature(phase)]
-#![deny(deprecated_owned_vector)]
 
 #[cfg(test, stage0)] #[phase(syntax, link)] extern crate log;
 #[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate log;
@@ -114,7 +113,6 @@ mod tests {
     use std::rand::Rng;
 
     #[test]
-    #[allow(deprecated_owned_vector)]
     fn test_flate_round_trip() {
         let mut r = rand::task_rng();
         let mut words = vec!();
index 694fe7d0f48b08fa3e3fb9097f443c67e2379b50..3949bde3d52f7a6992575e5afc914ca31bf5bfa0 100644 (file)
@@ -47,7 +47,6 @@ fn main() {
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/")]
 
-#![deny(deprecated_owned_vector)]
 #![feature(plugin_registrar, managed_boxes)]
 
 extern crate syntax;
index eb9c86f00147980ba5f65ee8d420c21505575652..db6d940a7200e2a3d4022d54dfc2918f4b7692f8 100644 (file)
@@ -88,7 +88,6 @@
        html_playground_url = "http://play.rust-lang.org/")]
 #![feature(globs, phase)]
 #![deny(missing_doc)]
-#![deny(deprecated_owned_vector)]
 
 #[cfg(test)] extern crate debug;
 #[cfg(test, stage0)] #[phase(syntax, link)] extern crate log;
index 6d39a332ad9bd5a3549c7475a9dafa4d0aeb64b8..a2c2706b4c2f779585d55b1af8b1ecc1742431d2 100644 (file)
@@ -31,7 +31,6 @@
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/",
        html_playground_url = "http://play.rust-lang.org/")]
-#![deny(deprecated_owned_vector)]
 
 use std::cell::Cell;
 use std::{cmp, os, path};
index 3015b6f12ccd1795047a1024a0d9158ebcf36b38..a34791f470eaf9473a1a8dc0dc0a92e7948c4489 100644 (file)
 // of the contents of `Vec<T>`, since we anticipate that to be a
 // frequent way to dynamically construct a vector.
 
-/// MaybeOwnedVector<'a,T> abstracts over `Vec<T>`, `~[T]`, `&'a [T]`.
+/// MaybeOwnedVector<'a,T> abstracts over `Vec<T>`, `&'a [T]`.
 ///
 /// Some clients will have a pre-allocated vector ready to hand off in
 /// a slice; others will want to create the set on the fly and hand
-/// off ownership, via either `Growable` or `FixedLen` depending on
-/// which kind of vector they have constructed.  (The `FixedLen`
-/// variant is provided for interoperability with `std::slice` methods
-/// that return `~[T]`.)
+/// off ownership, via `Growable`.
 pub enum MaybeOwnedVector<'a,T> {
     Growable(Vec<T>),
-    FixedLen(~[T]),
     Borrowed(&'a [T]),
 }
 
@@ -51,11 +47,6 @@ impl<'a,T> IntoMaybeOwnedVector<'a,T> for Vec<T> {
     fn into_maybe_owned(self) -> MaybeOwnedVector<'a,T> { Growable(self) }
 }
 
-impl<'a,T> IntoMaybeOwnedVector<'a,T> for ~[T] {
-    #[inline]
-    fn into_maybe_owned(self) -> MaybeOwnedVector<'a,T> { FixedLen(self) }
-}
-
 impl<'a,T> IntoMaybeOwnedVector<'a,T> for &'a [T] {
     #[inline]
     fn into_maybe_owned(self) -> MaybeOwnedVector<'a,T> { Borrowed(self) }
@@ -65,7 +56,6 @@ impl<'a,T> MaybeOwnedVector<'a,T> {
     pub fn iter(&'a self) -> slice::Items<'a,T> {
         match self {
             &Growable(ref v) => v.iter(),
-            &FixedLen(ref v) => v.iter(),
             &Borrowed(ref v) => v.iter(),
         }
     }
@@ -84,7 +74,6 @@ impl<'b,T> slice::Vector<T> for MaybeOwnedVector<'b,T> {
     fn as_slice<'a>(&'a self) -> &'a [T] {
         match self {
             &Growable(ref v) => v.as_slice(),
-            &FixedLen(ref v) => v.as_slice(),
             &Borrowed(ref v) => v.as_slice(),
         }
     }
@@ -106,15 +95,14 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 impl<'a,T:Clone> CloneableVector<T> for MaybeOwnedVector<'a,T> {
     /// Returns a copy of `self`.
-    fn to_owned(&self) -> ~[T] {
+    fn to_owned(&self) -> Vec<T> {
         self.as_slice().to_owned()
     }
 
     /// Convert `self` into an owned slice, not making a copy if possible.
-    fn into_owned(self) -> ~[T] {
+    fn into_owned(self) -> Vec<T> {
         match self {
             Growable(v) => v.as_slice().to_owned(),
-            FixedLen(v) => v,
             Borrowed(v) => v.to_owned(),
         }
     }
@@ -125,7 +113,6 @@ impl<'a,T:Clone> MaybeOwnedVector<'a,T> {
     pub fn into_vec(self) -> Vec<T> {
         match self {
             Growable(v) => v,
-            FixedLen(v) => Vec::from_slice(v.as_slice()),
             Borrowed(v) => Vec::from_slice(v),
         }
     }
index 9071656f21334c896c60c0891977cf0f8196047a..e6915385a42d58f0d48bd7c934a15e490b15facf 100644 (file)
@@ -191,9 +191,9 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
 type Registers = [uint, ..22];
 
 #[cfg(windows, target_arch = "x86_64")]
-fn new_regs() -> Box<Registers> { box [0, .. 34] }
+fn new_regs() -> Box<Registers> { box() ([0, .. 34]) }
 #[cfg(not(windows), target_arch = "x86_64")]
-fn new_regs() -> Box<Registers> { box {let v = [0, .. 22]; v} }
+fn new_regs() -> Box<Registers> { box() ([0, .. 22]) }
 
 #[cfg(target_arch = "x86_64")]
 fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
index 9748dfbae33f0dc8f744797f43e695cea15f4068..e8de2b9bd9335cc99621b3d45cf147ac2cced253 100644 (file)
 // NB this does *not* include globs, please keep it that way.
 #![feature(macro_rules, phase)]
 #![allow(visible_private_types)]
-#![deny(deprecated_owned_vector)]
 
 #[cfg(test)] #[phase(plugin, link)] extern crate log;
 #[cfg(test)] extern crate rustuv;
index 54bc2802b09ac364cb92ab2b6f42d3dcc44abf62..b181b0ca8c977ae13e80c25a106de44d17d102ec 100644 (file)
@@ -43,8 +43,6 @@ fn main() {
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/")]
-
-#![deny(deprecated_owned_vector)]
 #![feature(plugin_registrar, managed_boxes)]
 
 extern crate syntax;
index 19f55c59491d814fc52658408063ee3c2cd7df24..2ecfef35308832b7d960e5e7a1bef52f81d889e7 100644 (file)
@@ -115,7 +115,7 @@ fn main() {
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules)]
-#![deny(missing_doc, deprecated_owned_vector)]
+#![deny(missing_doc)]
 
 use std::fmt;
 use std::io::LineBufferedWriter;
index 709882c87cedb970b3be3f693517592507fefd77..27ccc528c940db36a84550f2f66257ea1b1bd8a4 100644 (file)
@@ -53,8 +53,6 @@
        html_root_url = "http://doc.rust-lang.org/",
        html_playground_url = "http://play.rust-lang.org/")]
 
-#![deny(deprecated_owned_vector)]
-
 extern crate rand;
 
 pub use bigint::{BigInt, BigUint};
index 61e62a0d1053e960bd905310144fb9fbfe8bbe7c..61b133c4e68abef23ecb275231bb1d1f1cc0863d 100644 (file)
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules, phase)]
-#![deny(missing_doc, deprecated_owned_vector)]
+#![deny(missing_doc)]
 
 #[cfg(test)]
 extern crate stdtest = "test";
index 59f53986af9fc8662cb1e25ed3942190d5408bd0..b6205d8d54e6799c474195fb8b2733eb39dd8c78 100644 (file)
@@ -37,7 +37,7 @@
 
 pub fn main_args(args: &[String]) -> int {
     let owned_args = args.to_owned();
-    monitor(proc() run_compiler(owned_args));
+    monitor(proc() run_compiler(owned_args.as_slice()));
     0
 }
 
index b8db8e230b074c589e7ff646fcd7bcf394a6ee2d..bc5fad7f9343a871ea2d0f7b2f03db230c6b8a91 100644 (file)
@@ -418,10 +418,10 @@ fn walk_expr(&mut self,
                 self.walk_expr(&*cond, in_out, loop_scopes);
 
                 let mut then_bits = in_out.to_owned();
-                self.walk_block(&*then, then_bits, loop_scopes);
+                self.walk_block(&*then, then_bits.as_mut_slice(), loop_scopes);
 
                 self.walk_opt_expr(els, in_out, loop_scopes);
-                join_bits(&self.dfcx.oper, then_bits, in_out);
+                join_bits(&self.dfcx.oper, then_bits.as_slice(), in_out);
             }
 
             ast::ExprWhile(cond, blk) => {
@@ -444,8 +444,8 @@ fn walk_expr(&mut self,
                     loop_id: expr.id,
                     break_bits: Vec::from_slice(in_out)
                 });
-                self.walk_block(&*blk, body_bits, loop_scopes);
-                self.add_to_entry_set(expr.id, body_bits);
+                self.walk_block(&*blk, body_bits.as_mut_slice(), loop_scopes);
+                self.add_to_entry_set(expr.id, body_bits.as_slice());
                 let new_loop_scope = loop_scopes.pop().unwrap();
                 copy_bits(new_loop_scope.break_bits.as_slice(), in_out);
             }
@@ -468,8 +468,8 @@ fn walk_expr(&mut self,
                     loop_id: expr.id,
                     break_bits: Vec::from_slice(in_out)
                 });
-                self.walk_block(&**blk, body_bits, loop_scopes);
-                self.add_to_entry_set(expr.id, body_bits);
+                self.walk_block(&**blk, body_bits.as_mut_slice(), loop_scopes);
+                self.add_to_entry_set(expr.id, body_bits.as_slice());
 
                 let new_loop_scope = loop_scopes.pop().unwrap();
                 assert_eq!(new_loop_scope.loop_id, expr.id);
@@ -499,16 +499,17 @@ fn walk_expr(&mut self,
 
                 for arm in arms.iter() {
                     // in_out reflects the discr and all guards to date
-                    self.walk_opt_expr(arm.guard, guards, loop_scopes);
+                    self.walk_opt_expr(arm.guard, guards.as_mut_slice(),
+                                       loop_scopes);
 
                     // determine the bits for the body and then union
                     // them into `in_out`, which reflects all bodies to date
                     let mut body = guards.to_owned();
                     self.walk_pat_alternatives(arm.pats.as_slice(),
-                                               body,
+                                               body.as_mut_slice(),
                                                loop_scopes);
-                    self.walk_expr(&*arm.body, body, loop_scopes);
-                    join_bits(&self.dfcx.oper, body, in_out);
+                    self.walk_expr(&*arm.body, body.as_mut_slice(), loop_scopes);
+                    join_bits(&self.dfcx.oper, body.as_slice(), in_out);
                 }
             }
 
@@ -578,7 +579,7 @@ fn walk_expr(&mut self,
                 self.walk_expr(&**l, in_out, loop_scopes);
                 let temp = in_out.to_owned();
                 self.walk_expr(&**r, in_out, loop_scopes);
-                join_bits(&self.dfcx.oper, temp, in_out);
+                join_bits(&self.dfcx.oper, temp.as_slice(), in_out);
             }
 
             ast::ExprIndex(l, r) |
@@ -739,8 +740,8 @@ fn walk_pat_alternatives(&mut self,
         let initial_state = in_out.to_owned();
         for &pat in pats.iter() {
             let mut temp = initial_state.clone();
-            self.walk_pat(pat, temp, loop_scopes);
-            join_bits(&self.dfcx.oper, temp, in_out);
+            self.walk_pat(pat, temp.as_mut_slice(), loop_scopes);
+            join_bits(&self.dfcx.oper, temp.as_slice(), in_out);
         }
     }
 
index 7527477384a0d77b429aecd011dbfe4a49645834..389a73c357b7d473d685ecce39d6be7b5c85de61 100644 (file)
@@ -121,8 +121,6 @@ pub enum Lint {
     UnusedMustUse,
     UnusedResult,
 
-    DeprecatedOwnedVector,
-
     Warnings,
 
     RawPointerDeriving,
@@ -433,13 +431,6 @@ pub enum LintSource {
         default: Allow,
     }),
 
-    ("deprecated_owned_vector",
-     LintSpec {
-        lint: DeprecatedOwnedVector,
-        desc: "use of a `~[T]` vector",
-        default: Allow,
-    }),
-
     ("raw_pointer_deriving",
      LintSpec {
         lint: RawPointerDeriving,
@@ -1229,20 +1220,6 @@ fn check_unused_result(cx: &Context, s: &ast::Stmt) {
     }
 }
 
-fn check_deprecated_owned_vector(cx: &Context, e: &ast::Expr) {
-    let t = ty::expr_ty(cx.tcx, e);
-    match ty::get(t).sty {
-        ty::ty_uniq(t) => match ty::get(t).sty {
-            ty::ty_vec(_, None) => {
-                cx.span_lint(DeprecatedOwnedVector, e.span,
-                             "use of deprecated `~[]` vector; replaced by `std::vec::Vec`")
-            }
-            _ => {}
-        },
-        _ => {}
-    }
-}
-
 fn check_item_non_camel_case_types(cx: &Context, it: &ast::Item) {
     fn is_camel_case(ident: ast::Ident) -> bool {
         let ident = token::get_ident(ident);
@@ -1855,7 +1832,6 @@ fn visit_expr(&mut self, e: &ast::Expr, _: ()) {
 
         check_type_limits(self, e);
         check_unused_casts(self, e);
-        check_deprecated_owned_vector(self, e);
 
         visit::walk_expr(self, e, ());
     }
index 6b468bd0827c6144ba0c63eec06c10a922f7bf67..1a7f0cdfc507ef7db918eab273073ec346a81776 100644 (file)
 
 ```rust
 local_data_key!(key_int: int)
-local_data_key!(key_vector: ~[int])
+local_data_key!(key_vector: Vec<int>)
 
 key_int.replace(Some(3));
 assert_eq!(*key_int.get().unwrap(), 3);
 
-key_vector.replace(Some(~[4]));
-assert_eq!(*key_vector.get().unwrap(), ~[4]);
+key_vector.replace(Some(vec![4]));
+assert_eq!(*key_vector.get().unwrap(), vec![4]);
 ```
 
 */
index dbde1a7486d09c9fef49838e71ddabc05f61da07..2ad69dad8d2c9c75d44526ae227a2655d71226e7 100644 (file)
@@ -35,7 +35,6 @@
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/")]
-#![deny(deprecated_owned_vector)]
 
 use std::char;
 use std::cmp;
index 9907faae52bc4bd0c1b193e5211e4b639d3865b7..a5c2042c979eecc60f214633872be06b35cfec9e 100644 (file)
@@ -81,7 +81,7 @@ fn main() {
 ```
 
 Two wrapper functions are provided to encode a Encodable object
-into a string (String) or buffer (~[u8]): `str_encode(&m)` and `buffer_encode(&m)`.
+into a string (String) or buffer (vec![u8]): `str_encode(&m)` and `buffer_encode(&m)`.
 
 ```rust
 use serialize::json;
@@ -2225,10 +2225,6 @@ impl<'a, A:ToJson> ToJson for &'a [A] {
     fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
 }
 
-impl<A:ToJson> ToJson for ~[A] {
-    fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
-}
-
 impl<A:ToJson> ToJson for Vec<A> {
     fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
 }
@@ -3048,7 +3044,8 @@ fn test_hashmap_with_numeric_key_can_handle_double_quote_delimited_key() {
         let _hm: HashMap<uint, bool> = Decodable::decode(&mut decoder).unwrap();
     }
 
-    fn assert_stream_equal(src: &str, expected: ~[(JsonEvent, ~[StackElement])]) {
+    fn assert_stream_equal(src: &str,
+                           expected: Vec<(JsonEvent, Vec<StackElement>)>) {
         let mut parser = Parser::new(src.chars());
         let mut i = 0;
         loop {
@@ -3056,7 +3053,7 @@ fn assert_stream_equal(src: &str, expected: ~[(JsonEvent, ~[StackElement])]) {
                 Some(e) => e,
                 None => { break; }
             };
-            let (ref expected_evt, ref expected_stack) = expected[i];
+            let (ref expected_evt, ref expected_stack) = *expected.get(i);
             if !parser.stack().is_equal_to(expected_stack.as_slice()) {
                 fail!("Parser stack is not equal to {}", expected_stack);
             }
@@ -3065,26 +3062,27 @@ fn assert_stream_equal(src: &str, expected: ~[(JsonEvent, ~[StackElement])]) {
         }
     }
     #[test]
+    #[ignore(cfg(target_word_size = "32"))] // FIXME(#14064)
     fn test_streaming_parser() {
         assert_stream_equal(
             r#"{ "foo":"bar", "array" : [0, 1, 2,3 ,4,5], "idents":[null,true,false]}"#,
-            ~[
-                (ObjectStart,             ~[]),
-                  (StringValue("bar".to_string()),   ~[Key("foo")]),
-                  (ListStart,             ~[Key("array")]),
-                    (NumberValue(0.0),    ~[Key("array"), Index(0)]),
-                    (NumberValue(1.0),    ~[Key("array"), Index(1)]),
-                    (NumberValue(2.0),    ~[Key("array"), Index(2)]),
-                    (NumberValue(3.0),    ~[Key("array"), Index(3)]),
-                    (NumberValue(4.0),    ~[Key("array"), Index(4)]),
-                    (NumberValue(5.0),    ~[Key("array"), Index(5)]),
-                  (ListEnd,               ~[Key("array")]),
-                  (ListStart,             ~[Key("idents")]),
-                    (NullValue,           ~[Key("idents"), Index(0)]),
-                    (BooleanValue(true),  ~[Key("idents"), Index(1)]),
-                    (BooleanValue(false), ~[Key("idents"), Index(2)]),
-                  (ListEnd,               ~[Key("idents")]),
-                (ObjectEnd,               ~[]),
+            vec![
+                (ObjectStart,             vec![]),
+                  (StringValue("bar".to_string()),   vec![Key("foo")]),
+                  (ListStart,             vec![Key("array")]),
+                    (NumberValue(0.0),    vec![Key("array"), Index(0)]),
+                    (NumberValue(1.0),    vec![Key("array"), Index(1)]),
+                    (NumberValue(2.0),    vec![Key("array"), Index(2)]),
+                    (NumberValue(3.0),    vec![Key("array"), Index(3)]),
+                    (NumberValue(4.0),    vec![Key("array"), Index(4)]),
+                    (NumberValue(5.0),    vec![Key("array"), Index(5)]),
+                  (ListEnd,               vec![Key("array")]),
+                  (ListStart,             vec![Key("idents")]),
+                    (NullValue,           vec![Key("idents"), Index(0)]),
+                    (BooleanValue(true),  vec![Key("idents"), Index(1)]),
+                    (BooleanValue(false), vec![Key("idents"), Index(2)]),
+                  (ListEnd,               vec![Key("idents")]),
+                (ObjectEnd,               vec![]),
             ]
         );
     }
@@ -3115,34 +3113,34 @@ fn test_read_object_streaming() {
 
         assert_stream_equal(
             "{}",
-            box [(ObjectStart, box []), (ObjectEnd, box [])]
+            vec![(ObjectStart, vec![]), (ObjectEnd, vec![])]
         );
         assert_stream_equal(
             "{\"a\": 3}",
-            box [
-                (ObjectStart,        box []),
-                  (NumberValue(3.0), box [Key("a")]),
-                (ObjectEnd,          box []),
+            vec![
+                (ObjectStart,        vec![]),
+                  (NumberValue(3.0), vec![Key("a")]),
+                (ObjectEnd,          vec![]),
             ]
         );
         assert_stream_equal(
             "{ \"a\": null, \"b\" : true }",
-            box [
-                (ObjectStart,           box []),
-                  (NullValue,           box [Key("a")]),
-                  (BooleanValue(true),  box [Key("b")]),
-                (ObjectEnd,             box []),
+            vec![
+                (ObjectStart,           vec![]),
+                  (NullValue,           vec![Key("a")]),
+                  (BooleanValue(true),  vec![Key("b")]),
+                (ObjectEnd,             vec![]),
             ]
         );
         assert_stream_equal(
             "{\"a\" : 1.0 ,\"b\": [ true ]}",
-            box [
-                (ObjectStart,           box []),
-                  (NumberValue(1.0),    box [Key("a")]),
-                  (ListStart,           box [Key("b")]),
-                    (BooleanValue(true),box [Key("b"), Index(0)]),
-                  (ListEnd,             box [Key("b")]),
-                (ObjectEnd,             box []),
+            vec![
+                (ObjectStart,           vec![]),
+                  (NumberValue(1.0),    vec![Key("a")]),
+                  (ListStart,           vec![Key("b")]),
+                    (BooleanValue(true),vec![Key("b"), Index(0)]),
+                  (ListEnd,             vec![Key("b")]),
+                (ObjectEnd,             vec![]),
             ]
         );
         assert_stream_equal(
@@ -3154,19 +3152,19 @@ fn test_read_object_streaming() {
                     { "c": {"d": null} }
                 ]
             }"#,
-            ~[
-                (ObjectStart,                   ~[]),
-                  (NumberValue(1.0),            ~[Key("a")]),
-                  (ListStart,                   ~[Key("b")]),
-                    (BooleanValue(true),        ~[Key("b"), Index(0)]),
-                    (StringValue("foo\nbar".to_string()),  ~[Key("b"), Index(1)]),
-                    (ObjectStart,               ~[Key("b"), Index(2)]),
-                      (ObjectStart,             ~[Key("b"), Index(2), Key("c")]),
-                        (NullValue,             ~[Key("b"), Index(2), Key("c"), Key("d")]),
-                      (ObjectEnd,               ~[Key("b"), Index(2), Key("c")]),
-                    (ObjectEnd,                 ~[Key("b"), Index(2)]),
-                  (ListEnd,                     ~[Key("b")]),
-                (ObjectEnd,                     ~[]),
+            vec![
+                (ObjectStart,                   vec![]),
+                  (NumberValue(1.0),            vec![Key("a")]),
+                  (ListStart,                   vec![Key("b")]),
+                    (BooleanValue(true),        vec![Key("b"), Index(0)]),
+                    (StringValue("foo\nbar".to_string()),  vec![Key("b"), Index(1)]),
+                    (ObjectStart,               vec![Key("b"), Index(2)]),
+                      (ObjectStart,             vec![Key("b"), Index(2), Key("c")]),
+                        (NullValue,             vec![Key("b"), Index(2), Key("c"), Key("d")]),
+                      (ObjectEnd,               vec![Key("b"), Index(2), Key("c")]),
+                    (ObjectEnd,                 vec![Key("b"), Index(2)]),
+                  (ListEnd,                     vec![Key("b")]),
+                (ObjectEnd,                     vec![]),
             ]
         );
     }
@@ -3175,70 +3173,70 @@ fn test_read_object_streaming() {
     fn test_read_list_streaming() {
         assert_stream_equal(
             "[]",
-            box [
-                (ListStart, box []),
-                (ListEnd,   box []),
+            vec![
+                (ListStart, vec![]),
+                (ListEnd,   vec![]),
             ]
         );
         assert_stream_equal(
             "[ ]",
-            box [
-                (ListStart, box []),
-                (ListEnd,   box []),
+            vec![
+                (ListStart, vec![]),
+                (ListEnd,   vec![]),
             ]
         );
         assert_stream_equal(
             "[true]",
-            box [
-                (ListStart,              box []),
-                    (BooleanValue(true), box [Index(0)]),
-                (ListEnd,                box []),
+            vec![
+                (ListStart,              vec![]),
+                    (BooleanValue(true), vec![Index(0)]),
+                (ListEnd,                vec![]),
             ]
         );
         assert_stream_equal(
             "[ false ]",
-            box [
-                (ListStart,               box []),
-                    (BooleanValue(false), box [Index(0)]),
-                (ListEnd,                 box []),
+            vec![
+                (ListStart,               vec![]),
+                    (BooleanValue(false), vec![Index(0)]),
+                (ListEnd,                 vec![]),
             ]
         );
         assert_stream_equal(
             "[null]",
-            box [
-                (ListStart,     box []),
-                    (NullValue, box [Index(0)]),
-                (ListEnd,       box []),
+            vec![
+                (ListStart,     vec![]),
+                    (NullValue, vec![Index(0)]),
+                (ListEnd,       vec![]),
             ]
         );
         assert_stream_equal(
             "[3, 1]",
-            box [
-                (ListStart,     box []),
-                    (NumberValue(3.0), box [Index(0)]),
-                    (NumberValue(1.0), box [Index(1)]),
-                (ListEnd,       box []),
+            vec![
+                (ListStart,     vec![]),
+                    (NumberValue(3.0), vec![Index(0)]),
+                    (NumberValue(1.0), vec![Index(1)]),
+                (ListEnd,       vec![]),
             ]
         );
         assert_stream_equal(
             "\n[3, 2]\n",
-            box [
-                (ListStart,     box []),
-                    (NumberValue(3.0), box [Index(0)]),
-                    (NumberValue(2.0), box [Index(1)]),
-                (ListEnd,       box []),
+            vec![
+                (ListStart,     vec![]),
+                    (NumberValue(3.0), vec![Index(0)]),
+                    (NumberValue(2.0), vec![Index(1)]),
+                (ListEnd,       vec![]),
             ]
         );
         assert_stream_equal(
             "[2, [4, 1]]",
-            box [
-                (ListStart,                 box []),
-                    (NumberValue(2.0),      box [Index(0)]),
-                    (ListStart,             box [Index(1)]),
-                        (NumberValue(4.0),  box [Index(1), Index(0)]),
-                        (NumberValue(1.0),  box [Index(1), Index(1)]),
-                    (ListEnd,               box [Index(1)]),
-                (ListEnd,                   box []),
+            vec![
+                (ListStart,                 vec![]),
+                    (NumberValue(2.0),      vec![Index(0)]),
+                    (ListStart,             vec![Index(1)]),
+                        (NumberValue(4.0),  vec![Index(1), Index(0)]),
+                        (NumberValue(1.0),  vec![Index(1), Index(1)]),
+                    (ListEnd,               vec![Index(1)]),
+                (ListEnd,                   vec![]),
             ]
         );
 
@@ -3368,7 +3366,7 @@ fn test_to_json() {
         assert_eq!((1, 2, 3).to_json(), list3);
         assert_eq!([1, 2].to_json(), list2);
         assert_eq!((&[1, 2, 3]).to_json(), list3);
-        assert_eq!((~[1, 2]).to_json(), list2);
+        assert_eq!((vec![1, 2]).to_json(), list2);
         assert_eq!(vec!(1, 2, 3).to_json(), list3);
         let mut tree_map = TreeMap::new();
         tree_map.insert("a".to_string(), 1);
index d4987bd0afe0bb362911c9b31ee8c6efe8a8fb8c..40092a477b3967257b645a986e25d7246da0d1cf 100644 (file)
@@ -425,32 +425,6 @@ fn encode(&self, s: &mut S) -> Result<(), E> {
     }
 }
 
-impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for ~[T] {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_seq(self.len(), |s| {
-            for (i, e) in self.iter().enumerate() {
-                try!(s.emit_seq_elt(i, |s| e.encode(s)))
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for ~[T] {
-    fn decode(d: &mut D) -> Result<~[T], E> {
-        use std::vec::FromVec;
-
-        d.read_seq(|d, len| {
-            let mut v: Vec<T> = Vec::with_capacity(len);
-            for i in range(0, len) {
-                v.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
-            }
-            let k: ~[T] = FromVec::from_vec(v);
-            Ok(k)
-        })
-    }
-}
-
 impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for Vec<T> {
     fn encode(&self, s: &mut S) -> Result<(), E> {
         s.emit_seq(self.len(), |s| {
index b9edc9a811e43486af96ba81ebc99df56c73a4de..2730d90f05fc121b6acccad4eb3bd89d466bf468 100644 (file)
@@ -278,18 +278,6 @@ fn into_ascii_opt(self) -> Option<Vec<Ascii>> {
     unsafe fn into_ascii_nocheck(self) -> Vec<Ascii>;
 }
 
-impl OwnedAsciiCast for ~[u8] {
-    #[inline]
-    fn is_ascii(&self) -> bool {
-        self.as_slice().is_ascii()
-    }
-
-    #[inline]
-    unsafe fn into_ascii_nocheck(self) -> Vec<Ascii> {
-        mem::transmute(Vec::from_slice(self.as_slice()))
-    }
-}
-
 impl OwnedAsciiCast for String {
     #[inline]
     fn is_ascii(&self) -> bool {
@@ -353,14 +341,6 @@ fn eq_ignore_case(self, other: &[Ascii]) -> bool {
     }
 }
 
-impl IntoStr for ~[Ascii] {
-    #[inline]
-    fn into_str(self) -> String {
-        let vector: Vec<Ascii> = self.as_slice().iter().map(|x| *x).collect();
-        vector.into_str()
-    }
-}
-
 impl IntoStr for Vec<Ascii> {
     #[inline]
     fn into_str(self) -> String {
@@ -592,8 +572,8 @@ fn test_ascii_vec() {
         let test = &[40u8, 32u8, 59u8];
         assert_eq!(test.to_ascii(), v2ascii!([40, 32, 59]));
         assert_eq!("( ;".to_ascii(), v2ascii!([40, 32, 59]));
-        let v = box [40u8, 32u8, 59u8];
-        assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59]));
+        let v = vec![40u8, 32u8, 59u8];
+        assert_eq!(v.as_slice().to_ascii(), v2ascii!([40, 32, 59]));
         assert_eq!("( ;".to_string().as_slice().to_ascii(), v2ascii!([40, 32, 59]));
 
         assert_eq!("abCDef&?#".to_ascii().to_lower().into_str(), "abcdef&?#".to_string());
@@ -623,7 +603,7 @@ fn test_ascii_vec_ng() {
     #[test]
     fn test_owned_ascii_vec() {
         assert_eq!(("( ;".to_string()).into_ascii(), vec2ascii![40, 32, 59]);
-        assert_eq!((box [40u8, 32u8, 59u8]).into_ascii(), vec2ascii![40, 32, 59]);
+        assert_eq!((vec![40u8, 32u8, 59u8]).into_ascii(), vec2ascii![40, 32, 59]);
     }
 
     #[test]
index 529536b0a0da78317bae8db7fedef77408c70f4f..c03fbf302d75419a4ab2f5676d8904640c7817f7 100644 (file)
@@ -15,9 +15,9 @@
 use io;
 use option::{None, Option, Some};
 use result::{Ok, Err};
-use super::{Reader, Writer, IoResult};
-use str::StrSlice;
 use slice::{bytes, MutableVector, ImmutableVector};
+use str::StrSlice;
+use super::{Reader, Writer, IoResult};
 use vec::Vec;
 
 /// Allows reading from a rx.
@@ -162,14 +162,14 @@ fn test_rx_reader() {
         assert_eq!(Ok(2), reader.read(buf));
         assert_eq!(&[7,8,6], buf.as_slice());
 
-        match reader.read(buf) {
+        match reader.read(buf.as_mut_slice()) {
             Ok(..) => fail!(),
             Err(e) => assert_eq!(e.kind, io::EndOfFile),
         }
         assert_eq!(&[7,8,6], buf.as_slice());
 
         // Ensure it continues to fail in the same way.
-        match reader.read(buf) {
+        match reader.read(buf.as_mut_slice()) {
             Ok(..) => fail!(),
             Err(e) => assert_eq!(e.kind, io::EndOfFile),
         }
index d61518d4ee76f9aa36db766b634eebdf4c3a8402..84a1253e5b4ae50a60fa1de3a4a17be09991f465 100644 (file)
@@ -447,10 +447,10 @@ fn test_read_be_int_n() {
     #[test]
     fn test_read_f32() {
         //big-endian floating-point 8.1250
-        let buf = box [0x41, 0x02, 0x00, 0x00];
+        let buf = vec![0x41, 0x02, 0x00, 0x00];
 
         let mut writer = MemWriter::new();
-        writer.write(buf).unwrap();
+        writer.write(buf.as_slice()).unwrap();
 
         let mut reader = MemReader::new(writer.unwrap());
         let f = reader.read_be_f32().unwrap();
index 5259200133ae1974e1af84e02146849f8a2110ed..c29c82ab2e9b443085be829f7fa7e378d081db9f 100644 (file)
@@ -52,6 +52,9 @@
 use c_str::ToCStr;
 use clone::Clone;
 use collections::Collection;
+use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode};
+use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader};
+use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
 use io;
 use iter::Iterator;
 use kinds::Send;
 use owned::Box;
 use path::{Path, GenericPath};
 use path;
-use result::{Ok, Err};
-use rt::rtio::{RtioFileStream, IoFactory, LocalIo};
+use result::{Err, Ok};
+use rt::rtio::LocalIo;
 use rt::rtio;
-use slice::{OwnedVector, ImmutableVector};
-use super::UnstableFileStat;
-use super::{FileMode, FileAccess, FileStat, IoResult, FilePermission};
-use super::{Reader, Writer, Seek, Append, SeekCur, SeekEnd, SeekSet};
-use super::{SeekStyle, Read, Write, ReadWrite, Open, IoError, Truncate};
+use slice::ImmutableVector;
 use vec::Vec;
 
 /// Unconstrained file access type that exposes read and write operations
@@ -82,7 +81,7 @@
 /// configured at creation time, via the `FileAccess` parameter to
 /// `File::open_mode()`.
 pub struct File {
-    fd: Box<RtioFileStream:Send>,
+    fd: Box<rtio::RtioFileStream:Send>,
     path: Path,
     last_nread: int,
 }
@@ -846,7 +845,7 @@ pub fn tmpdir() -> TempDir {
             let mut read_buf = [0, .. 1028];
             let read_str = match check!(read_stream.read(read_buf)) {
                 -1|0 => fail!("shouldn't happen"),
-                n => str::from_utf8(read_buf.slice_to(n).to_owned()).unwrap().to_owned()
+                n => str::from_utf8(read_buf.slice_to(n)).unwrap().to_owned()
             };
             assert_eq!(read_str, message.to_owned());
         }
index f0fbe4529b0e959c3b6aeb88155400332cf2fdd8..71a967bb8dc5f41037fc64910f756fa1bb274e70 100644 (file)
@@ -450,8 +450,8 @@ fn test_mem_reader() {
 
     #[test]
     fn test_buf_reader() {
-        let in_buf = box [0, 1, 2, 3, 4, 5, 6, 7];
-        let mut reader = BufReader::new(in_buf);
+        let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
+        let mut reader = BufReader::new(in_buf.as_slice());
         let mut buf = [];
         assert_eq!(reader.read(buf), Ok(0));
         assert_eq!(reader.tell(), Ok(0));
@@ -466,7 +466,7 @@ fn test_buf_reader() {
         assert_eq!(reader.read(buf), Ok(3));
         assert_eq!(buf.slice(0, 3), &[5, 6, 7]);
         assert!(reader.read(buf).is_err());
-        let mut reader = BufReader::new(in_buf);
+        let mut reader = BufReader::new(in_buf.as_slice());
         assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
         assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7));
         assert!(reader.read(buf).is_err());
index 3cb2fe1c8f1b3bc35a446b05ceafe465f628a2ef..a626d1f3a6c08660b413f289e1d662d32a6350f7 100644 (file)
@@ -856,8 +856,8 @@ pub fn env_cmd() -> Command {
     })
 
     iotest!(fn test_add_to_env() {
-        let new_env = box [("RUN_TEST_NEW_ENV", "123")];
-        let prog = env_cmd().env(new_env).spawn().unwrap();
+        let new_env = vec![("RUN_TEST_NEW_ENV", "123")];
+        let prog = env_cmd().env(new_env.as_slice()).spawn().unwrap();
         let result = prog.wait_with_output().unwrap();
         let output = str::from_utf8_lossy(result.output.as_slice()).into_string();
 
index 59c42f111d0faed566ec0bb5b9c85b0f9a423565..83a01feee9017865f0c13878ca2282b28f805be2 100644 (file)
@@ -300,24 +300,24 @@ fn test_limit_reader_limit() {
     #[test]
     fn test_null_writer() {
         let mut s = NullWriter;
-        let buf = box [0, 0, 0];
-        s.write(buf).unwrap();
+        let buf = vec![0, 0, 0];
+        s.write(buf.as_slice()).unwrap();
         s.flush().unwrap();
     }
 
     #[test]
     fn test_zero_reader() {
         let mut s = ZeroReader;
-        let mut buf = box [1, 2, 3];
-        assert_eq!(s.read(buf), Ok(3));
-        assert_eq!(box [0, 0, 0], buf);
+        let mut buf = vec![1, 2, 3];
+        assert_eq!(s.read(buf.as_mut_slice()), Ok(3));
+        assert_eq!(vec![0, 0, 0], buf);
     }
 
     #[test]
     fn test_null_reader() {
         let mut r = NullReader;
-        let mut buf = box [0];
-        assert!(r.read(buf).is_err());
+        let mut buf = vec![0];
+        assert!(r.read(buf.as_mut_slice()).is_err());
     }
 
     #[test]
index fa882e7d016fe21783efe91b2ed1cebd09c62af4..22418cff957c5c254d1a0ca5361041987b7eeea4 100644 (file)
@@ -42,7 +42,7 @@
 use ptr::RawPtr;
 use ptr;
 use result::{Err, Ok, Result};
-use slice::{Vector, ImmutableVector, MutableVector, OwnedVector};
+use slice::{Vector, ImmutableVector, MutableVector};
 use str::{Str, StrSlice, StrAllocating};
 use str;
 use string::String;
@@ -536,7 +536,7 @@ fn load_self() -> Option<Vec<u8>> {
         unsafe {
             use libc::funcs::bsd44::*;
             use libc::consts::os::extra::*;
-            let mib = box [CTL_KERN as c_int,
+            let mib = vec![CTL_KERN as c_int,
                         KERN_PROC as c_int,
                         KERN_PROC_PATHNAME as c_int, -1 as c_int];
             let mut sz: libc::size_t = 0;
index a101f0432126e2ff4de213bd9303071fc42f9514..7d15893af241e865136b1194dca2536d8cff462a 100644 (file)
@@ -63,8 +63,6 @@
 
 */
 
-#![deny(deprecated_owned_vector)]
-
 use collections::Collection;
 use c_str::CString;
 use clone::Clone;
@@ -527,13 +525,6 @@ fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
     }
 }
 
-impl BytesContainer for ~[u8] {
-    #[inline]
-    fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
-        self.as_slice()
-    }
-}
-
 impl BytesContainer for Vec<u8> {
     #[inline]
     fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
index 171535edbeb346b2ac4ce429a9e4f3609db81eba..494428de3a5c48aadaf85dc7563208bac908cae4 100644 (file)
@@ -22,7 +22,7 @@
 use str::Str;
 use str;
 use slice::{CloneableVector, Splits, Vector, VectorVector,
-            ImmutableEqVector, OwnedVector, ImmutableVector};
+            ImmutableEqVector, ImmutableVector};
 use vec::Vec;
 
 use super::{BytesContainer, GenericPath, GenericPathUnsafe};
@@ -282,7 +282,6 @@ fn is_ancestor_of(&self, other: &Path) -> bool {
         }
     }
 
-    #[allow(deprecated_owned_vector)]
     fn path_relative_from(&self, base: &Path) -> Option<Path> {
         if self.is_absolute() != base.is_absolute() {
             if self.is_absolute() {
index 011dfa6eeacc1e5f629164ff2b1d69b3b89fa86e..e3209c5c186477d5ee310f5f9b6a3c9e2744457f 100644 (file)
@@ -21,7 +21,7 @@
 use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Iterator, Map};
 use mem;
 use option::{Option, Some, None};
-use slice::{Vector, OwnedVector, ImmutableVector};
+use slice::{Vector, ImmutableVector};
 use str::{CharSplits, Str, StrAllocating, StrVector, StrSlice};
 use string::String;
 use vec::Vec;
index eb862ecf932901c72046ca5641f6aaa52e5f885b..6fb08b6ef7556fe5906de31f4207b023ea2619d0 100644 (file)
@@ -83,7 +83,7 @@
 #[doc(no_inline)] pub use slice::{MutableCloneableVector, MutableOrdVector};
 #[doc(no_inline)] pub use slice::{ImmutableVector, MutableVector};
 #[doc(no_inline)] pub use slice::{ImmutableEqVector, ImmutableOrdVector};
-#[doc(no_inline)] pub use slice::{Vector, VectorVector, OwnedVector};
+#[doc(no_inline)] pub use slice::{Vector, VectorVector};
 #[doc(no_inline)] pub use slice::MutableVectorAllocating;
 #[doc(no_inline)] pub use string::String;
 #[doc(no_inline)] pub use vec::Vec;
index 8655d1e47d51a01772f112c8fde0102bc45c2a82..fe5d8fc068c919b50d18baa8bf92545cd3bc49fe 100644 (file)
@@ -71,7 +71,6 @@ fn fill_bytes(&mut self, v: &mut [u8]) {
 }
 
 #[cfg(test)]
-#[allow(deprecated_owned_vector)]
 mod test {
     use prelude::*;
 
@@ -83,24 +82,23 @@ mod test {
     #[test]
     fn test_reader_rng_u64() {
         // transmute from the target to avoid endianness concerns.
-        let v = box [1u64, 2u64, 3u64];
-        let bytes: ~[u8] = unsafe {mem::transmute(v)};
-        let mut rng = ReaderRng::new(MemReader::new(bytes.move_iter().collect()));
+        let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1,
+                     0  , 0, 0, 0, 0, 0, 0, 2,
+                     0,   0, 0, 0, 0, 0, 0, 3];
+        let mut rng = ReaderRng::new(MemReader::new(v));
 
-        assert_eq!(rng.next_u64(), 1);
-        assert_eq!(rng.next_u64(), 2);
-        assert_eq!(rng.next_u64(), 3);
+        assert_eq!(rng.next_u64(), mem::to_be64(1));
+        assert_eq!(rng.next_u64(), mem::to_be64(2));
+        assert_eq!(rng.next_u64(), mem::to_be64(3));
     }
     #[test]
     fn test_reader_rng_u32() {
-        // transmute from the target to avoid endianness concerns.
-        let v = box [1u32, 2u32, 3u32];
-        let bytes: ~[u8] = unsafe {mem::transmute(v)};
-        let mut rng = ReaderRng::new(MemReader::new(bytes.move_iter().collect()));
+        let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3];
+        let mut rng = ReaderRng::new(MemReader::new(v));
 
-        assert_eq!(rng.next_u32(), 1);
-        assert_eq!(rng.next_u32(), 2);
-        assert_eq!(rng.next_u32(), 3);
+        assert_eq!(rng.next_u32(), mem::to_be32(1));
+        assert_eq!(rng.next_u32(), mem::to_be32(2));
+        assert_eq!(rng.next_u32(), mem::to_be32(3));
     }
     #[test]
     fn test_reader_rng_fill_bytes() {
index 3b223b68ee666204d7d7412ef6c85317e3f9fa02..9a1c0151e5411b1b55ee851a48cf5a556fb3c126 100644 (file)
@@ -37,8 +37,8 @@ fn to_str(&self) -> String {
 
 #[cfg(test)]
 mod tests {
+    use prelude::*;
     use super::*;
-    use str::StrAllocating;
 
     #[test]
     fn test_simple_types() {
@@ -54,11 +54,11 @@ fn test_simple_types() {
 
     #[test]
     fn test_vectors() {
-        let x: ~[int] = box [];
+        let x: Vec<int> = vec![];
         assert_eq!(x.to_str(), "[]".to_string());
-        assert_eq!((box [1]).to_str(), "[1]".to_string());
-        assert_eq!((box [1, 2, 3]).to_str(), "[1, 2, 3]".to_string());
-        assert!((box [box [], box [1], box [1, 1]]).to_str() ==
+        assert_eq!((vec![1]).to_str(), "[1]".to_string());
+        assert_eq!((vec![1, 2, 3]).to_str(), "[1, 2, 3]".to_string());
+        assert!((vec![vec![], vec![1], vec![1, 1]]).to_str() ==
                "[[], [1], [1, 1]]".to_string());
     }
 }
index 9f0109282564293db77e4ac8b5939202c344d0e2..66ca10b196c6c4363a6890d9140241a0a7b78f52 100644 (file)
@@ -26,7 +26,7 @@
        html_root_url = "http://doc.rust-lang.org/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![feature(phase, globs, macro_rules)]
-#![deny(deprecated_owned_vector)]
+
 #![deny(missing_doc)]
 #![no_std]
 
index 9706176ca8babbe9e26a4d7b567a187a5c5737a7..e280c244929836d86080a9752978bd05ff61fee8 100644 (file)
@@ -30,6 +30,7 @@ pub enum ObsoleteSyntax {
     ObsoleteOwnedType,
     ObsoleteOwnedExpr,
     ObsoleteOwnedPattern,
+    ObsoleteOwnedVector,
 }
 
 pub trait ParserObsoleteMethods {
@@ -63,6 +64,10 @@ fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
                 "`~` notation for owned pointer patterns",
                 "use the `box` operator instead of `~`"
             ),
+            ObsoleteOwnedVector => (
+                "`~[T]` is no longer a type",
+                "use the `Vec` type instead"
+            ),
         };
 
         self.report(sp, kind, kind_str, desc);
index 8083bf41706d65acea1c25272057b941b2dbdcd5..4d9b112cb5c3a191e552ff3479e0d7fbefe9b60d 100644 (file)
@@ -1315,11 +1315,8 @@ pub fn parse_ty(&mut self, _: bool) -> P<Ty> {
             // OWNED POINTER
             self.bump();
             match self.token {
-                token::IDENT(ref ident, _)
-                        if "str" == token::get_ident(*ident).get() => {
-                    // This is OK (for now).
-                }
-                token::LBRACKET => {}   // Also OK.
+                token::LBRACKET =>
+                    self.obsolete(self.last_span, ObsoleteOwnedVector),
                 _ => self.obsolete(self.last_span, ObsoleteOwnedType),
             };
             TyUniq(self.parse_ty(false))
@@ -2342,7 +2339,10 @@ pub fn parse_prefix_expr(&mut self) -> Gc<Expr> {
             hi = e.span.hi;
             // HACK: turn ~[...] into a ~-vec
             ex = match e.node {
-              ExprVec(..) | ExprRepeat(..) => ExprVstore(e, ExprVstoreUniq),
+              ExprVec(..) | ExprRepeat(..) => {
+                  self.obsolete(self.last_span, ObsoleteOwnedVector);
+                  ExprVstore(e, ExprVstoreUniq)
+              }
               ExprLit(lit) if lit_is_str(lit) => {
                   self.obsolete(self.last_span, ObsoleteOwnedExpr);
                   ExprVstore(e, ExprVstoreUniq)
@@ -2375,6 +2375,7 @@ pub fn parse_prefix_expr(&mut self) -> Gc<Expr> {
             // HACK: turn `box [...]` into a boxed-vec
             ex = match subexpression.node {
                 ExprVec(..) | ExprRepeat(..) => {
+                    self.obsolete(self.last_span, ObsoleteOwnedVector);
                     ExprVstore(subexpression, ExprVstoreUniq)
                 }
                 ExprLit(lit) if lit_is_str(lit) => {
index 7d94e46a88a6e74b5769e57e1f5fc4e979422482..d0101e993c49d191ad10ccb11a423e6702cb1366 100644 (file)
@@ -33,7 +33,6 @@
        html_root_url = "http://doc.rust-lang.org/")]
 
 #![feature(asm, macro_rules, phase)]
-#![deny(deprecated_owned_vector)]
 
 extern crate getopts;
 extern crate regex;
@@ -72,7 +71,7 @@ pub mod test {
              MetricChange, Improvement, Regression, LikelyNoise,
              StaticTestFn, StaticTestName, DynTestName, DynTestFn,
              run_test, test_main, test_main_static, filter_tests,
-             parse_opts, StaticBenchFn, test_main_static_x};
+             parse_opts, StaticBenchFn};
 }
 
 pub mod stats;
@@ -263,14 +262,6 @@ pub fn test_main_static(args: &[String], tests: &[TestDescAndFn]) {
     test_main(args, owned_tests)
 }
 
-pub fn test_main_static_x(args: &[~str], tests: &[TestDescAndFn]) {
-    test_main_static(args.iter()
-                         .map(|x| x.to_string())
-                         .collect::<Vec<_>>()
-                         .as_slice(),
-                     tests)
-}
-
 pub enum ColorConfig {
     AutoColor,
     AlwaysColor,
index c6a45b651ef936e2f9c70d69b92de537d4d076b3..aa0e9b46fa7c336cc34856455a66225f43010f52 100644 (file)
@@ -167,7 +167,6 @@ pub fn new(samples: &[T]) -> Summary<T> {
 impl<'a,T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
 
     // FIXME #11059 handle NaN, inf and overflow
-    #[allow(deprecated_owned_vector)]
     fn sum(self) -> T {
         let mut partials = vec![];
 
@@ -1027,7 +1026,6 @@ fn test_unif25() {
 
     #[test]
     fn test_boxplot_nonpositive() {
-        #[allow(deprecated_owned_vector)]
         fn t(s: &Summary<f64>, expected: String) {
             use std::io::MemWriter;
             let mut m = MemWriter::new();
index c13cce36c0a915e035c45abb9923b565dd68415f..63523cd3a6f6a877482e2da76f4d5743e3f515fa 100644 (file)
@@ -20,7 +20,6 @@
        html_root_url = "http://doc.rust-lang.org/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![feature(phase)]
-#![deny(deprecated_owned_vector)]
 
 #[cfg(test)] extern crate debug;
 
index 64f3e633d034c4d3a719fb81fde7cb30cb189cb8..19b9d5638d0d8f3f034586958591b6322ebacd26 100644 (file)
@@ -75,7 +75,7 @@ fn main() {
     let clen = seq.len();
 
     let mut seqlen = Future::spawn(proc() {
-        let substs = ~[
+        let substs = vec![
             (regex!("B"), "(c|g|t)"),
             (regex!("D"), "(a|g|t)"),
             (regex!("H"), "(a|c|t)"),
@@ -95,7 +95,7 @@ fn main() {
         seq.len()
     });
 
-    let variants = ~[
+    let variants = vec![
         regex!("agggtaaa|tttaccct"),
         regex!("[cgt]gggtaaa|tttaccc[acg]"),
         regex!("a[act]ggtaaa|tttacc[agt]t"),
index 3ced98592400ee24692a8cea022465d00579e0f7..3cd582ca0b8c3a9bad17071194031bd10ca34b64 100644 (file)
@@ -9,11 +9,10 @@
 // except according to those terms.
 
 fn test() {
-    let w: ~[int];
+    let w: &mut [int];
     w[5] = 0; //~ ERROR use of possibly uninitialized variable: `w`
-              //~^ ERROR cannot assign to immutable vec content `w[..]`
 
-    let mut w: ~[int];
+    let mut w: &mut [int];
     w[5] = 0; //~ ERROR use of possibly uninitialized variable: `w`
 }
 
index b12e6799e6a7945920ad22b8b01cd5d08155f40d..7457a1020cee1c31c7fdf01bfaa6663fdb5497c9 100644 (file)
@@ -11,8 +11,6 @@
 #![deny(unreachable_code)]
 #![allow(unused_variable)]
 #![allow(dead_code)]
-#![allow(deprecated_owned_vector)]
-
 
 fn fail_len(v: Vec<int> ) -> uint {
     let mut i = 3;
diff --git a/src/test/compile-fail/lint-deprecated-owned-vector.rs b/src/test/compile-fail/lint-deprecated-owned-vector.rs
deleted file mode 100644 (file)
index 537f3c9..0000000
+++ /dev/null
@@ -1,16 +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.
-
-#![deny(deprecated_owned_vector)]
-
-fn main() {
-    ~[1]; //~ ERROR use of deprecated `~[]`
-    //~^ ERROR use of deprecated `~[]`
-}
index ae18e9bebad599b07c45a29ba05203fca3f55af1..26cae1aa708112331822d8e9aef3649bf733d1b3 100644 (file)
@@ -11,7 +11,6 @@
 #![feature(managed_boxes)]
 #![forbid(heap_memory)]
 #![allow(dead_code)]
-#![allow(deprecated_owned_vector)]
 
 
 struct Foo {
index cb05c2833345c0d2fec11866bf5eb56247d1186c..4334d2f63ea59c41e94263c90b12700daf9330d6 100644 (file)
@@ -11,7 +11,6 @@
 #![feature(globs)]
 #![deny(unused_imports)]
 #![allow(dead_code)]
-#![allow(deprecated_owned_vector)]
 
 use cal = bar::c::cc;
 
index 671fecc4e22e7581d57ffca4a3f463b86c56dbfe..d5f34669a25e2355b415b366485fa2fce3ea2cb6 100644 (file)
@@ -13,7 +13,6 @@
 #![allow(dead_assignment)]
 #![allow(unused_variable)]
 #![allow(dead_code)]
-#![allow(deprecated_owned_vector)]
 #![deny(unused_mut)]
 
 
index 7c459434bcabd1023d47f86e05654ecee8195f1d..8ae3f1fdd0d74bc76efe6ba3a745d1885edb2771 100644 (file)
@@ -12,7 +12,6 @@
 
 #![allow(dead_code)]
 #![deny(unused_unsafe)]
-#![allow(deprecated_owned_vector)]
 
 
 mod foo {
index a6baf21549e5845f8f7bfdbd63998d98b2af72a3..15544468ae992a7ecdc4cbbce137c92ee54bbfbc 100644 (file)
@@ -13,7 +13,4 @@ pub fn main() {
 
     struct Foo;
     assert!(Some(box Foo).is_some());
-
-    let xs: ~[()] = ~[];
-    assert!(Some(xs).is_some());
 }
index b69450024f656685757be2fd16efa750e47f6388..7078518bebcf9598f2fe53691945b62cedb5f4d6 100644 (file)
@@ -13,7 +13,6 @@
 #![feature(macro_rules, managed_boxes)]
 #![deny(warnings)]
 #![allow(unused_must_use)]
-#![allow(deprecated_owned_vector)]
 
 extern crate debug;
 
index 782cea2979f2702966cdd65bf942fcfa83bfe17c..cd5903ad4e3b5f6d2ab949ee7787d3e597f1d87f 100644 (file)
@@ -45,7 +45,7 @@ pub fn main() {
     p.borrow_mut().y += 3;
     assert_eq!(*p.borrow(), Point {x: 3, y: 5});
 
-    let v = Rc::new(RefCell::new(~[1, 2, 3]));
+    let v = Rc::new(RefCell::new([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));
index 6fbb311593bfafd96fb4883f5d7554a279e9e5a3..b471d13901e093a4878c370ad2df856ca81ab7b0 100644 (file)
@@ -62,8 +62,6 @@ fn visit_f128(&mut self) -> bool { true }
 
     fn visit_char(&mut self) -> bool { true }
 
-    fn visit_estr_box(&mut self) -> bool { true }
-    fn visit_estr_uniq(&mut self) -> bool { true }
     fn visit_estr_slice(&mut self) -> bool { true }
     fn visit_estr_fixed(&mut self,
                         _sz: uint, _sz2: uint,
@@ -74,13 +72,6 @@ fn visit_uniq(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { true }
     fn visit_ptr(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { true }
     fn visit_rptr(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { true }
 
-    fn visit_evec_box(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { true }
-    fn visit_evec_uniq(&mut self, _mtbl: uint, inner: *TyDesc) -> bool {
-        self.types.push("[".to_string());
-        unsafe { visit_tydesc(inner, &mut *self as &mut TyVisitor); }
-        self.types.push("]".to_string());
-        true
-    }
     fn visit_evec_slice(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { true }
     fn visit_evec_fixed(&mut self, _n: uint, _sz: uint, _align: uint,
                         _mtbl: uint, _inner: *TyDesc) -> bool { true }