diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index ba3180cefd6..b03486a6c22 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -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 @@ mod bench { box 10 }) } - - #[bench] - fn alloc_owned_big(b: &mut Bencher) { - b.iter(|| { - box [10, ..1000] - }) - } } diff --git a/src/libcollections/hash/mod.rs b/src/libcollections/hash/mod.rs index b484b2c8128..bd7bab456ba 100644 --- a/src/libcollections/hash/mod.rs +++ b/src/libcollections/hash/mod.rs @@ -213,13 +213,6 @@ impl<'a, S: Writer, T: Hash> Hash for &'a mut [T] { } } -impl> Hash for ~[T] { - #[inline] - fn hash(&self, state: &mut S) { - self.as_slice().hash(state); - } -} - impl> Hash for Vec { #[inline] fn hash(&self, state: &mut S) { diff --git a/src/libcollections/hash/sip.rs b/src/libcollections/hash/sip.rs index 74e93284d2a..887b0fb0b8a 100644 --- a/src/libcollections/hash/sip.rs +++ b/src/libcollections/hash/sip.rs @@ -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 @@ mod tests { s } - fn result_bytes(h: u64) -> ~[u8] { - box [(h >> 0) as u8, + fn result_bytes(h: u64) -> Vec { + vec![(h >> 0) as u8, (h >> 8) as u8, (h >> 16) as u8, (h >> 24) as u8, diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 1bc56368693..865da9eff13 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -101,11 +101,8 @@ There are a number of free functions that create or take vectors, for example: 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 @@ impl Iterator<(uint, uint)> for ElementSwaps { /// Generates even and odd permutations alternately. pub struct Permutations { swaps: ElementSwaps, - v: ~[T], + v: Vec, } -impl Iterator<~[T]> for Permutations { +impl Iterator> for Permutations { #[inline] - fn next(&mut self) -> Option<~[T]> { + fn next(&mut self) -> Option> { 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 @@ impl Iterator<~[T]> for Permutations { /// Extension methods for vector slices with cloneable elements pub trait CloneableVector { /// Copy `self` into a new owned vector - fn to_owned(&self) -> ~[T]; + fn to_owned(&self) -> Vec; /// Convert `self` into an owned vector, not making a copy if possible. - fn into_owned(self) -> ~[T]; + fn into_owned(self) -> Vec; } /// Extension methods for vector slices impl<'a, T: Clone> CloneableVector 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::()); - let data_size = data_size.expect("overflow in to_owned()"); - let size = mem::size_of::>().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::(); - 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 { Vec::from_slice(*self) } #[inline(always)] - fn into_owned(self) -> ~[T] { self.to_owned() } -} - -/// Extension methods for owned vectors -impl CloneableVector for ~[T] { - #[inline] - fn to_owned(&self) -> ~[T] { self.clone() } - - #[inline(always)] - fn into_owned(self) -> ~[T] { self } + fn into_owned(self) -> Vec { self.to_owned() } } /// Extension methods for vectors containing `Clone` elements. @@ -387,57 +331,6 @@ impl<'a,T:Clone> ImmutableCloneableVector for &'a [T] { } -/// Extension methods for owned vectors. -pub trait OwnedVector { - /// 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; - - /** - * 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, Vec); -} - -impl OwnedVector for ~[T] { - #[inline] - fn move_iter(self) -> MoveItems { - unsafe { - let iter = transmute(self.iter()); - let ptr = transmute(self); - MoveItems { allocation: ptr, iter: iter } - } - } - - #[inline] - fn partition(self, f: |&T| -> bool) -> (Vec, Vec) { - let mut lefts = Vec::new(); - let mut rights = Vec::new(); - - for elt in self.move_iter() { - if f(&elt) { - lefts.push(elt); - } else { - rights.push(elt); - } - } - - (lefts, rights) - } -} - fn insertion_sort(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, start: uint, end: uint) -> uint; } impl<'a,T> MutableVectorAllocating<'a, T> for &'a mut [T] { @@ -686,7 +579,7 @@ impl<'a,T> MutableVectorAllocating<'a, T> for &'a mut [T] { } #[inline] - fn move_from(self, mut src: ~[T], start: uint, end: uint) -> uint { + fn move_from(self, mut src: Vec, 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 { - allocation: *mut u8, // the block of memory allocated for the vector - iter: Items<'static, T> -} - -impl Iterator for MoveItems { - #[inline] - fn next(&mut self) -> Option { - unsafe { - self.iter.next().map(|x| ptr::read(x)) - } - } - - #[inline] - fn size_hint(&self) -> (uint, Option) { - self.iter.size_hint() - } -} - -impl DoubleEndedIterator for MoveItems { - #[inline] - fn next_back(&mut self) -> Option { - unsafe { - self.iter.next_back().map(|x| ptr::read(x)) - } - } -} - -#[unsafe_destructor] -impl Drop for MoveItems { - fn drop(&mut self) { - // destroy the remaining elements - for _x in *self {} - unsafe { - // 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 @@ mod tests { #[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 = 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 = 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 = 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 = 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { #[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 = 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 = vec![]; v3.reverse(); assert!(v3.is_empty()); } @@ -1505,10 +1360,10 @@ mod tests { #[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 @@ mod tests { #[test] fn test_concat() { - let v: [~[int], ..0] = []; + let v: [Vec, ..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, ..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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { assert_eq!(format!("{}", x.as_slice()), x_str); }) ) - let empty: ~[int] = box []; + let empty: Vec = 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 @@ mod tests { ); t!(&[int]); - t!(~[int]); t!(Vec); } @@ -2392,13 +2246,6 @@ mod bench { }); } - #[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(|| { diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 49d8775dd9c..83601be83de 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -707,7 +707,7 @@ pub mod raw { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { } 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 @@ mod tests { } 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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { #[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(); diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index dbef73efc47..acb7b2c2704 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -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::ptr; 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 @@ impl PartialOrd for Vec { impl Eq for Vec {} +impl> Equiv for Vec { + #[inline] + fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } +} + impl Ord for Vec { #[inline] fn cmp(&self, other: &Vec) -> Ordering { @@ -401,6 +405,11 @@ impl Collection for Vec { } } +impl CloneableVector for Vec { + fn to_owned(&self) -> Vec { self.clone() } + fn into_owned(self) -> Vec { self } +} + // FIXME: #13996: need a way to mark the return value as `noalias` #[inline(never)] unsafe fn alloc_or_realloc(ptr: *mut T, size: uint, old_size: uint) -> *mut T { @@ -1511,52 +1520,6 @@ pub fn unzip>(mut iter: V) -> (Vec, Vec) { (ts, us) } -/// Mechanism to convert from a `Vec` 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 { - /// Convert a `Vec` into the receiver type. - fn from_vec(v: Vec) -> Self; -} - -impl FromVec for ~[T] { - fn from_vec(mut v: Vec) -> ~[T] { - let len = v.len(); - let data_size = len.checked_mul(&mem::size_of::()); - let data_size = data_size.expect("overflow in from_vec()"); - let size = mem::size_of::>().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::(); - 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 mod raw { 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 @@ mod tests { 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; diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index f7680e6f847..e6c462c62d2 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -159,7 +159,7 @@ mod test { fn test_fn_a() -> f64 { 1.0 } fn test_fn_b(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::.clone(); diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs index d4571eb3a43..763ca843c11 100644 --- a/src/libcore/failure.rs +++ b/src/libcore/failure.rs @@ -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_"] diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 0e6a0d1c6f5..2464dfc9b5e 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -828,12 +828,6 @@ impl<'a, T: Show> Show for &'a mut [T] { } } -impl 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("()") diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 35c8afee4b6..d61416a68e0 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -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, diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 64c53b658ef..bb11ec5502e 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -35,7 +35,7 @@ into a `loop`, for example, the `for` loop in this example is essentially 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 @@ pub trait Iterator { /// } /// 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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { 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 @@ mod tests { #[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 @@ mod tests { } #[test] - fn test_MinMaxResult() { + fn test_min_max_result() { let r: MinMaxResult = NoElements; assert_eq!(r.into_option(), None) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 5661c668373..5c7b588a9c9 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -130,11 +130,6 @@ pub mod str; 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; diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 45ccf657dbd..a71727c3f8e 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -660,7 +660,7 @@ mod tests { } } - fn R(i: Rc>) -> R { + fn r(i: Rc>) -> R { R { i: i } @@ -673,7 +673,7 @@ mod tests { 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(); } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index b2776b78b1c..c37c66f9862 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -503,7 +503,8 @@ impl PartialOrd for *mut T { } #[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 @@ pub mod ptr_tests { 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 @@ pub mod ptr_tests { "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 @@ pub mod ptr_tests { #[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 @@ pub mod ptr_tests { 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 @@ pub mod ptr_tests { 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 @@ pub mod ptr_tests { 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 @@ pub mod ptr_tests { 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 @@ pub mod ptr_tests { 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 @@ pub mod ptr_tests { 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 diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 56db4ee8059..0a2a756c6b1 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -29,16 +29,6 @@ pub struct Box { pub data: T, } -/// The representation of a Rust vector -pub struct Vec { - pub fill: uint, - pub alloc: uint, - pub data: T, -} - -/// The representation of a Rust string -pub type String = Vec; - /// The representation of a Rust slice pub struct Slice { pub data: *T, @@ -79,7 +69,6 @@ pub trait Repr { impl<'a, T> Repr> for &'a [T] {} impl<'a> Repr> for &'a str {} -impl Repr<*Vec> for ~[T] {} #[cfg(test)] mod tests { diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 585373ec70c..d579d044892 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -266,38 +266,19 @@ pub mod traits { } } - impl 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 Eq for ~[T] {} - impl<'a,T:PartialEq, V: Vector> Equiv for &'a [T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } } - impl<'a,T:PartialEq, V: Vector> Equiv 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 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 @@ pub mod traits { order::gt(self.iter(), other.iter()) } } - - impl 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 for &'a [T] { fn as_slice<'a>(&'a self) -> &'a [T] { *self } } -impl Vector 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 @@ impl<'a, T> Collection for &'a [T] { } } -impl 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 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutChunks<'a, T> { impl<'a, T> Default for &'a [T] { fn default() -> &'a [T] { &[] } } - -impl Default for ~[T] { - fn default() -> ~[T] { ~[] } -} diff --git a/src/libdebug/reflect.rs b/src/libdebug/reflect.rs index 997d3427122..3a12aec39a1 100644 --- a/src/libdebug/reflect.rs +++ b/src/libdebug/reflect.rs @@ -192,15 +192,14 @@ impl TyVisitor for MovePtrAdaptor { 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 @@ impl TyVisitor for MovePtrAdaptor { 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 { diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs index e6cc9785b44..86b71eb5b8d 100644 --- a/src/libdebug/repr.rs +++ b/src/libdebug/repr.rs @@ -203,10 +203,6 @@ impl<'a> ReprVisitor<'a> { 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 @@ impl<'a> TyVisitor for ReprVisitor<'a> { }) } + #[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 @@ impl<'a> TyVisitor for ReprVisitor<'a> { }) } - fn visit_evec_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool { - self.get::<&raw::Box>>(|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 { diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index 8d8fe8ffe8c..955f697dce3 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -26,7 +26,6 @@ Simple [DEFLATE][def]-based compression. This is a wrapper around the 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!(); diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index 694fe7d0f48..3949bde3d52 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -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; diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index eb9c86f0014..db6d940a720 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -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; diff --git a/src/libglob/lib.rs b/src/libglob/lib.rs index 6d39a332ad9..a2c2706b4c2 100644 --- a/src/libglob/lib.rs +++ b/src/libglob/lib.rs @@ -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}; diff --git a/src/libgraphviz/maybe_owned_vec.rs b/src/libgraphviz/maybe_owned_vec.rs index 3015b6f12cc..a34791f470e 100644 --- a/src/libgraphviz/maybe_owned_vec.rs +++ b/src/libgraphviz/maybe_owned_vec.rs @@ -26,17 +26,13 @@ use std::slice; // of the contents of `Vec`, since we anticipate that to be a // frequent way to dynamically construct a vector. -/// MaybeOwnedVector<'a,T> abstracts over `Vec`, `~[T]`, `&'a [T]`. +/// MaybeOwnedVector<'a,T> abstracts over `Vec`, `&'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), - FixedLen(~[T]), Borrowed(&'a [T]), } @@ -51,11 +47,6 @@ impl<'a,T> IntoMaybeOwnedVector<'a,T> for Vec { 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 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 @@ impl<'a,T:fmt::Show> fmt::Show for MaybeOwnedVector<'a,T> { impl<'a,T:Clone> CloneableVector for MaybeOwnedVector<'a,T> { /// Returns a copy of `self`. - fn to_owned(&self) -> ~[T] { + fn to_owned(&self) -> Vec { 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 { 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 { match self { Growable(v) => v, - FixedLen(v) => Vec::from_slice(v.as_slice()), Borrowed(v) => Vec::from_slice(v), } } diff --git a/src/libgreen/context.rs b/src/libgreen/context.rs index 9071656f213..e6915385a42 100644 --- a/src/libgreen/context.rs +++ b/src/libgreen/context.rs @@ -191,9 +191,9 @@ type Registers = [uint, ..34]; type Registers = [uint, ..22]; #[cfg(windows, target_arch = "x86_64")] -fn new_regs() -> Box { box [0, .. 34] } +fn new_regs() -> Box { box() ([0, .. 34]) } #[cfg(not(windows), target_arch = "x86_64")] -fn new_regs() -> Box { box {let v = [0, .. 22]; v} } +fn new_regs() -> Box { box() ([0, .. 22]) } #[cfg(target_arch = "x86_64")] fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 9748dfbae33..e8de2b9bd93 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -209,7 +209,6 @@ // 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; diff --git a/src/libhexfloat/lib.rs b/src/libhexfloat/lib.rs index 54bc2802b09..b181b0ca8c9 100644 --- a/src/libhexfloat/lib.rs +++ b/src/libhexfloat/lib.rs @@ -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; diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 19f55c59491..2ecfef35308 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -115,7 +115,7 @@ if logging is disabled, none of the components of the log will be executed. 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; diff --git a/src/libnum/lib.rs b/src/libnum/lib.rs index 709882c87ce..27ccc528c94 100644 --- a/src/libnum/lib.rs +++ b/src/libnum/lib.rs @@ -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}; diff --git a/src/libregex/lib.rs b/src/libregex/lib.rs index 61e62a0d105..61b133c4e68 100644 --- a/src/libregex/lib.rs +++ b/src/libregex/lib.rs @@ -364,7 +364,7 @@ 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"; diff --git a/src/librustc/driver/mod.rs b/src/librustc/driver/mod.rs index 59f53986af9..b6205d8d54e 100644 --- a/src/librustc/driver/mod.rs +++ b/src/librustc/driver/mod.rs @@ -37,7 +37,7 @@ pub mod config; 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 } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index b8db8e230b0..bc5fad7f934 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -418,10 +418,10 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { 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 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { 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 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { 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 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { 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 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { 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 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { 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); } } diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 7527477384a..389a73c357b 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -121,8 +121,6 @@ pub enum Lint { UnusedMustUse, UnusedResult, - DeprecatedOwnedVector, - Warnings, RawPointerDeriving, @@ -433,13 +431,6 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[ 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 @@ impl<'a> Visitor<()> for Context<'a> { check_type_limits(self, e); check_unused_casts(self, e); - check_deprecated_owned_vector(self, e); visit::walk_expr(self, e, ()); } diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index 6b468bd0827..1a7f0cdfc50 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -24,13 +24,13 @@ modify/read the slot specified by the key. ```rust local_data_key!(key_int: int) -local_data_key!(key_vector: ~[int]) +local_data_key!(key_vector: Vec) 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]); ``` */ diff --git a/src/libsemver/lib.rs b/src/libsemver/lib.rs index dbde1a7486d..2ad69dad8d2 100644 --- a/src/libsemver/lib.rs +++ b/src/libsemver/lib.rs @@ -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; diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 9907faae52b..a5c2042c979 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -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 ToJson for ~[A] { - fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) } -} - impl ToJson for Vec { fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) } } @@ -3048,7 +3044,8 @@ mod tests { let _hm: HashMap = Decodable::decode(&mut decoder).unwrap(); } - fn assert_stream_equal(src: &str, expected: ~[(JsonEvent, ~[StackElement])]) { + fn assert_stream_equal(src: &str, + expected: Vec<(JsonEvent, Vec)>) { let mut parser = Parser::new(src.chars()); let mut i = 0; loop { @@ -3056,7 +3053,7 @@ mod tests { 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 @@ mod tests { } } #[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 @@ mod tests { 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 @@ mod tests { { "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 @@ mod tests { 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 @@ mod tests { 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); diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index d4987bd0afe..40092a477b3 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -425,32 +425,6 @@ impl<'a, E, S:Encoder,T:Encodable> Encodable for &'a [T] { } } -impl,T:Encodable> Encodable 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,T:Decodable> Decodable for ~[T] { - fn decode(d: &mut D) -> Result<~[T], E> { - use std::vec::FromVec; - - d.read_seq(|d, len| { - let mut v: Vec = 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,T:Encodable> Encodable for Vec { fn encode(&self, s: &mut S) -> Result<(), E> { s.emit_seq(self.len(), |s| { diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index b9edc9a811e..2730d90f05f 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -278,18 +278,6 @@ pub trait OwnedAsciiCast { unsafe fn into_ascii_nocheck(self) -> Vec; } -impl OwnedAsciiCast for ~[u8] { - #[inline] - fn is_ascii(&self) -> bool { - self.as_slice().is_ascii() - } - - #[inline] - unsafe fn into_ascii_nocheck(self) -> Vec { - mem::transmute(Vec::from_slice(self.as_slice())) - } -} - impl OwnedAsciiCast for String { #[inline] fn is_ascii(&self) -> bool { @@ -353,14 +341,6 @@ impl<'a> AsciiStr for &'a [Ascii] { } } -impl IntoStr for ~[Ascii] { - #[inline] - fn into_str(self) -> String { - let vector: Vec = self.as_slice().iter().map(|x| *x).collect(); - vector.into_str() - } -} - impl IntoStr for Vec { #[inline] fn into_str(self) -> String { @@ -592,8 +572,8 @@ mod tests { 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 @@ mod tests { #[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] diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index 529536b0a0d..c03fbf302d7 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -15,9 +15,9 @@ use comm::{Sender, Receiver}; 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 @@ mod test { 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), } diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index d61518d4ee7..84a1253e5b4 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -447,10 +447,10 @@ mod test { #[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(); diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 5259200133a..c29c82ab2e9 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -52,6 +52,9 @@ fs::unlink(&path); 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; @@ -60,14 +63,10 @@ use option::{Some, None, Option}; 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 @@ use vec::Vec; /// configured at creation time, via the `FileAccess` parameter to /// `File::open_mode()`. pub struct File { - fd: Box, + fd: Box, path: Path, last_nread: int, } @@ -846,7 +845,7 @@ mod test { 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()); } diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index f0fbe4529b0..71a967bb8dc 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -450,8 +450,8 @@ mod test { #[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 @@ mod test { 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()); diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 3cb2fe1c8f1..a626d1f3a6c 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -856,8 +856,8 @@ mod tests { }) 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(); diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 59c42f111d0..83a01feee90 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -300,24 +300,24 @@ mod test { #[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] diff --git a/src/libstd/os.rs b/src/libstd/os.rs index fa882e7d016..22418cff957 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -42,7 +42,7 @@ use path::{Path, GenericPath, BytesContainer}; 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 @@ pub fn self_exe_name() -> Option { 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; diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index a101f043212..7d15893af24 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -63,8 +63,6 @@ println!("path exists: {}", path.exists()); */ -#![deny(deprecated_owned_vector)] - use collections::Collection; use c_str::CString; use clone::Clone; @@ -527,13 +525,6 @@ impl<'a> BytesContainer for &'a [u8] { } } -impl BytesContainer for ~[u8] { - #[inline] - fn container_as_bytes<'a>(&'a self) -> &'a [u8] { - self.as_slice() - } -} - impl BytesContainer for Vec { #[inline] fn container_as_bytes<'a>(&'a self) -> &'a [u8] { diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 171535edbeb..494428de3a5 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -22,7 +22,7 @@ use option::{Option, None, Some}; 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 @@ impl GenericPath for Path { } } - #[allow(deprecated_owned_vector)] fn path_relative_from(&self, base: &Path) -> Option { if self.is_absolute() != base.is_absolute() { if self.is_absolute() { diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 011dfa6eeac..e3209c5c186 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -21,7 +21,7 @@ use io::Writer; 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; diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index eb862ecf932..6fb08b6ef75 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -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; diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index 8655d1e47d5..fe5d8fc068c 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -71,7 +71,6 @@ impl Rng for ReaderRng { } #[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() { diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index 3b223b68ee6..9a1c0151e54 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -37,8 +37,8 @@ impl ToStr for T { #[cfg(test)] mod tests { + use prelude::*; use super::*; - use str::StrAllocating; #[test] fn test_simple_types() { @@ -54,11 +54,11 @@ mod tests { #[test] fn test_vectors() { - let x: ~[int] = box []; + let x: Vec = 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()); } } diff --git a/src/libsync/lib.rs b/src/libsync/lib.rs index 9f010928256..66ca10b196c 100644 --- a/src/libsync/lib.rs +++ b/src/libsync/lib.rs @@ -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] diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 9706176ca8b..e280c244929 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -30,6 +30,7 @@ pub enum ObsoleteSyntax { ObsoleteOwnedType, ObsoleteOwnedExpr, ObsoleteOwnedPattern, + ObsoleteOwnedVector, } pub trait ParserObsoleteMethods { @@ -63,6 +64,10 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { "`~` 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); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8083bf41706..4d9b112cb5c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1315,11 +1315,8 @@ impl<'a> Parser<'a> { // 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 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { // 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) => { diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 7d94e46a88a..d0101e993c4 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -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::>() - .as_slice(), - tests) -} - pub enum ColorConfig { AutoColor, AlwaysColor, diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index c6a45b651ef..aa0e9b46fa7 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -167,7 +167,6 @@ impl Summary { impl<'a,T: FloatMath + FromPrimitive> Stats 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 @@ mod tests { #[test] fn test_boxplot_nonpositive() { - #[allow(deprecated_owned_vector)] fn t(s: &Summary, expected: String) { use std::io::MemWriter; let mut m = MemWriter::new(); diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index c13cce36c0a..63523cd3a6f 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -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; diff --git a/src/test/bench/shootout-regex-dna.rs b/src/test/bench/shootout-regex-dna.rs index 64f3e633d03..19b9d5638d0 100644 --- a/src/test/bench/shootout-regex-dna.rs +++ b/src/test/bench/shootout-regex-dna.rs @@ -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"), diff --git a/src/test/compile-fail/borrowck-use-in-index-lvalue.rs b/src/test/compile-fail/borrowck-use-in-index-lvalue.rs index 3ced9859240..3cd582ca0b8 100644 --- a/src/test/compile-fail/borrowck-use-in-index-lvalue.rs +++ b/src/test/compile-fail/borrowck-use-in-index-lvalue.rs @@ -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` } diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index b12e6799e6a..7457a1020ce 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -11,8 +11,6 @@ #![deny(unreachable_code)] #![allow(unused_variable)] #![allow(dead_code)] -#![allow(deprecated_owned_vector)] - fn fail_len(v: Vec ) -> 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 index 537f3c9f48a..00000000000 --- a/src/test/compile-fail/lint-deprecated-owned-vector.rs +++ /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 or the MIT license -// , 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 `~[]` -} diff --git a/src/test/compile-fail/lint-heap-memory.rs b/src/test/compile-fail/lint-heap-memory.rs index ae18e9bebad..26cae1aa708 100644 --- a/src/test/compile-fail/lint-heap-memory.rs +++ b/src/test/compile-fail/lint-heap-memory.rs @@ -11,7 +11,6 @@ #![feature(managed_boxes)] #![forbid(heap_memory)] #![allow(dead_code)] -#![allow(deprecated_owned_vector)] struct Foo { diff --git a/src/test/compile-fail/lint-unused-imports.rs b/src/test/compile-fail/lint-unused-imports.rs index cb05c283334..4334d2f63ea 100644 --- a/src/test/compile-fail/lint-unused-imports.rs +++ b/src/test/compile-fail/lint-unused-imports.rs @@ -11,7 +11,6 @@ #![feature(globs)] #![deny(unused_imports)] #![allow(dead_code)] -#![allow(deprecated_owned_vector)] use cal = bar::c::cc; diff --git a/src/test/compile-fail/lint-unused-mut-variables.rs b/src/test/compile-fail/lint-unused-mut-variables.rs index 671fecc4e22..d5f34669a25 100644 --- a/src/test/compile-fail/lint-unused-mut-variables.rs +++ b/src/test/compile-fail/lint-unused-mut-variables.rs @@ -13,7 +13,6 @@ #![allow(dead_assignment)] #![allow(unused_variable)] #![allow(dead_code)] -#![allow(deprecated_owned_vector)] #![deny(unused_mut)] diff --git a/src/test/compile-fail/lint-unused-unsafe.rs b/src/test/compile-fail/lint-unused-unsafe.rs index 7c459434bca..8ae3f1fdd0d 100644 --- a/src/test/compile-fail/lint-unused-unsafe.rs +++ b/src/test/compile-fail/lint-unused-unsafe.rs @@ -12,7 +12,6 @@ #![allow(dead_code)] #![deny(unused_unsafe)] -#![allow(deprecated_owned_vector)] mod foo { diff --git a/src/test/run-pass/empty-allocation-non-null.rs b/src/test/run-pass/empty-allocation-non-null.rs index a6baf21549e..15544468ae9 100644 --- a/src/test/run-pass/empty-allocation-non-null.rs +++ b/src/test/run-pass/empty-allocation-non-null.rs @@ -13,7 +13,4 @@ pub fn main() { struct Foo; assert!(Some(box Foo).is_some()); - - let xs: ~[()] = ~[]; - assert!(Some(xs).is_some()); } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index b69450024f6..7078518bebc 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -13,7 +13,6 @@ #![feature(macro_rules, managed_boxes)] #![deny(warnings)] #![allow(unused_must_use)] -#![allow(deprecated_owned_vector)] extern crate debug; diff --git a/src/test/run-pass/overloaded-autoderef.rs b/src/test/run-pass/overloaded-autoderef.rs index 782cea2979f..cd5903ad4e3 100644 --- a/src/test/run-pass/overloaded-autoderef.rs +++ b/src/test/run-pass/overloaded-autoderef.rs @@ -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)); diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 6fbb311593b..b471d13901e 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -62,8 +62,6 @@ impl TyVisitor for MyVisitor { 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 @@ impl TyVisitor for MyVisitor { 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 }