diff options
| author | NODA, Kai <nodakai@gmail.com> | 2014-10-05 18:11:17 +0800 |
|---|---|---|
| committer | NODA, Kai <nodakai@gmail.com> | 2014-10-13 14:16:22 +0800 |
| commit | f27ad3d3e99ce679f782607971a9f6f18befa503 (patch) | |
| tree | 388f850cfb1e4d06077dfa6cd28a0e79eda28c07 /src/libstd/io | |
| parent | a6e0c76ef4b8ed87698dc9fe51e952039d33b913 (diff) | |
| download | rust-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/libstd/io')
| -rw-r--r-- | src/libstd/io/buffered.rs | 6 | ||||
| -rw-r--r-- | src/libstd/io/fs.rs | 10 | ||||
| -rw-r--r-- | src/libstd/io/mem.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 42 | ||||
| -rw-r--r-- | src/libstd/io/net/addrinfo.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/net/tcp.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/pipe.rs | 1 | ||||
| -rw-r--r-- | src/libstd/io/process.rs | 8 | ||||
| -rw-r--r-- | src/libstd/io/stdio.rs | 5 | ||||
| -rw-r--r-- | src/libstd/io/timer.rs | 1 |
10 files changed, 38 insertions, 41 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 754b440b0de..8ab0d3a5504 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -400,7 +400,7 @@ mod test { impl Reader for ShortReader { fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> { - match self.lengths.shift() { + match self.lengths.remove(0) { Some(i) => Ok(i), None => Err(io::standard_error(io::EndOfFile)) } @@ -551,7 +551,7 @@ mod test { #[test] fn test_read_line() { - let in_buf = MemReader::new(Vec::from_slice(b"a\nb\nc")); + let in_buf = MemReader::new(b"a\nb\nc".to_vec()); let mut reader = BufferedReader::with_capacity(2, in_buf); assert_eq!(reader.read_line(), Ok("a\n".to_string())); assert_eq!(reader.read_line(), Ok("b\n".to_string())); @@ -561,7 +561,7 @@ mod test { #[test] fn test_lines() { - let in_buf = MemReader::new(Vec::from_slice(b"a\nb\nc")); + let in_buf = MemReader::new(b"a\nb\nc".to_vec()); let mut reader = BufferedReader::with_capacity(2, in_buf); let mut it = reader.lines(); assert_eq!(it.next(), Some(Ok("a\n".to_string()))); diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 82494d41aa3..e8fed67fffe 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -1415,7 +1415,7 @@ mod test { check!(copy(&input, &output)); assert_eq!(check!(File::open(&output).read_to_end()), - (Vec::from_slice(b"foo"))); + b"foo".to_vec()); } #[test] @@ -1459,7 +1459,7 @@ mod test { } assert_eq!(check!(stat(&out)).size, check!(stat(&input)).size); assert_eq!(check!(File::open(&out).read_to_end()), - (Vec::from_slice(b"foobar"))); + b"foobar".to_vec()); } #[cfg(not(windows))] // apparently windows doesn't like symlinks @@ -1497,7 +1497,7 @@ mod test { assert_eq!(check!(stat(&out)).size, check!(stat(&input)).size); assert_eq!(check!(stat(&out)).size, check!(input.stat()).size); assert_eq!(check!(File::open(&out).read_to_end()), - (Vec::from_slice(b"foobar"))); + b"foobar".to_vec()); // can't link to yourself match link(&input, &input) { @@ -1560,7 +1560,7 @@ mod test { check!(file.fsync()); assert_eq!(check!(file.stat()).size, 10); assert_eq!(check!(File::open(&path).read_to_end()), - (Vec::from_slice(b"foobar\0\0\0\0"))); + b"foobar\0\0\0\0".to_vec()); // Truncate to a smaller length, don't seek, and then write something. // Ensure that the intermediate zeroes are all filled in (we're seeked @@ -1571,7 +1571,7 @@ mod test { check!(file.fsync()); assert_eq!(check!(file.stat()).size, 9); assert_eq!(check!(File::open(&path).read_to_end()), - (Vec::from_slice(b"fo\0\0\0\0wut"))); + b"fo\0\0\0\0wut".to_vec()); drop(file); } diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 0f8e0ed52f8..f86ae05d623 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -617,7 +617,7 @@ mod test { #[bench] fn bench_mem_reader(b: &mut Bencher) { b.iter(|| { - let buf = Vec::from_slice([5 as u8, ..100]); + let buf = [5 as u8, ..100].to_vec(); { let mut rdr = MemReader::new(buf); for _i in range(0u, 10) { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index d18b3cdf2e7..8592d48974a 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1949,62 +1949,62 @@ mod tests { return Ok(0); } }; - behavior.shift(); + behavior.remove(0); } } } #[test] fn test_read_at_least() { - let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")), - Vec::from_slice([GoodBehavior(uint::MAX)])); + let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), + vec![GoodBehavior(uint::MAX)]); let mut buf = [0u8, ..5]; assert!(r.read_at_least(1, buf).unwrap() >= 1); assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least assert!(r.read_at_least(0, buf).is_ok()); - let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")), - Vec::from_slice([BadBehavior(50), GoodBehavior(uint::MAX)])); + let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), + vec![BadBehavior(50), GoodBehavior(uint::MAX)]); assert!(r.read_at_least(1, buf).unwrap() >= 1); - let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")), - Vec::from_slice([BadBehavior(1), GoodBehavior(1), - BadBehavior(50), GoodBehavior(uint::MAX)])); + let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), + vec![BadBehavior(1), GoodBehavior(1), + BadBehavior(50), GoodBehavior(uint::MAX)]); assert!(r.read_at_least(1, buf).unwrap() >= 1); assert!(r.read_at_least(1, buf).unwrap() >= 1); - let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")), - Vec::from_slice([BadBehavior(uint::MAX)])); + let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), + vec![BadBehavior(uint::MAX)]); assert_eq!(r.read_at_least(1, buf).unwrap_err().kind, NoProgress); - let mut r = MemReader::new(Vec::from_slice(b"hello, world!")); + let mut r = MemReader::new(b"hello, world!".to_vec()); assert_eq!(r.read_at_least(5, buf).unwrap(), 5); assert_eq!(r.read_at_least(6, buf).unwrap_err().kind, InvalidInput); } #[test] fn test_push_at_least() { - let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")), - Vec::from_slice([GoodBehavior(uint::MAX)])); + let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), + vec![GoodBehavior(uint::MAX)]); let mut buf = Vec::new(); assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1); assert!(r.push_at_least(0, 5, &mut buf).is_ok()); - let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")), - Vec::from_slice([BadBehavior(50), GoodBehavior(uint::MAX)])); + let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), + vec![BadBehavior(50), GoodBehavior(uint::MAX)]); assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1); - let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")), - Vec::from_slice([BadBehavior(1), GoodBehavior(1), - BadBehavior(50), GoodBehavior(uint::MAX)])); + let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), + vec![BadBehavior(1), GoodBehavior(1), + BadBehavior(50), GoodBehavior(uint::MAX)]); assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1); assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1); - let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")), - Vec::from_slice([BadBehavior(uint::MAX)])); + let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()), + vec![BadBehavior(uint::MAX)]); assert_eq!(r.push_at_least(1, 5, &mut buf).unwrap_err().kind, NoProgress); - let mut r = MemReader::new(Vec::from_slice(b"hello, world!")); + let mut r = MemReader::new(b"hello, world!".to_vec()); assert_eq!(r.push_at_least(5, 1, &mut buf).unwrap_err().kind, InvalidInput); } diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index 27241f9bfa5..9d85701eb29 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -126,9 +126,7 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>) #[cfg(all(test, not(target_os = "android")))] mod test { use super::*; - use io::net::tcp::*; use io::net::ip::*; - use io::net::udp::*; #[test] fn dns_smoke_test() { diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index e2a850c58e4..d6528ce977e 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -521,10 +521,8 @@ impl Clone for TcpAcceptor { #[cfg(test)] #[allow(experimental)] mod test { - use super::*; use io::net::tcp::*; use io::net::ip::*; - use io::net::udp::*; use io::*; use io::test::*; use prelude::*; diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs index d7d478bd458..9362a48a6f0 100644 --- a/src/libstd/io/pipe.rs +++ b/src/libstd/io/pipe.rs @@ -118,7 +118,6 @@ impl Writer for PipeStream { #[cfg(test)] mod test { - use super::*; use prelude::*; #[test] diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 5de4bc10e1a..88f8434b957 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -727,7 +727,7 @@ mod tests { assert!(p.is_ok()); let mut p = p.unwrap(); assert!(p.stdout.is_some()); - let ret = read_all(p.stdout.get_mut_ref() as &mut Reader); + let ret = read_all(p.stdout.as_mut().unwrap() as &mut Reader); assert!(p.wait().unwrap().success()); return ret; } @@ -758,9 +758,9 @@ mod tests { .stdin(CreatePipe(true, false)) .stdout(CreatePipe(false, true)) .spawn().unwrap(); - p.stdin.get_mut_ref().write("foobar".as_bytes()).unwrap(); + p.stdin.as_mut().unwrap().write("foobar".as_bytes()).unwrap(); drop(p.stdin.take()); - let out = read_all(p.stdout.get_mut_ref() as &mut Reader); + let out = read_all(p.stdout.as_mut().unwrap() as &mut Reader); assert!(p.wait().unwrap().success()); assert_eq!(out, "foobar\n".to_string()); } @@ -1019,7 +1019,7 @@ mod tests { fn test_add_to_env() { let prog = env_cmd().env("RUN_TEST_NEW_ENV", "123").spawn().unwrap(); let result = prog.wait_with_output().unwrap(); - let output = str::from_utf8_lossy(result.output.as_slice()).into_string(); + let output = String::from_utf8_lossy(result.output.as_slice()).into_string(); assert!(output.as_slice().contains("RUN_TEST_NEW_ENV=123"), "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output); diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index b174f19f198..93037f765d6 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -385,6 +385,7 @@ mod tests { use super::*; use prelude::*; + #[test] fn smoke() { // Just make sure we can acquire handles stdin(); @@ -392,6 +393,7 @@ mod tests { stderr(); } + #[test] fn capture_stdout() { use io::{ChanReader, ChanWriter}; @@ -404,9 +406,10 @@ mod tests { assert_eq!(r.read_to_string().unwrap(), "hello!\n".to_string()); } + #[test] fn capture_stderr() { use realstd::comm::channel; - use realstd::io::{Writer, ChanReader, ChanWriter, Reader}; + use realstd::io::{ChanReader, ChanWriter, Reader}; let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index e7df0285540..a657989fe12 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -235,7 +235,6 @@ mod test { use super::*; use time::Duration; use task::spawn; - use io::*; use prelude::*; #[test] |
