Skip to content

Commit e27cbef

Browse files
committed
Fix warnings when compiling stdlib with --test
1 parent 27a1834 commit e27cbef

File tree

26 files changed

+81
-75
lines changed

26 files changed

+81
-75
lines changed

src/libstd/dynamic_lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ mod tests {
132132
#[cfg_attr(any(windows,
133133
target_os = "android", // FIXME #10379
134134
target_env = "musl"), ignore)]
135+
#[allow(deprecated)]
135136
fn test_loading_cosine() {
136137
// The math library does not need to be loaded since it is already
137138
// statically linked in
@@ -164,6 +165,7 @@ mod tests {
164165
target_os = "bitrig",
165166
target_os = "netbsd",
166167
target_os = "openbsd"))]
168+
#[allow(deprecated)]
167169
fn test_errors_do_not_crash() {
168170
// Open /dev/null as a library to get an error, and make sure
169171
// that only causes an error, and not a crash.

src/libstd/fs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,6 @@ mod tests {
12811281
use io::{ErrorKind, SeekFrom};
12821282
use path::PathBuf;
12831283
use path::Path as Path2;
1284-
use os;
12851284
use rand::{self, StdRng, Rng};
12861285
use str;
12871286

@@ -1410,8 +1409,8 @@ mod tests {
14101409
let message = "ten-four";
14111410
let mut read_mem = [0; 4];
14121411
let set_cursor = 4 as u64;
1413-
let mut tell_pos_pre_read;
1414-
let mut tell_pos_post_read;
1412+
let tell_pos_pre_read;
1413+
let tell_pos_post_read;
14151414
let tmpdir = tmpdir();
14161415
let filename = &tmpdir.join("file_rt_io_file_test_seeking.txt");
14171416
{

src/libstd/io/buffered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ impl<W: Read + Write> Read for InternalBufWriter<W> {
791791
mod tests {
792792
use prelude::v1::*;
793793
use io::prelude::*;
794-
use io::{self, BufReader, BufWriter, Cursor, LineWriter, SeekFrom};
794+
use io::{self, BufReader, BufWriter, LineWriter, SeekFrom};
795795
use test;
796796

797797
/// A dummy reader intended at testing short-reads propagation.

src/libstd/io/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ mod test {
377377
struct TestError;
378378

379379
impl fmt::Display for TestError {
380-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
380+
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
381381
Ok(())
382382
}
383383
}

src/libstd/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,7 @@ mod tests {
19831983
b.iter(|| {
19841984
let mut lr = repeat(1).take(10000000);
19851985
let mut vec = Vec::with_capacity(1024);
1986-
super::read_to_end(&mut lr, &mut vec);
1986+
super::read_to_end(&mut lr, &mut vec)
19871987
});
19881988
}
19891989
}

src/libstd/io/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ mod tests {
199199
}
200200

201201
#[test]
202+
#[allow(deprecated)]
202203
fn tee() {
203204
let mut buf = [0; 10];
204205
{
@@ -209,6 +210,7 @@ mod tests {
209210
}
210211

211212
#[test]
213+
#[allow(deprecated)]
212214
fn broadcast() {
213215
let mut buf1 = [0; 10];
214216
let mut buf2 = [0; 10];

src/libstd/net/addr.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,7 @@ impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T {
468468
#[cfg(test)]
469469
mod tests {
470470
use prelude::v1::*;
471-
use io;
472471
use net::*;
473-
use net::Ipv6MulticastScope::*;
474472
use net::test::{tsa, sa6, sa4};
475473

476474
#[test]

src/libstd/net/ip.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ impl FromInner<c::in6_addr> for Ipv6Addr {
527527
#[cfg(test)]
528528
mod tests {
529529
use prelude::v1::*;
530-
use io;
531530
use net::*;
532531
use net::Ipv6MulticastScope::*;
533532
use net::test::{tsa, sa6, sa4};

src/libstd/net/tcp.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ mod tests {
319319
use net::test::{next_test_ip4, next_test_ip6};
320320
use sync::mpsc::channel;
321321
use sys_common::AsInner;
322-
use time::Duration;
322+
use time::{Instant, Duration};
323323
use thread;
324324

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

930930
t!(stream.set_write_timeout(None));
931931
assert_eq!(None, t!(stream.write_timeout()));
932+
drop(listener);
932933
}
933934

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

942943
let mut buf = [0; 10];
943-
let wait = Duration::span(|| {
944-
let kind = stream.read(&mut buf).err().expect("expected error").kind();
945-
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
946-
});
947-
assert!(wait > Duration::from_millis(400));
944+
let start = Instant::now();
945+
let kind = stream.read(&mut buf).err().expect("expected error").kind();
946+
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
947+
assert!(start.elapsed() > Duration::from_millis(400));
948+
drop(listener);
948949
}
949950

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

965-
let wait = Duration::span(|| {
966-
let kind = stream.read(&mut buf).err().expect("expected error").kind();
967-
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
968-
});
969-
assert!(wait > Duration::from_millis(400));
966+
let start = Instant::now();
967+
let kind = stream.read(&mut buf).err().expect("expected error").kind();
968+
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
969+
assert!(start.elapsed() > Duration::from_millis(400));
970+
drop(listener);
970971
}
971972
}

src/libstd/net/udp.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ mod tests {
169169
use net::test::{next_test_ip4, next_test_ip6};
170170
use sync::mpsc::channel;
171171
use sys_common::AsInner;
172-
use time::Duration;
172+
use time::{Instant, Duration};
173173
use thread;
174174

175175
fn each_ip(f: &mut FnMut(SocketAddr, SocketAddr)) {
@@ -370,22 +370,22 @@ mod tests {
370370
fn test_read_timeout() {
371371
let addr = next_test_ip4();
372372

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

376376
let mut buf = [0; 10];
377-
let wait = Duration::span(|| {
378-
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
379-
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
380-
});
381-
assert!(wait > Duration::from_millis(400));
377+
378+
let start = Instant::now();
379+
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
380+
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
381+
assert!(start.elapsed() > Duration::from_millis(400));
382382
}
383383

384384
#[test]
385385
fn test_read_with_timeout() {
386386
let addr = next_test_ip4();
387387

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

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

397-
let wait = Duration::span(|| {
398-
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
399-
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
400-
});
401-
assert!(wait > Duration::from_millis(400));
397+
let start = Instant::now();
398+
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
399+
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
400+
assert!(start.elapsed() > Duration::from_millis(400));
402401
}
403402
}

0 commit comments

Comments
 (0)