Skip to content

Fix warnings when compiling stdlib with --test #30458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libstd/dynamic_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ mod tests {
#[cfg_attr(any(windows,
target_os = "android", // FIXME #10379
target_env = "musl"), ignore)]
#[allow(deprecated)]
fn test_loading_cosine() {
// The math library does not need to be loaded since it is already
// statically linked in
Expand Down Expand Up @@ -164,6 +165,7 @@ mod tests {
target_os = "bitrig",
target_os = "netbsd",
target_os = "openbsd"))]
#[allow(deprecated)]
fn test_errors_do_not_crash() {
// Open /dev/null as a library to get an error, and make sure
// that only causes an error, and not a crash.
Expand Down
5 changes: 2 additions & 3 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,6 @@ mod tests {
use io::{ErrorKind, SeekFrom};
use path::PathBuf;
use path::Path as Path2;
use os;
use rand::{self, StdRng, Rng};
use str;

Expand Down Expand Up @@ -1410,8 +1409,8 @@ mod tests {
let message = "ten-four";
let mut read_mem = [0; 4];
let set_cursor = 4 as u64;
let mut tell_pos_pre_read;
let mut tell_pos_post_read;
let tell_pos_pre_read;
let tell_pos_post_read;
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_rt_io_file_test_seeking.txt");
{
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ impl<W: Read + Write> Read for InternalBufWriter<W> {
mod tests {
use prelude::v1::*;
use io::prelude::*;
use io::{self, BufReader, BufWriter, Cursor, LineWriter, SeekFrom};
use io::{self, BufReader, BufWriter, LineWriter, SeekFrom};
use test;

/// A dummy reader intended at testing short-reads propagation.
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ mod test {
struct TestError;

impl fmt::Display for TestError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ mod tests {
b.iter(|| {
let mut lr = repeat(1).take(10000000);
let mut vec = Vec::with_capacity(1024);
super::read_to_end(&mut lr, &mut vec);
super::read_to_end(&mut lr, &mut vec)
});
}
}
2 changes: 2 additions & 0 deletions src/libstd/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn tee() {
let mut buf = [0; 10];
{
Expand All @@ -209,6 +210,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn broadcast() {
let mut buf1 = [0; 10];
let mut buf2 = [0; 10];
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,7 @@ impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T {
#[cfg(test)]
mod tests {
use prelude::v1::*;
use io;
use net::*;
use net::Ipv6MulticastScope::*;
use net::test::{tsa, sa6, sa4};

#[test]
Expand Down
1 change: 0 additions & 1 deletion src/libstd/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ impl FromInner<c::in6_addr> for Ipv6Addr {
#[cfg(test)]
mod tests {
use prelude::v1::*;
use io;
use net::*;
use net::Ipv6MulticastScope::*;
use net::test::{tsa, sa6, sa4};
Expand Down
23 changes: 12 additions & 11 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ mod tests {
use net::test::{next_test_ip4, next_test_ip6};
use sync::mpsc::channel;
use sys_common::AsInner;
use time::Duration;
use time::{Instant, Duration};
use thread;

fn each_ip(f: &mut FnMut(SocketAddr)) {
Expand Down Expand Up @@ -929,6 +929,7 @@ mod tests {

t!(stream.set_write_timeout(None));
assert_eq!(None, t!(stream.write_timeout()));
drop(listener);
}

#[test]
Expand All @@ -940,11 +941,11 @@ mod tests {
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));

let mut buf = [0; 10];
let wait = Duration::span(|| {
let kind = stream.read(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
});
assert!(wait > Duration::from_millis(400));
let start = Instant::now();
let kind = stream.read(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
assert!(start.elapsed() > Duration::from_millis(400));
drop(listener);
}

#[test]
Expand All @@ -962,10 +963,10 @@ mod tests {
t!(stream.read(&mut buf));
assert_eq!(b"hello world", &buf[..]);

let wait = Duration::span(|| {
let kind = stream.read(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
});
assert!(wait > Duration::from_millis(400));
let start = Instant::now();
let kind = stream.read(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
assert!(start.elapsed() > Duration::from_millis(400));
drop(listener);
}
}
25 changes: 12 additions & 13 deletions src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ mod tests {
use net::test::{next_test_ip4, next_test_ip6};
use sync::mpsc::channel;
use sys_common::AsInner;
use time::Duration;
use time::{Instant, Duration};
use thread;

fn each_ip(f: &mut FnMut(SocketAddr, SocketAddr)) {
Expand Down Expand Up @@ -370,22 +370,22 @@ mod tests {
fn test_read_timeout() {
let addr = next_test_ip4();

let mut stream = t!(UdpSocket::bind(&addr));
let stream = t!(UdpSocket::bind(&addr));
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));

let mut buf = [0; 10];
let wait = Duration::span(|| {
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
});
assert!(wait > Duration::from_millis(400));

let start = Instant::now();
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
assert!(start.elapsed() > Duration::from_millis(400));
}

#[test]
fn test_read_with_timeout() {
let addr = next_test_ip4();

let mut stream = t!(UdpSocket::bind(&addr));
let stream = t!(UdpSocket::bind(&addr));
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));

t!(stream.send_to(b"hello world", &addr));
Expand All @@ -394,10 +394,9 @@ mod tests {
t!(stream.recv_from(&mut buf));
assert_eq!(b"hello world", &buf[..]);

let wait = Duration::span(|| {
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
});
assert!(wait > Duration::from_millis(400));
let start = Instant::now();
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
assert!(start.elapsed() > Duration::from_millis(400));
}
}
5 changes: 5 additions & 0 deletions src/libstd/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
#![stable(feature = "rust1", since = "1.0.0")]
#![allow(missing_docs)]

#[cfg(not(test))]
use core::num;
#[cfg(not(test))]
use intrinsics;
#[cfg(not(test))]
use libc::c_int;
#[cfg(not(test))]
use num::FpCategory;


#[stable(feature = "rust1", since = "1.0.0")]
pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
#![stable(feature = "rust1", since = "1.0.0")]
#![allow(missing_docs)]

#[cfg(not(test))]
use core::num;
#[cfg(not(test))]
use intrinsics;
#[cfg(not(test))]
use libc::c_int;
#[cfg(not(test))]
use num::FpCategory;

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
5 changes: 0 additions & 5 deletions src/libstd/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ pub fn test_num<T>(ten: T, two: T) where
#[cfg(test)]
mod tests {
use super::*;
use i8;
use i16;
use i32;
use i64;
use isize;
use u8;
use u16;
use u32;
Expand Down
4 changes: 3 additions & 1 deletion src/libstd/os/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ mod tests {
c_longlong c_ulonglong c_float c_double);
}

#[cfg(unix)]
#[cfg(all(unix, not(target_os = "android")))]
#[test]
fn unix() {
{
use os::unix::raw;
Expand All @@ -101,6 +102,7 @@ mod tests {
}

#[cfg(windows)]
#[test]
fn windows() {
use os::windows::raw;
}
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/rand/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,6 @@ mod imp {

#[cfg(test)]
mod tests {
use prelude::v1::*;

use sync::mpsc::channel;
use rand::Rng;
use super::OsRng;
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/rand/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ impl<R: Read> Rng for ReaderRng<R> {

#[cfg(test)]
mod tests {
use prelude::v1::*;

use super::ReaderRng;
use rand::Rng;

Expand Down
16 changes: 9 additions & 7 deletions src/libstd/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@
issue = "0")]
#![doc(hidden)]

use borrow::ToOwned;
use mem;
use panic;
use sys;
use sys_common::thread_info::{self, NewThread};
use sys_common;
use thread::Thread;


// Reexport some of our utilities which are expected by other crates.
pub use sys_common::unwind::{begin_unwind, begin_unwind_fmt};
Expand All @@ -41,6 +35,14 @@ pub use sys_common::unwind::imp::eh_frame_registry::*;
#[cfg(not(test))]
#[lang = "start"]
fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
use borrow::ToOwned;
use mem;
use panic;
use sys;
use sys_common;
use sys_common::thread_info::{self, NewThread};
use thread::Thread;

sys::init();

let failed = unsafe {
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sync/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,15 @@ mod tests {
static M: StaticMutex = StaticMutex::new();

let g = M.lock().unwrap();
let (g, _no_timeout) = C.wait_timeout_ms(g, 1).unwrap();
let (g, _no_timeout) = C.wait_timeout(g, Duration::from_millis(1)).unwrap();
// spurious wakeups mean this isn't necessarily true
// assert!(!no_timeout);
let _t = thread::spawn(move || {
let _g = M.lock().unwrap();
C.notify_one();
});
let (g, no_timeout) = C.wait_timeout_ms(g, u32::MAX).unwrap();
assert!(no_timeout);
let (g, timeout_res) = C.wait_timeout(g, Duration::from_millis(u32::MAX as u64)).unwrap();
assert!(!timeout_res.timed_out());
drop(g);
unsafe { C.destroy(); M.destroy(); }
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/common/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ mod tests {
b.iter(|| {
let mut lr = repeat(1).take(10000000);
let mut vec = Vec::with_capacity(1024);
unsafe { read_to_end_uninitialized(&mut lr, &mut vec) };
unsafe { read_to_end_uninitialized(&mut lr, &mut vec) }
});
}
}
10 changes: 4 additions & 6 deletions src/libstd/sys/common/remutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ mod tests {
use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
use cell::RefCell;
use sync::Arc;
use boxed;
use thread;

#[test]
Expand Down Expand Up @@ -208,13 +207,13 @@ mod tests {
fn trylock_works() {
let m = Arc::new(ReentrantMutex::new(()));
let m2 = m.clone();
let lock = m.try_lock().unwrap();
let lock2 = m.try_lock().unwrap();
let _lock = m.try_lock().unwrap();
let _lock2 = m.try_lock().unwrap();
thread::spawn(move || {
let lock = m2.try_lock();
assert!(lock.is_err());
}).join().unwrap();
let lock3 = m.try_lock().unwrap();
let _lock3 = m.try_lock().unwrap();
}

pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell<u32>>);
Expand All @@ -233,9 +232,8 @@ mod tests {
*lock.borrow_mut() = 1;
let lock2 = mc.lock().unwrap();
*lock.borrow_mut() = 2;
let answer = Answer(lock2);
let _answer = Answer(lock2);
panic!("What the answer to my lifetimes dilemma is?");
drop(answer);
}).join();
assert!(result.is_err());
let r = m.lock().err().unwrap().into_inner();
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/common/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ mod tests {
#[test]
fn wtf8buf_show_str() {
let text = "a\té 💩\r";
let mut string = Wtf8Buf::from_str(text);
let string = Wtf8Buf::from_str(text);
assert_eq!(format!("{:?}", text), format!("{:?}", string));
}

Expand Down
Loading