about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorNODA, Kai <nodakai@gmail.com>2014-10-05 18:11:17 +0800
committerNODA, Kai <nodakai@gmail.com>2014-10-13 14:16:22 +0800
commitf27ad3d3e99ce679f782607971a9f6f18befa503 (patch)
tree388f850cfb1e4d06077dfa6cd28a0e79eda28c07 /src/libcollections
parenta6e0c76ef4b8ed87698dc9fe51e952039d33b913 (diff)
downloadrust-f27ad3d3e99ce679f782607971a9f6f18befa503.tar.gz
rust-f27ad3d3e99ce679f782607971a9f6f18befa503.zip
Clean up rustc warnings.
compiletest: compact "linux" "macos" etc.as "unix".
liballoc: remove a superfluous "use".
libcollections: remove invocations of deprecated methods in favor of
    their suggested replacements and use "_" for a loop counter.
libcoretest: remove invocations of deprecated methods;  also add
    "allow(deprecated)" for testing a deprecated method itself.
libglob: use "cfg_attr".
libgraphviz: add a test for one of data constructors.
libgreen: remove a superfluous "use".
libnum: "allow(type_overflow)" for type cast into u8 in a test code.
librustc: names of static variables should be in upper case.
libserialize: v[i] instead of get().
libstd/ascii: to_lowercase() instead of to_lower().
libstd/bitflags: modify AnotherSetOfFlags to use i8 as its backend.
    It will serve better for testing various aspects of bitflags!.
libstd/collections: "allow(deprecated)" for testing a deprecated
    method itself.
libstd/io: remove invocations of deprecated methods and superfluous "use".
    Also add #[test] where it was missing.
libstd/num: introduce a helper function to effectively remove
    invocations of a deprecated method.
libstd/path and rand: remove invocations of deprecated methods and
    superfluous "use".
libstd/task and libsync/comm: "allow(deprecated)" for testing
    a deprecated method itself.
libsync/deque: remove superfluous "unsafe".
libsync/mutex and once: names of static variables should be in upper case.
libterm: introduce a helper function to effectively remove
    invocations of a deprecated method.

We still see a few warnings about using obsoleted native::task::spawn()
in the test modules for libsync.  I'm not sure how I should replace them
with std::task::TaksBuilder and native::task::NativeTaskBuilder
(dependency to libstd?)

