Skip to content

Commit 257212a

Browse files
committed
Remove warnings from tests.
1 parent 2ba46f8 commit 257212a

File tree

20 files changed

+64
-62
lines changed

20 files changed

+64
-62
lines changed

src/libcoretest/iter.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ fn test_inspect() {
452452
}
453453

454454
#[test]
455+
#[allow(deprecated)]
455456
fn test_unfoldr() {
456457
fn count(st: &mut usize) -> Option<usize> {
457458
if *st < 10 {
@@ -782,6 +783,7 @@ fn test_rposition_panic() {
782783

783784

784785
#[cfg(test)]
786+
#[allow(deprecated)]
785787
fn check_randacc_iter<A, T>(a: T, len: usize) where
786788
A: PartialEq,
787789
T: Clone + RandomAccessIterator + Iterator<Item=A>,
@@ -821,6 +823,7 @@ fn test_double_ended_flat_map() {
821823
}
822824

823825
#[test]
826+
#[allow(deprecated)]
824827
fn test_random_access_chain() {
825828
let xs = [1, 2, 3, 4, 5];
826829
let ys = [7, 9, 11];
@@ -884,6 +887,7 @@ fn test_random_access_skip() {
884887
}
885888

886889
#[test]
890+
#[allow(deprecated)]
887891
fn test_random_access_inspect() {
888892
let xs = [1, 2, 3, 4, 5];
889893

@@ -897,6 +901,7 @@ fn test_random_access_inspect() {
897901
}
898902

899903
#[test]
904+
#[allow(deprecated)]
900905
fn test_random_access_map() {
901906
let xs = [1, 2, 3, 4, 5];
902907

@@ -985,12 +990,19 @@ fn test_range_step() {
985990
}
986991

987992
#[test]
988-
fn test_reverse() {
993+
#[allow(deprecated)]
994+
fn test_reverse_in_place() {
989995
let mut ys = [1, 2, 3, 4, 5];
990996
ys.iter_mut().reverse_in_place();
991997
assert!(ys == [5, 4, 3, 2, 1]);
992998
}
993999

1000+
#[test]
1001+
fn test_reverse() {
1002+
let ys = [1, 2, 3, 4, 5].iter().cloned().rev().collect::<Vec<_>>();
1003+
assert_eq!(&ys, &[5, 4, 3, 2, 1]);
1004+
}
1005+
9941006
#[test]
9951007
fn test_peekable_is_empty() {
9961008
let a = [1];
@@ -1031,6 +1043,7 @@ fn test_min_max_result() {
10311043
}
10321044

10331045
#[test]
1046+
#[allow(deprecated)]
10341047
fn test_iterate() {
10351048
let mut it = iterate(1, |x| x * 2);
10361049
assert_eq!(it.next(), Some(1));

src/libstd/fs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,6 @@ mod tests {
13111311
use io::{ErrorKind, SeekFrom};
13121312
use path::PathBuf;
13131313
use path::Path as Path2;
1314-
use os;
13151314
use rand::{self, StdRng, Rng};
13161315
use str;
13171316

src/libstd/io/buffered.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ mod tests {
741741
// This is just here to make sure that we don't infinite loop in the
742742
// newtype struct autoderef weirdness
743743
#[test]
744+
#[allow(deprecated)]
744745
fn test_buffered_stream() {
745746
struct S;
746747

@@ -892,6 +893,7 @@ mod tests {
892893
}
893894

894895
#[bench]
896+
#[allow(deprecated)]
895897
fn bench_buffered_stream(b: &mut test::Bencher) {
896898
let mut buf = Cursor::new(Vec::new());
897899
b.iter(|| {

src/libstd/io/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ mod test {
309309
struct TestError;
310310

311311
impl fmt::Display for TestError {
312-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
312+
fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result {
313313
Ok(())
314314
}
315315
}

src/libstd/net/addr.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,7 @@ impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T {
458458
#[cfg(test)]
459459
mod tests {
460460
use prelude::v1::*;
461-
use io;
462461
use net::*;
463-
use net::Ipv6MulticastScope::*;
464462
use net::test::{tsa, sa6, sa4};
465463

466464
#[test]

src/libstd/net/ip.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ impl FromInner<libc::in6_addr> for Ipv6Addr {
514514
#[cfg(test)]
515515
mod tests {
516516
use prelude::v1::*;
517-
use io;
518517
use net::*;
519518
use net::Ipv6MulticastScope::*;
520519
use net::test::{tsa, sa6, sa4};

src/libstd/net/tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ mod tests {
908908
#[test]
909909
fn timeouts() {
910910
let addr = next_test_ip4();
911-
let listener = t!(TcpListener::bind(&addr));
911+
let _listener = t!(TcpListener::bind(&addr));
912912

913913
let stream = t!(TcpStream::connect(&("localhost", addr.port())));
914914
let dur = Duration::new(15410, 0);
@@ -933,7 +933,7 @@ mod tests {
933933
#[test]
934934
fn test_read_timeout() {
935935
let addr = next_test_ip4();
936-
let listener = t!(TcpListener::bind(&addr));
936+
let _listener = t!(TcpListener::bind(&addr));
937937

938938
let mut stream = t!(TcpStream::connect(&("localhost", addr.port())));
939939
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));

src/libstd/net/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ mod tests {
391391
fn test_read_timeout() {
392392
let addr = next_test_ip4();
393393

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

397397
let mut buf = [0; 10];
@@ -407,7 +407,7 @@ mod tests {
407407
fn test_read_with_timeout() {
408408
let addr = next_test_ip4();
409409

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

413413
t!(stream.send_to(b"hello world", &addr));

src/libstd/num/f32.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
#![allow(unsigned_negation)]
1616
#![doc(primitive = "f32")]
1717

18-
use prelude::v1::*;
19-
20-
use core::num;
21-
use intrinsics;
22-
use libc::c_int;
23-
use num::{FpCategory, ParseFloatError};
18+
#[cfg(not(test))] use prelude::v1::*;
19+
#[cfg(not(test))] use core::num;
20+
#[cfg(not(test))] use intrinsics;
21+
#[cfg(not(test))] use libc::c_int;
22+
#[cfg(not(test))] use num::{FpCategory, ParseFloatError};
2423

2524
pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
2625
pub use core::f32::{MIN_EXP, MAX_EXP, MIN_10_EXP};
@@ -1690,6 +1689,7 @@ mod tests {
16901689
}
16911690

16921691
#[test]
1692+
#[allow(deprecated)]
16931693
fn test_real_consts() {
16941694
use super::consts;
16951695

src/libstd/num/f64.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
#![allow(missing_docs)]
1515
#![doc(primitive = "f64")]
1616

17-
use prelude::v1::*;
18-
19-
use core::num;
20-
use intrinsics;
21-
use libc::c_int;
22-
use num::{FpCategory, ParseFloatError};
17+
#[cfg(not(test))] use prelude::v1::*;
18+
#[cfg(not(test))] use core::num;
19+
#[cfg(not(test))] use intrinsics;
20+
#[cfg(not(test))] use libc::c_int;
21+
#[cfg(not(test))] use num::{FpCategory, ParseFloatError};
2322

2423
pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
2524
pub use core::f64::{MIN_EXP, MAX_EXP, MIN_10_EXP};
@@ -1646,6 +1645,7 @@ mod tests {
16461645
}
16471646

16481647
#[test]
1648+
#[allow(deprecated)]
16491649
fn test_real_consts() {
16501650
use super::consts;
16511651
let pi: f64 = consts::PI;

src/libstd/num/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ pub fn test_num<T>(ten: T, two: T) where
4545
mod tests {
4646
use core::prelude::*;
4747
use super::*;
48-
use i8;
49-
use i16;
50-
use i32;
51-
use i64;
52-
use isize;
5348
use u8;
5449
use u16;
5550
use u32;

src/libstd/os/raw.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ mod tests {
8383
}
8484

8585
#[cfg(unix)]
86+
#[test]
8687
fn unix() {
8788
{
8889
use os::unix::raw;

src/libstd/rand/os.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ mod imp {
346346

347347
#[cfg(test)]
348348
mod tests {
349-
use prelude::v1::*;
350-
351349
use sync::mpsc::channel;
352350
use rand::Rng;
353351
use super::OsRng;

src/libstd/rand/reader.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ impl<R: Read> Rng for ReaderRng<R> {
6464

6565
#[cfg(test)]
6666
mod tests {
67-
use prelude::v1::*;
68-
6967
use super::ReaderRng;
7068
use rand::Rng;
7169

src/libstd/rt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
use prelude::v1::*;
2525
use sys;
26-
use usize;
2726

2827
// Reexport some of our utilities which are expected by other crates.
2928
pub use self::util::{min_stack, running_on_valgrind};
@@ -51,15 +50,16 @@ mod libunwind;
5150
/// of exiting cleanly.
5251
pub const DEFAULT_ERROR_CODE: isize = 101;
5352

54-
#[cfg(any(windows, android))]
53+
#[cfg(all(any(windows, android), not(test)))]
5554
const OS_DEFAULT_STACK_ESTIMATE: usize = 1 << 20;
56-
#[cfg(all(unix, not(android)))]
55+
#[cfg(all(unix, not(android), not(test)))]
5756
const OS_DEFAULT_STACK_ESTIMATE: usize = 2 * (1 << 20);
5857

5958
#[cfg(not(test))]
6059
#[lang = "start"]
6160
fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
6261
use prelude::v1::*;
62+
use usize;
6363

6464
use mem;
6565
use env;

src/libstd/sys/common/remutex.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ mod tests {
158158
use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
159159
use cell::RefCell;
160160
use sync::Arc;
161-
use boxed;
162161
use thread;
163162

164163
#[test]
@@ -180,32 +179,32 @@ mod tests {
180179

181180
#[test]
182181
fn is_mutex() {
183-
let m = ReentrantMutex::new(RefCell::new(0));
182+
let m = Arc::new(ReentrantMutex::new(RefCell::new(0)));
184183
let lock = m.lock().unwrap();
185-
let handle = thread::scoped(|| {
186-
let lock = m.lock().unwrap();
184+
let mc = m.clone();
185+
let handle = thread::spawn(move || {
186+
let lock = mc.lock().unwrap();
187187
assert_eq!(*lock.borrow(), 4950);
188188
});
189189
for i in 0..100 {
190190
let lock = m.lock().unwrap();
191191
*lock.borrow_mut() += i;
192192
}
193193
drop(lock);
194-
drop(handle);
194+
handle.join().unwrap();
195195
}
196196

197197
#[test]
198198
fn trylock_works() {
199-
let m = ReentrantMutex::new(());
200-
let lock = m.try_lock().unwrap();
201-
let lock2 = m.try_lock().unwrap();
202-
{
203-
thread::scoped(|| {
204-
let lock = m.try_lock();
205-
assert!(lock.is_err());
206-
});
207-
}
208-
let lock3 = m.try_lock().unwrap();
199+
let m = Arc::new(ReentrantMutex::new(()));
200+
let _lock = m.try_lock().unwrap();
201+
let _lock2 = m.try_lock().unwrap();
202+
let mc = m.clone();
203+
thread::spawn(move || {
204+
let lock = mc.try_lock();
205+
assert!(lock.is_err());
206+
}).join().unwrap();
207+
let _lock3 = m.try_lock().unwrap();
209208
}
210209

211210
pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell<u32>>);
@@ -224,9 +223,8 @@ mod tests {
224223
*lock.borrow_mut() = 1;
225224
let lock2 = mc.lock().unwrap();
226225
*lock.borrow_mut() = 2;
227-
let answer = Answer(lock2);
226+
let _answer = Answer(lock2);
228227
panic!("What the answer to my lifetimes dilemma is?");
229-
drop(answer);
230228
}).join();
231229
assert!(result.is_err());
232230
let r = m.lock().err().unwrap().into_inner();

src/libstd/sys/common/stack.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ pub unsafe fn record_sp_limit(limit: usize) {
216216
/// As with the setter, this function does not have a __morestack header and can
217217
/// therefore be called in a "we're out of stack" situation.
218218
#[inline(always)]
219+
#[cfg(not(test))]
219220
pub unsafe fn get_sp_limit() -> usize {
220221
return target_get_sp_limit();
221222

src/libstd/sys/unix/process.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,7 @@ mod tests {
446446
use mem;
447447
use ptr;
448448
use libc;
449-
use slice;
450-
use sys::{self, c, cvt, pipe};
449+
use sys::{self, c, cvt};
451450

452451
#[cfg(not(target_os = "android"))]
453452
extern {

0 commit comments

Comments
 (0)