From bcb1c381a38f8f36a71323bbf12d55afc8627d90 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 6 Jan 2014 22:33:37 -0800 Subject: [PATCH] stdtest: Fix all leaked trait imports --- src/libstd/ascii.rs | 2 +- src/libstd/bool.rs | 5 +---- src/libstd/c_str.rs | 9 ++++----- src/libstd/gc.rs | 1 + src/libstd/io/buffered.rs | 3 ++- src/libstd/io/extensions.rs | 9 +++++---- src/libstd/io/net/addrinfo.rs | 2 +- src/libstd/io/net/ip.rs | 3 +-- src/libstd/io/net/udp.rs | 2 -- src/libstd/io/option.rs | 3 ++- src/libstd/io/util.rs | 1 + src/libstd/option.rs | 1 + src/libstd/os.rs | 4 +--- src/libstd/path/mod.rs | 1 + src/libstd/path/posix.rs | 5 ++--- src/libstd/path/windows.rs | 4 +--- src/libstd/rand/distributions/exponential.rs | 10 +++++----- src/libstd/rand/distributions/gamma.rs | 11 +++++------ src/libstd/rand/distributions/mod.rs | 2 +- src/libstd/rand/distributions/normal.rs | 12 ++++++------ src/libstd/rand/distributions/range.rs | 5 ++--- src/libstd/rand/isaac.rs | 3 +-- src/libstd/rand/mod.rs | 6 ++---- src/libstd/rand/rand_impls.rs | 3 +-- src/libstd/rand/reader.rs | 2 ++ src/libstd/rand/reseeding.rs | 4 +--- src/libstd/rc.rs | 1 + src/libstd/result.rs | 3 +-- src/libstd/rt/unwind.rs | 14 ++++---------- src/libstd/run.rs | 5 ++--- src/libstd/send_str.rs | 8 +------- src/libstd/str.rs | 7 ++----- src/libstd/unstable/stack.rs | 2 -- src/libstd/util.rs | 5 +---- src/libstd/vec.rs | 10 ++++------ 35 files changed, 67 insertions(+), 101 deletions(-) diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index adc10c456e3..c52ff2d088d 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -478,10 +478,10 @@ static ASCII_UPPER_MAP: &'static [u8] = &[ #[cfg(test)] mod tests { + use prelude::*; use super::*; use str::from_char; use char::from_u32; - use option::{Some, None}; macro_rules! v2ascii ( ( [$($e:expr),*]) => ( [$(Ascii{chr:$e}),*]); diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs index 923aacf352b..a20ddc14147 100644 --- a/src/libstd/bool.rs +++ b/src/libstd/bool.rs @@ -317,10 +317,7 @@ impl Zero for bool { #[cfg(test)] mod tests { - use cmp::{Equal, Greater, Less, Eq, TotalOrd}; - use ops::{BitAnd, BitXor, BitOr}; - use from_str::{FromStr, from_str}; - use option::{Some, None}; + use prelude::*; use super::all_values; #[test] diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index a7e502be32e..b924378a0e7 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -377,10 +377,10 @@ pub unsafe fn from_c_multistring(buf: *libc::c_char, #[cfg(test)] mod tests { + use prelude::*; use super::*; use libc; use ptr; - use option::{Some, None}; #[test] fn test_str_multistring_parsing() { @@ -568,11 +568,10 @@ mod tests { #[cfg(test)] mod bench { - use iter::range; - use libc; - use option::Some; - use ptr; use extra::test::BenchHarness; + use libc; + use prelude::*; + use ptr; #[inline] fn check(s: &str, c_str: *libc::c_char) { diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs index d3bec8ca6c9..df7111ca510 100644 --- a/src/libstd/gc.rs +++ b/src/libstd/gc.rs @@ -54,6 +54,7 @@ impl DeepClone for Gc { #[cfg(test)] mod tests { + use prelude::*; use super::*; use cell::RefCell; diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index fd8fd0c6814..fa85f286af7 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -318,9 +318,10 @@ impl Decorator for BufferedStream { #[cfg(test)] mod test { + use io::Decorator; + use io; use prelude::*; use super::*; - use io; use super::super::mem::{MemReader, MemWriter}; use Harness = extra::test::BenchHarness; diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 5fed9d74527..860ff644018 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -131,10 +131,11 @@ pub fn u64_from_be_bytes(data: &[u8], #[cfg(test)] mod test { - use option::{None, Option, Some}; + use unstable::finally::Finally; + use io::Decorator; + use prelude::*; use io::mem::{MemReader, MemWriter}; - use io::{Reader, io_error, placeholder_error}; - use vec::ImmutableVector; + use io::{io_error, placeholder_error}; struct InitialZeroByteReader { count: int, @@ -376,7 +377,7 @@ mod test { fn push_bytes_fail_reset_len() { // push_bytes unsafely sets the vector length. This is testing that // upon failure the length is reset correctly. - let mut reader = ErroringLaterReader { + let reader = ErroringLaterReader { count: 0, }; // FIXME (#7049): Figure out some other way to do this. diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index 6d968de209c..fe29a112262 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -100,8 +100,8 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option) #[cfg(test)] mod test { - use option::Some; use io::net::ip::Ipv4Addr; + use prelude::*; use super::*; #[test] diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index 00f66f1e9c7..4fb631eb3d6 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -337,9 +337,8 @@ impl FromStr for SocketAddr { #[cfg(test)] mod test { + use prelude::*; use super::*; - use from_str::FromStr; - use option::{Option, Some, None}; #[test] fn test_from_str_ipv4() { diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 8994f6b461a..eaee48dc6e0 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -100,8 +100,6 @@ impl Writer for UdpStream { mod test { use super::*; use io::net::ip::{SocketAddr}; - use io::*; - use prelude::*; iotest!(fn bind_error() { let mut called = false; diff --git a/src/libstd/io/option.rs b/src/libstd/io/option.rs index a661d6ab7eb..60e63e95dcc 100644 --- a/src/libstd/io/option.rs +++ b/src/libstd/io/option.rs @@ -104,8 +104,9 @@ impl> Acceptor for Option { #[cfg(test)] mod test { - use option::*; + use prelude::*; use super::super::mem::*; + use io::Decorator; use super::super::{PreviousIoError, io_error}; #[test] diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 48030543336..86538c37249 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -193,6 +193,7 @@ pub fn copy(r: &mut R, w: &mut W) { #[cfg(test)] mod test { + use io::Decorator; use io::mem::{MemReader, MemWriter}; use super::*; use prelude::*; diff --git a/src/libstd/option.rs b/src/libstd/option.rs index a44b280aa84..f49244a3607 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -457,6 +457,7 @@ pub fn collect>, V: FromIterator>(iter: Iter) -> #[cfg(test)] mod tests { use super::*; + use prelude::*; use iter::range; use str::StrSlice; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index def8d8bb08e..4042e13a592 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1239,16 +1239,14 @@ pub mod consts { #[cfg(test)] mod tests { + use prelude::*; use c_str::ToCStr; - use option::Some; use option; use os::{env, getcwd, getenv, make_absolute, args}; use os::{setenv, unsetenv}; use os; - use path::Path; use rand::Rng; use rand; - use str::StrSlice; #[test] diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 6488595ea4f..354cc10f022 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -687,6 +687,7 @@ fn from_utf8_with_replacement(mut v: &[u8]) -> ~str { } #[cfg(test)] mod tests { + use prelude::*; use super::{GenericPath, PosixPath, WindowsPath}; use c_str::ToCStr; diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index e0e3e8c790c..7b94de6c094 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -442,11 +442,9 @@ static dot_dot_static: &'static [u8] = bytes!(".."); #[cfg(test)] mod tests { + use prelude::*; use super::*; - use option::{Option, Some, None}; - use iter::Iterator; use str; - use vec::Vector; macro_rules! t( (s: $path:expr, $exp:expr) => ( @@ -1325,6 +1323,7 @@ mod tests { mod bench { use extra::test::BenchHarness; use super::*; + use prelude::*; #[bench] fn join_home_dir(bh: &mut BenchHarness) { diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index be83a519807..09b00be7e9d 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1053,11 +1053,9 @@ fn prefix_len(p: Option) -> uint { #[cfg(test)] mod tests { + use prelude::*; use super::*; use super::parse_prefix; - use option::{Some,None}; - use iter::Iterator; - use vec::Vector; macro_rules! t( (s: $path:expr, $exp:expr) => ( diff --git a/src/libstd/rand/distributions/exponential.rs b/src/libstd/rand/distributions/exponential.rs index fe1d8c505ca..336528eeb25 100644 --- a/src/libstd/rand/distributions/exponential.rs +++ b/src/libstd/rand/distributions/exponential.rs @@ -91,10 +91,10 @@ impl IndependentSample for Exp { #[cfg(test)] mod test { + use rand::distributions::*; + use prelude::*; use rand::*; use super::*; - use iter::range; - use option::{Some, None}; #[test] fn test_exp() { @@ -120,11 +120,11 @@ mod test { #[cfg(test)] mod bench { use extra::test::BenchHarness; + use mem::size_of; + use prelude::*; use rand::{XorShiftRng, RAND_BENCH_N}; use super::*; - use iter::range; - use option::{Some, None}; - use mem::size_of; + use rand::distributions::*; #[bench] fn rand_exp(bh: &mut BenchHarness) { diff --git a/src/libstd/rand/distributions/gamma.rs b/src/libstd/rand/distributions/gamma.rs index 78b6f5b8c7f..96efa948015 100644 --- a/src/libstd/rand/distributions/gamma.rs +++ b/src/libstd/rand/distributions/gamma.rs @@ -310,10 +310,10 @@ impl IndependentSample for StudentT { #[cfg(test)] mod test { + use rand::distributions::*; + use prelude::*; use rand::*; use super::*; - use iter::range; - use option::{Some, None}; #[test] fn test_chi_squared_one() { @@ -371,13 +371,12 @@ mod test { #[cfg(test)] mod bench { - use super::*; + use extra::test::BenchHarness; use mem::size_of; + use prelude::*; use rand::distributions::IndependentSample; use rand::{StdRng, RAND_BENCH_N}; - use extra::test::BenchHarness; - use iter::range; - use option::{Some, None}; + use super::*; #[bench] diff --git a/src/libstd/rand/distributions/mod.rs b/src/libstd/rand/distributions/mod.rs index e29a70aede9..a996233abe3 100644 --- a/src/libstd/rand/distributions/mod.rs +++ b/src/libstd/rand/distributions/mod.rs @@ -253,9 +253,9 @@ fn ziggurat( #[cfg(test)] mod tests { + use prelude::*; use rand::*; use super::*; - use option::{Some, None}; #[deriving(Eq)] struct ConstRand(uint); diff --git a/src/libstd/rand/distributions/normal.rs b/src/libstd/rand/distributions/normal.rs index 7b24f78bdcf..7a15091df9d 100644 --- a/src/libstd/rand/distributions/normal.rs +++ b/src/libstd/rand/distributions/normal.rs @@ -148,10 +148,10 @@ impl IndependentSample for LogNormal { #[cfg(test)] mod tests { + use prelude::*; use rand::*; use super::*; - use iter::range; - use option::{Some, None}; + use rand::distributions::*; #[test] fn test_normal() { @@ -188,11 +188,11 @@ mod tests { #[cfg(test)] mod bench { use extra::test::BenchHarness; - use rand::{XorShiftRng, RAND_BENCH_N}; - use super::*; - use iter::range; - use option::{Some, None}; use mem::size_of; + use prelude::*; + use rand::{XorShiftRng, RAND_BENCH_N}; + use rand::distributions::*; + use super::*; #[bench] fn rand_normal(bh: &mut BenchHarness) { diff --git a/src/libstd/rand/distributions/range.rs b/src/libstd/rand/distributions/range.rs index fc6cdde162d..8141b3d3e89 100644 --- a/src/libstd/rand/distributions/range.rs +++ b/src/libstd/rand/distributions/range.rs @@ -163,12 +163,11 @@ float_impl! { f64 } #[cfg(test)] mod tests { + use prelude::*; use super::*; use rand::*; + use rand::distributions::*; use num::Bounded; - use iter::range; - use option::{Some, None}; - use vec::ImmutableVector; #[should_fail] #[test] diff --git a/src/libstd/rand/isaac.rs b/src/libstd/rand/isaac.rs index e1845bfeab6..6fd2cde9dfb 100644 --- a/src/libstd/rand/isaac.rs +++ b/src/libstd/rand/isaac.rs @@ -433,8 +433,7 @@ impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng { mod test { use super::*; use rand::{Rng, SeedableRng, OSRng}; - use option::Some; - use iter::range; + use prelude::*; use vec; #[test] diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 0fa436b2447..e52a3850011 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -656,8 +656,7 @@ pub struct Closed01(F); #[cfg(test)] mod test { - use iter::{Iterator, range}; - use option::{Option, Some}; + use prelude::*; use vec; use super::*; @@ -845,11 +844,10 @@ static RAND_BENCH_N: u64 = 100; #[cfg(test)] mod bench { + use prelude::*; use extra::test::BenchHarness; use rand::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng, RAND_BENCH_N}; use mem::size_of; - use iter::range; - use option::{Some, None}; #[bench] fn rand_xorshift(bh: &mut BenchHarness) { diff --git a/src/libstd/rand/rand_impls.rs b/src/libstd/rand/rand_impls.rs index dd6edca94ac..1c90ef148fc 100644 --- a/src/libstd/rand/rand_impls.rs +++ b/src/libstd/rand/rand_impls.rs @@ -226,9 +226,8 @@ impl Rand for @T { #[cfg(test)] mod tests { + use prelude::*; use rand::{Rng, task_rng, Open01, Closed01}; - use iter::range; - use option::{None, Some}; struct ConstantRng(u64); impl Rng for ConstantRng { diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index 7045b64eff6..7af98e418a8 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -78,6 +78,8 @@ mod test { use super::*; use io::mem::MemReader; use cast; + use rand::*; + use prelude::*; #[test] fn test_reader_rng_u64() { diff --git a/src/libstd/rand/reseeding.rs b/src/libstd/rand/reseeding.rs index 9e049564a2d..c0a7d14bf70 100644 --- a/src/libstd/rand/reseeding.rs +++ b/src/libstd/rand/reseeding.rs @@ -142,11 +142,9 @@ impl Default for ReseedWithDefault { #[cfg(test)] mod test { + use prelude::*; use super::*; use rand::{SeedableRng, Rng}; - use default::Default; - use iter::range; - use option::{None, Some}; struct Counter { i: u32 diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 9158e8cdb89..ad2305c2410 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -170,6 +170,7 @@ impl Drop for Rc { #[cfg(test)] mod test_rc { + use prelude::*; use super::*; use cell::RefCell; diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 4e8db15a92e..1a4e6d5bcfd 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -293,10 +293,9 @@ pub fn fold_>>(iterator: Iter) -> Result<(),E> { #[cfg(test)] mod tests { use super::*; + use prelude::*; use iter::range; - use to_str::ToStr; - use vec::ImmutableVector; pub fn op1() -> Result { Ok(666) } pub fn op2() -> Result { Err(~"sadface") } diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 56dc2288a40..3a07e8c373b 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -77,6 +77,7 @@ mod libunwind { //! Unwind library interface #[allow(non_camel_case_types)]; + #[allow(dead_code)] // these are just bindings use libc::{uintptr_t, uint64_t}; @@ -262,7 +263,8 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class { // This is achieved by overriding the return value in search phase to always // say "catch!". -#[cfg(not(target_arch = "arm"))] +#[cfg(not(target_arch = "arm"), not(test))] +#[doc(hidden)] pub mod eabi { use uw = super::libunwind; use libc::c_int; @@ -278,8 +280,6 @@ pub mod eabi { #[lang="eh_personality"] #[no_mangle] // so we can reference it by name from middle/trans/base.rs - #[doc(hidden)] - #[cfg(not(test))] pub extern "C" fn rust_eh_personality( version: c_int, actions: uw::_Unwind_Action, @@ -295,8 +295,6 @@ pub mod eabi { } #[no_mangle] // referenced from rust_try.ll - #[doc(hidden)] - #[cfg(not(test))] pub extern "C" fn rust_eh_personality_catch( version: c_int, actions: uw::_Unwind_Action, @@ -319,7 +317,7 @@ pub mod eabi { // ARM EHABI uses a slightly different personality routine signature, // but otherwise works the same. -#[cfg(target_arch = "arm")] +#[cfg(target_arch = "arm", not(test))] pub mod eabi { use uw = super::libunwind; use libc::c_int; @@ -333,8 +331,6 @@ pub mod eabi { #[lang="eh_personality"] #[no_mangle] // so we can reference it by name from middle/trans/base.rs - #[doc(hidden)] - #[cfg(not(test))] pub extern "C" fn rust_eh_personality( state: uw::_Unwind_State, ue_header: *uw::_Unwind_Exception, @@ -347,8 +343,6 @@ pub mod eabi { } #[no_mangle] // referenced from rust_try.ll - #[doc(hidden)] - #[cfg(not(test))] pub extern "C" fn rust_eh_personality_catch( state: uw::_Unwind_State, ue_header: *uw::_Unwind_Exception, diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 337cb744080..3595a7d45ac 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -330,16 +330,15 @@ pub fn process_output(prog: &str, args: &[~str]) -> Option { #[cfg(test)] mod tests { + use prelude::*; use libc::c_int; - use option::{Option, None, Some}; use os; - use path::Path; use run; use str; use task::spawn; use unstable::running_on_valgrind; use io::pipe::PipeStream; - use io::{Writer, Reader, io_error, FileNotFound}; + use io::{io_error, FileNotFound}; #[test] #[cfg(not(target_os="android"))] // FIXME(#10380) diff --git a/src/libstd/send_str.rs b/src/libstd/send_str.rs index f10818b052d..c8143442d6e 100644 --- a/src/libstd/send_str.rs +++ b/src/libstd/send_str.rs @@ -176,14 +176,8 @@ impl IterBytes for SendStr { #[cfg(test)] mod tests { - use clone::{Clone, DeepClone}; - use cmp::{TotalEq, Ord, TotalOrd, Equiv}; - use cmp::Equal; - use container::Container; - use default::Default; + use prelude::*; use send_str::{SendStrOwned, SendStrStatic}; - use str::Str; - use to_str::ToStr; #[test] fn test_send_str_traits() { diff --git a/src/libstd/str.rs b/src/libstd/str.rs index a005549402e..35e188964c1 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -2768,14 +2768,11 @@ impl Default for @str { #[cfg(test)] mod tests { - use container::Container; - use option::{None, Some, Option}; + use iter::AdditiveIterator; + use prelude::*; use ptr; use str::*; - use vec::{Vector, ImmutableVector, CopyableVector}; - use cmp::{TotalOrd, Less, Equal, Greater}; use send_str::{SendStrOwned, SendStrStatic}; - use from_str::from_str; #[test] fn test_eq() { diff --git a/src/libstd/unstable/stack.rs b/src/libstd/unstable/stack.rs index 5b5eaf9d8d0..d6cd690eaa9 100644 --- a/src/libstd/unstable/stack.rs +++ b/src/libstd/unstable/stack.rs @@ -24,8 +24,6 @@ //! detection is not guaranteed to continue in the future. Usage of this module //! is discouraged unless absolutely necessary. -use str::Str; - static RED_ZONE: uint = 20 * 1024; /// This function is invoked from rust's current __morestack function. Segmented diff --git a/src/libstd/util.rs b/src/libstd/util.rs index 6c0424b50e1..06c7923bfed 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -78,10 +78,7 @@ impl Void { #[cfg(test)] mod tests { use super::*; - - use clone::Clone; - use ops::Drop; - use option::{None, Some}; + use prelude::*; use mem::size_of; #[test] diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 4fa2372c1ab..632490d62ad 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2970,10 +2970,10 @@ impl Extendable for ~[A] { #[cfg(test)] mod tests { + use prelude::*; use mem; use vec::*; use cmp::*; - use prelude::*; use rand::{Rng, task_rng}; fn square(n: uint) -> uint { n * n } @@ -4454,13 +4454,11 @@ mod tests { #[cfg(test)] mod bench { use extra::test::BenchHarness; - use iter::range; - use vec; - use vec::{VectorVector, MutableTotalOrdVector}; - use option::*; + use mem; + use prelude::*; use ptr; use rand::{weak_rng, Rng}; - use mem; + use vec; #[bench] fn iterator(bh: &mut BenchHarness) {