From 366ca44cc8f79704f8781adb15e74d3c2a0e5572 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 28 Jun 2013 01:45:24 +1000 Subject: [PATCH] std: silence some test warnings. --- src/libstd/iterator.rs | 1 - src/libstd/local_data.rs | 23 ++++++++++------------- src/libstd/rt/uv/timer.rs | 4 ++-- src/libstd/str.rs | 3 ++- src/libstd/task/mod.rs | 14 ++++++-------- src/libstd/vec.rs | 4 ++-- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index ab433a9a79d..7de02a9f815 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -980,7 +980,6 @@ mod tests { use super::*; use prelude::*; - use iter; use uint; #[test] diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 82c01c998cf..33b4e3f1963 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -92,14 +92,12 @@ fn test_tls_multitask() { fn my_key(_x: @~str) { } local_data_set(my_key, @~"parent data"); do task::spawn { - unsafe { - // TLS shouldn't carry over. - assert!(local_data_get(my_key).is_none()); - local_data_set(my_key, @~"child data"); - assert!(*(local_data_get(my_key).get()) == + // TLS shouldn't carry over. + assert!(local_data_get(my_key).is_none()); + local_data_set(my_key, @~"child data"); + assert!(*(local_data_get(my_key).get()) == ~"child data"); - // should be cleaned up for us - } + // should be cleaned up for us } // Must work multiple times assert!(*(local_data_get(my_key).get()) == ~"parent data"); @@ -206,12 +204,11 @@ fn int_key(_x: @int) { } local_data_set(str_key, @~"parent data"); local_data_set(box_key, @@()); do task::spawn { - unsafe { // spawn_linked - local_data_set(str_key, @~"string data"); - local_data_set(box_key, @@()); - local_data_set(int_key, @42); - fail!(); - } + // spawn_linked + local_data_set(str_key, @~"string data"); + local_data_set(box_key, @@()); + local_data_set(int_key, @42); + fail!(); } // Not quite nondeterministic. local_data_set(int_key, @31337); diff --git a/src/libstd/rt/uv/timer.rs b/src/libstd/rt/uv/timer.rs index cd6fc5c0a25..14465eb7dfd 100644 --- a/src/libstd/rt/uv/timer.rs +++ b/src/libstd/rt/uv/timer.rs @@ -160,14 +160,14 @@ fn repeat_stop() { let mut timer2 = TimerWatcher::new(&mut loop_); do timer2.start(10, 0) |timer2, _| { - unsafe { *count_ptr += 1; } + *count_ptr += 1; timer2.close(||()); // Restart the original timer let mut timer = timer; do timer.start(1, 0) |timer, _| { - unsafe { *count_ptr += 1; } + *count_ptr += 1; timer.close(||()); } } diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 58cdc6631f0..b4292a30541 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -2249,7 +2249,7 @@ fn test_le() { assert!("" <= ""); assert!("" <= "foo"); assert!("foo" <= "foo"); - assert!("foo" != ~"bar"); + assert!("foo" != "bar"); } #[test] @@ -3156,6 +3156,7 @@ fn test_char_range_at_reverse_underflow() { #[test] fn test_add() { + #[allow(unnecessary_allocation)]; macro_rules! t ( ($s1:expr, $s2:expr, $e:expr) => { assert_eq!($s1 + $s2, $e); diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 223afbce091..b558b9d53a3 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -934,17 +934,15 @@ fn test_spawn_sched_blocking() { let lock = testrt::rust_dbg_lock_create(); do spawn_sched(SingleThreaded) { - unsafe { - testrt::rust_dbg_lock_lock(lock); + testrt::rust_dbg_lock_lock(lock); - start_ch.send(()); + start_ch.send(()); - // Block the scheduler thread - testrt::rust_dbg_lock_wait(lock); - testrt::rust_dbg_lock_unlock(lock); + // Block the scheduler thread + testrt::rust_dbg_lock_wait(lock); + testrt::rust_dbg_lock_unlock(lock); - fin_ch.send(()); - } + fin_ch.send(()); }; // Wait until the other task has its lock diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 5dfea811c23..8cbd9309cc6 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -3861,11 +3861,11 @@ fn test_permutations3() { fn test_vec_zero() { use num::Zero; macro_rules! t ( - ($ty:ty) => { + ($ty:ty) => {{ let v: $ty = Zero::zero(); assert!(v.is_empty()); assert!(v.is_zero()); - } + }} ); t!(&[int]);