diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-06-06 10:27:49 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-11 15:02:17 -0700 |
| commit | 3316b1eb7c3eb520896af489dd45c4d17190d0a8 (patch) | |
| tree | c94cde854a882cad33d8ec7fe0067b43b5cb96d7 /src/libcore | |
| parent | f9260d41d6e37653bf71b08a041be0310098716a (diff) | |
| download | rust-3316b1eb7c3eb520896af489dd45c4d17190d0a8.tar.gz rust-3316b1eb7c3eb520896af489dd45c4d17190d0a8.zip | |
rustc: Remove ~[T] from the language
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.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/clone.rs | 2 | ||||
| -rw-r--r-- | src/libcore/failure.rs | 2 | ||||
| -rw-r--r-- | src/libcore/fmt/mod.rs | 6 | ||||
| -rw-r--r-- | src/libcore/intrinsics.rs | 4 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 14 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 5 | ||||
| -rw-r--r-- | src/libcore/option.rs | 4 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 45 | ||||
| -rw-r--r-- | src/libcore/raw.rs | 11 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 49 |
10 files changed, 42 insertions, 100 deletions
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<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(); 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<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("()") 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<A> { /// } /// 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<int> = 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<RefCell<int>>) -> R { + fn r(i: Rc<RefCell<int>>) -> 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<T> 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<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 @@ pub trait Repr<T> { 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 { 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<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 @@ pub mod traits { 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 @@ impl<'a, T> Collection for &'a [T] { } } -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 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutChunks<'a, T> { impl<'a, T> Default for &'a [T] { fn default() -> &'a [T] { &[] } } - -impl<T> Default for ~[T] { - fn default() -> ~[T] { ~[] } -} |