Signed-off-by: NODA, Kai <nodakai@gmail.com>
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/bitv.rs2
-rw-r--r--src/libcollections/dlist.rs8
-rw-r--r--src/libcollections/ringbuf.rs12
-rw-r--r--src/libcollections/str.rs3
-rw-r--r--src/libcollections/string.rs25
-rw-r--r--src/libcollections/vec.rs44
6 files changed, 49 insertions, 45 deletions
diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs
index 8f9873d77d1..bfa5e237f55 100644
--- a/src/libcollections/bitv.rs
+++ b/src/libcollections/bitv.rs
@@ -2659,7 +2659,7 @@ mod tests {
         let mut r = rng();
         let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
         b.iter(|| {
-            for i in range(0u, 100) {
+            for _ in range(0u, 100) {
                 bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
             }
             &bitv
diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs
index 87e07b7b1b6..088784070e7 100644
--- a/src/libcollections/dlist.rs
+++ b/src/libcollections/dlist.rs
@@ -890,13 +890,13 @@ mod tests {
         }
 
         let v = vec![1i,2,3,4,5];
-        let u = vec![9i,8,1,2,3,4,5];
+        let mut u = vec![9i,8,1,2,3,4,5];
         let mut m = list_from(v.as_slice());
         m.prepend(list_from(u.as_slice()));
         check_links(&m);
-        let sum = u.append(v.as_slice());
-        assert_eq!(sum.len(), m.len());
-        for elt in sum.into_iter() {
+        u.extend(v.as_slice().iter().map(|&b| b));
+        assert_eq!(u.len(), m.len());
+        for elt in u.into_iter() {
             assert_eq!(m.pop_front(), Some(elt))
         }
     }
diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs
index c9c824ac9ce..4d8e67f6ac8 100644
--- a/src/libcollections/ringbuf.rs
+++ b/src/libcollections/ringbuf.rs
@@ -611,10 +611,10 @@ mod tests {
         assert_eq!(deq.len(), 3);
         deq.push_front(a.clone());
         assert_eq!(deq.len(), 4);
-        assert_eq!((*deq.get(0)).clone(), a.clone());
-        assert_eq!((*deq.get(1)).clone(), b.clone());
-        assert_eq!((*deq.get(2)).clone(), c.clone());
-        assert_eq!((*deq.get(3)).clone(), d.clone());
+        assert_eq!(deq[0].clone(), a.clone());
+        assert_eq!(deq[1].clone(), b.clone());
+        assert_eq!(deq[2].clone(), c.clone());
+        assert_eq!(deq[3].clone(), d.clone());
     }
 
     #[test]
@@ -626,7 +626,7 @@ mod tests {
         assert_eq!(deq.len(), 66);
 
         for i in range(0u, 66) {
-            assert_eq!(*deq.get(i), 65 - i);
+            assert_eq!(deq[i], 65 - i);
         }
 
         let mut deq = RingBuf::new();
@@ -635,7 +635,7 @@ mod tests {
         }
 
         for i in range(0u, 66) {
-            assert_eq!(*deq.get(i), i);
+            assert_eq!(deq[i], i);
         }
     }
 
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index f3d3506de83..f49371b8e88 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -883,6 +883,7 @@ mod tests {
     use std::slice::{AsSlice, ImmutableSlice};
     use string::String;
     use vec::Vec;
+    use slice::CloneableVector;
 
     use unicode::char::UnicodeChar;
 
@@ -1504,7 +1505,7 @@ mod tests {
     fn vec_str_conversions() {
         let s1: String = String::from_str("All mimsy were the borogoves");
 
-        let v: Vec<u8> = Vec::from_slice(s1.as_bytes());
+        let v: Vec<u8> = s1.as_bytes().to_vec();
         let s2: String = String::from_str(from_utf8(v.as_slice()).unwrap());
         let mut i: uint = 0u;
         let n1: uint = s1.len();
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index 848068f20c2..061064ff803 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -1036,6 +1036,7 @@ mod tests {
     use str::{Str, StrSlice, Owned};
     use super::{as_string, String};
     use vec::Vec;
+    use slice::CloneableVector;
 
     #[test]
     fn test_as_string() {
@@ -1051,15 +1052,15 @@ mod tests {
 
     #[test]
     fn test_from_utf8() {
-        let xs = Vec::from_slice(b"hello");
+        let xs = b"hello".to_vec();
         assert_eq!(String::from_utf8(xs), Ok(String::from_str("hello")));
 
-        let xs = Vec::from_slice("ศไทย中华Việt Nam".as_bytes());
+        let xs = "ศไทย中华Việt Nam".as_bytes().to_vec();
         assert_eq!(String::from_utf8(xs), Ok(String::from_str("ศไทย中华Việt Nam")));
 
-        let xs = Vec::from_slice(b"hello\xFF");
+        let xs = b"hello\xFF".to_vec();
         assert_eq!(String::from_utf8(xs),
-                   Err(Vec::from_slice(b"hello\xFF")));
+                   Err(b"hello\xFF".to_vec()));
     }
 
     #[test]
@@ -1211,7 +1212,8 @@ mod tests {
     fn test_push_bytes() {
         let mut s = String::from_str("ABC");
         unsafe {
-            s.push_bytes([b'D']);
+            let mv = s.as_mut_vec();
+            mv.push_all([b'D']);
         }
         assert_eq!(s.as_slice(), "ABCD");
     }
@@ -1239,17 +1241,18 @@ mod tests {
     }
 
     #[test]
-    fn test_pop_char() {
+    fn test_pop() {
         let mut data = String::from_str("ประเทศไทย中华b¢€𤭢");
-        assert_eq!(data.pop_char().unwrap(), '𤭢'); // 4 bytes
-        assert_eq!(data.pop_char().unwrap(), '€'); // 3 bytes
-        assert_eq!(data.pop_char().unwrap(), '¢'); // 2 bytes
-        assert_eq!(data.pop_char().unwrap(), 'b'); // 1 bytes
-        assert_eq!(data.pop_char().unwrap(), '华');
+        assert_eq!(data.pop().unwrap(), '𤭢'); // 4 bytes
+        assert_eq!(data.pop().unwrap(), '€'); // 3 bytes
+        assert_eq!(data.pop().unwrap(), '¢'); // 2 bytes
+        assert_eq!(data.pop().unwrap(), 'b'); // 1 bytes
+        assert_eq!(data.pop().unwrap(), '华');
         assert_eq!(data.as_slice(), "ประเทศไทย中");
     }
 
     #[test]
+    #[allow(deprecated)] // use remove(0) instead
     fn test_shift_char() {
         let mut data = String::from_str("𤭢€¢b华ประเทศไทย中");
         assert_eq!(data.shift_char().unwrap(), '𤭢'); // 4 bytes
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index f922c189fef..c714e393570 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -2266,8 +2266,8 @@ mod tests {
     }
 
     #[test]
-    fn test_mut_slice_from() {
-        let mut values = Vec::from_slice([1u8,2,3,4,5]);
+    fn test_slice_from_mut() {
+        let mut values = vec![1u8,2,3,4,5];
         {
             let slice = values.slice_from_mut(2);
             assert!(slice == [3, 4, 5]);
@@ -2280,8 +2280,8 @@ mod tests {
     }
 
     #[test]
-    fn test_mut_slice_to() {
-        let mut values = Vec::from_slice([1u8,2,3,4,5]);
+    fn test_slice_to_mut() {
+        let mut values = vec![1u8,2,3,4,5];
         {
             let slice = values.slice_to_mut(2);
             assert!(slice == [1, 2]);
@@ -2294,8 +2294,8 @@ mod tests {
     }
 
     #[test]
-    fn test_mut_split_at() {
-        let mut values = Vec::from_slice([1u8,2,3,4,5]);
+    fn test_split_at_mut() {
+        let mut values = vec![1u8,2,3,4,5];
         {
             let (left, right) = values.split_at_mut(2);
             {
@@ -2315,7 +2315,7 @@ mod tests {
             }
         }
 
-        assert!(values == Vec::from_slice([2u8, 3, 5, 6, 7]));
+        assert!(values == vec![2u8, 3, 5, 6, 7]);
     }
 
     #[test]
@@ -2355,16 +2355,16 @@ mod tests {
 
     #[test]
     fn test_grow_fn() {
-        let mut v = Vec::from_slice([0u, 1]);
+        let mut v = vec![0u, 1];
         v.grow_fn(3, |i| i);
-        assert!(v == Vec::from_slice([0u, 1, 0, 1, 2]));
+        assert!(v == vec![0u, 1, 0, 1, 2]);
     }
 
     #[test]
     fn test_retain() {
-        let mut vec = Vec::from_slice([1u, 2, 3, 4]);
+        let mut vec = vec![1u, 2, 3, 4];
         vec.retain(|x| x%2 == 0);
-        assert!(vec == Vec::from_slice([2u, 4]));
+        assert!(vec == vec![2u, 4]);
     }
 
     #[test]
@@ -2567,32 +2567,32 @@ mod tests {
 
     #[test]
     fn test_move_items() {
-        let mut vec = vec!(1i, 2, 3);
-        let mut vec2 : Vec<int> = vec!();
+        let vec = vec![1, 2, 3];
+        let mut vec2 : Vec<i32> = vec![];
         for i in vec.into_iter() {
             vec2.push(i);
         }
-        assert!(vec2 == vec!(1i, 2, 3));
+        assert!(vec2 == vec![1, 2, 3]);
     }
 
     #[test]
     fn test_move_items_reverse() {
-        let mut vec = vec!(1i, 2, 3);
-        let mut vec2 : Vec<int> = vec!();
+        let vec = vec![1, 2, 3];
+        let mut vec2 : Vec<i32> = vec![];
         for i in vec.into_iter().rev() {
             vec2.push(i);
         }
-        assert!(vec2 == vec!(3i, 2, 1));
+        assert!(vec2 == vec![3, 2, 1]);
     }
 
     #[test]
     fn test_move_items_zero_sized() {
-        let mut vec = vec!((), (), ());
-        let mut vec2 : Vec<()> = vec!();
+        let vec = vec![(), (), ()];
+        let mut vec2 : Vec<()> = vec![];
         for i in vec.into_iter() {
             vec2.push(i);
         }
-        assert!(vec2 == vec!((), (), ()));
+        assert!(vec2 == vec![(), (), ()]);
     }
 
     #[test]
@@ -2707,7 +2707,7 @@ mod tests {
         b.bytes = src_len as u64;
 
         b.iter(|| {
-            let dst = Vec::from_slice(src.clone().as_slice());
+            let dst = src.clone().as_slice().to_vec();
             assert_eq!(dst.len(), src_len);
             assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
         });
@@ -2871,7 +2871,7 @@ mod tests {
 
         b.iter(|| {
             let mut dst = dst.clone();
-            dst.push_all_move(src.clone());
+            dst.extend(src.clone().into_iter());
             assert_eq!(dst.len(), dst_len + src_len);
             assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
         });