about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/liballoc/boxed_test.rs1
-rw-r--r--src/liballoc/lib.rs13
-rw-r--r--src/libcollections/lib.rs2
-rw-r--r--src/libcollections/slice.rs15
-rw-r--r--src/libcollections/str.rs4
-rw-r--r--src/libcollectionstest/slice.rs1
-rw-r--r--src/librand/lib.rs2
-rw-r--r--src/libserialize/json.rs1
-rw-r--r--src/libstd/dynamic_lib.rs14
-rw-r--r--src/libstd/io/buffered.rs4
-rw-r--r--src/libstd/os/raw.rs1
-rw-r--r--src/libstd/path.rs8
-rw-r--r--src/libstd/process.rs62
-rw-r--r--src/libstd/sync/mpsc/select.rs2
-rw-r--r--src/libstd/sync/semaphore.rs24
-rw-r--r--src/libstd/sys/unix/mod.rs53
-rw-r--r--src/libstd/sys/unix/stack_overflow.rs1
-rw-r--r--src/libstd/sys/unix/thread.rs19
-rw-r--r--src/libstd/sys/windows/fs.rs4
-rw-r--r--src/libstd/sys/windows/mod.rs42
-rw-r--r--src/libstd/sys/windows/process.rs1
-rw-r--r--src/libstd/sys/windows/stack_overflow.rs2
-rw-r--r--src/libstd/sys/windows/thread.rs1
-rw-r--r--src/libsyntax/print/pprust.rs1
24 files changed, 137 insertions, 141 deletions
diff --git a/src/liballoc/boxed_test.rs b/src/liballoc/boxed_test.rs
index e7da6d04d3f..120301afa44 100644
--- a/src/liballoc/boxed_test.rs
+++ b/src/liballoc/boxed_test.rs
@@ -15,7 +15,6 @@ use core::ops::Deref;
 use core::result::Result::{Ok, Err};
 use core::clone::Clone;
 
-use std::boxed;
 use std::boxed::Box;
 
 #[test]
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 403baa4a7b2..1438103d7f6 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -75,31 +75,28 @@
 #![feature(allocator)]
 #![feature(box_syntax)]
 #![feature(coerce_unsized)]
+#![feature(const_fn)]
 #![feature(core_intrinsics)]
 #![feature(custom_attribute)]
+#![feature(drop_in_place)]
+#![feature(dropck_parametricity)]
 #![feature(fundamental)]
 #![feature(lang_items)]
+#![feature(needs_allocator)]
 #![feature(optin_builtin_traits)]
 #![feature(placement_in_syntax)]
-#![feature(placement_new_protocol)]
-#![feature(raw)]
 #![feature(shared)]
 #![feature(staged_api)]
 #![feature(unboxed_closures)]
 #![feature(unique)]
 #![feature(unsafe_no_drop_flag, filling_drop)]
-#![feature(dropck_parametricity)]
 #![feature(unsize)]
-#![feature(drop_in_place)]
-#![feature(fn_traits)]
-#![feature(const_fn)]
-
-#![feature(needs_allocator)]
 
 // Issue# 30592: Systematically use alloc_system during stage0 since jemalloc
 // might be unavailable or disabled
 #![cfg_attr(stage0, feature(alloc_system))]
 
+#![cfg_attr(not(test), feature(raw, fn_traits, placement_new_protocol))]
 #![cfg_attr(test, feature(test, rustc_private, box_heap))]
 
 #[cfg(stage0)]
diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs
index a3c05c5a681..4958f750166 100644
--- a/src/libcollections/lib.rs
+++ b/src/libcollections/lib.rs
@@ -56,7 +56,7 @@
 #![feature(unicode)]
 #![feature(unique)]
 #![feature(unsafe_no_drop_flag)]
-#![cfg_attr(test, feature(clone_from_slice, rand, test))]
+#![cfg_attr(test, feature(rand, test))]
 
 #![no_std]
 
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs
index 8b4497e6f03..6252e4888eb 100644
--- a/src/libcollections/slice.rs
+++ b/src/libcollections/slice.rs
@@ -83,20 +83,14 @@
 
 // Many of the usings in this module are only used in the test configuration.
 // It's cleaner to just turn off the unused_imports warning than to fix them.
-#![allow(unused_imports)]
+#![cfg_attr(test, allow(unused_imports, dead_code))]
 
 use alloc::boxed::Box;
-use core::clone::Clone;
 use core::cmp::Ordering::{self, Greater, Less};
-use core::cmp::{self, Ord, PartialEq};
-use core::iter::Iterator;
-use core::marker::Sized;
+use core::cmp;
 use core::mem::size_of;
 use core::mem;
-use core::ops::FnMut;
-use core::option::Option::{self, Some, None};
 use core::ptr;
-use core::result::Result;
 use core::slice as core_slice;
 
 use borrow::{Borrow, BorrowMut, ToOwned};
@@ -136,12 +130,7 @@ pub use self::hack::to_vec;
 // `test_permutations` test
 mod hack {
     use alloc::boxed::Box;
-    use core::clone::Clone;
-    #[cfg(test)]
-    use core::iter::Iterator;
     use core::mem;
-    #[cfg(test)]
-    use core::option::Option::{Some, None};
 
     #[cfg(test)]
     use string::ToString;
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index 9ce1a111cf8..094b7f1d034 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -19,10 +19,6 @@
 // It's cleaner to just turn off the unused_imports warning than to fix them.
 #![allow(unused_imports)]
 
-use core::clone::Clone;
-use core::iter::{Iterator, Extend};
-use core::option::Option::{self, Some, None};
-use core::result::Result;
 use core::str as core_str;
 use core::str::pattern::Pattern;
 use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};
diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs
index 80dcd48fbfa..e5e15025625 100644
--- a/src/libcollectionstest/slice.rs
+++ b/src/libcollectionstest/slice.rs
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 use std::cmp::Ordering::{Equal, Greater, Less};
-use std::default::Default;
 use std::mem;
 use std::__rand::{Rng, thread_rng};
 use std::rc::Rc;
diff --git a/src/librand/lib.rs b/src/librand/lib.rs
index 9640322a2dd..531be63b7bb 100644
--- a/src/librand/lib.rs
+++ b/src/librand/lib.rs
@@ -36,7 +36,7 @@
 #![feature(custom_attribute)]
 #![allow(unused_attributes)]
 
-#![cfg_attr(test, feature(test, rand, rustc_private, iter_order_deprecated))]
+#![cfg_attr(test, feature(test, rand, rustc_private))]
 
 #![allow(deprecated)]
 
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index 9e1e3c6a558..2310a8237f4 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -2606,7 +2606,6 @@ impl FromStr for Json {
 mod tests {
     extern crate test;
     use self::Animal::*;
-    use self::DecodeEnum::*;
     use self::test::Bencher;
     use {Encodable, Decodable};
     use super::Json::*;
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs
index 41001153c3c..585051a98e5 100644
--- a/src/libstd/dynamic_lib.rs
+++ b/src/libstd/dynamic_lib.rs
@@ -16,7 +16,6 @@
             reason = "API has not been scrutinized and is highly likely to \
                       either disappear or change",
             issue = "27810")]
-#![rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")]
 #![allow(missing_docs)]
 #![allow(deprecated)]
 
@@ -26,6 +25,11 @@ use env;
 use ffi::{CString, OsString};
 use path::{Path, PathBuf};
 
+#[unstable(feature = "dynamic_lib",
+           reason = "API has not been scrutinized and is highly likely to \
+                     either disappear or change",
+           issue = "27810")]
+#[rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")]
 pub struct DynamicLibrary {
     handle: *mut u8
 }
@@ -43,6 +47,11 @@ impl Drop for DynamicLibrary {
     }
 }
 
+#[unstable(feature = "dynamic_lib",
+           reason = "API has not been scrutinized and is highly likely to \
+                     either disappear or change",
+           issue = "27810")]
+#[rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")]
 impl DynamicLibrary {
     /// Lazily open a dynamic library. When passed None it gives a
     /// handle to the calling process
@@ -126,7 +135,6 @@ mod tests {
     use prelude::v1::*;
     use libc;
     use mem;
-    use path::Path;
 
     #[test]
     #[cfg_attr(any(windows,
@@ -167,6 +175,8 @@ mod tests {
               target_os = "openbsd"))]
     #[allow(deprecated)]
     fn test_errors_do_not_crash() {
+        use path::Path;
+
         // Open /dev/null as a library to get an error, and make sure
         // that only causes an error, and not a crash.
         let path = Path::new("/dev/null");
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs
index 5ec51eaa567..ccebf3682c2 100644
--- a/src/libstd/io/buffered.rs
+++ b/src/libstd/io/buffered.rs
@@ -1095,8 +1095,8 @@ mod tests {
 
         thread::spawn(|| {
             let mut writer = BufWriter::new(PanicWriter);
-            writer.write(b"hello world");
-            writer.flush();
+            let _ = writer.write(b"hello world");
+            let _ = writer.flush();
         }).join().err().unwrap();
 
         assert_eq!(WRITES.load(Ordering::SeqCst), 1);
diff --git a/src/libstd/os/raw.rs b/src/libstd/os/raw.rs
index 62080fee48e..31d889fd422 100644
--- a/src/libstd/os/raw.rs
+++ b/src/libstd/os/raw.rs
@@ -68,6 +68,7 @@ pub enum c_void {
 }
 
 #[cfg(test)]
+#[allow(unused_imports)]
 mod tests {
     use any::TypeId;
     use libc;
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index e398a5a28c9..207c4d02e48 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -3326,11 +3326,13 @@ mod tests {
                          "{:?}.ends_with({:?}), expected {:?}, got {:?}", $path1, $path2,
                          $ends_with, ends_with);
 
-                 let relative_from = path1.relative_from(path2).map(|p| p.to_str().unwrap());
+                 let relative_from = path1.strip_prefix(path2)
+                                          .map(|p| p.to_str().unwrap())
+                                          .ok();
                  let exp: Option<&str> = $relative_from;
                  assert!(relative_from == exp,
-                         "{:?}.relative_from({:?}), expected {:?}, got {:?}", $path1, $path2,
-                         exp, relative_from);
+                         "{:?}.strip_prefix({:?}), expected {:?}, got {:?}",
+                         $path1, $path2, exp, relative_from);
             });
         );
 
diff --git a/src/libstd/process.rs b/src/libstd/process.rs
index be1fe9b2a9b..7197dfa8b2d 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -618,8 +618,8 @@ mod tests {
 
     // FIXME(#10380) these tests should not all be ignored on android.
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn smoke() {
         let p = Command::new("true").spawn();
         assert!(p.is_ok());
@@ -627,8 +627,8 @@ mod tests {
         assert!(p.wait().unwrap().success());
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn smoke_failure() {
         match Command::new("if-this-is-a-binary-then-the-world-has-ended").spawn() {
             Ok(..) => panic!(),
@@ -636,8 +636,8 @@ mod tests {
         }
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn exit_reported_right() {
         let p = Command::new("false").spawn();
         assert!(p.is_ok());
@@ -646,8 +646,9 @@ mod tests {
         drop(p.wait());
     }
 
-    #[cfg(all(unix, not(target_os="android")))]
     #[test]
+    #[cfg(unix)]
+    #[cfg_attr(target_os = "android", ignore)]
     fn signal_reported_right() {
         use os::unix::process::ExitStatusExt;
 
@@ -674,16 +675,16 @@ mod tests {
         return ret;
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn stdout_works() {
         let mut cmd = Command::new("echo");
         cmd.arg("foobar").stdout(Stdio::piped());
         assert_eq!(run_output(cmd), "foobar\n");
     }
 
-    #[cfg(all(unix, not(target_os="android")))]
     #[test]
+    #[cfg_attr(any(windows, target_os = "android"), ignore)]
     fn set_current_dir_works() {
         let mut cmd = Command::new("/bin/sh");
         cmd.arg("-c").arg("pwd")
@@ -692,8 +693,8 @@ mod tests {
         assert_eq!(run_output(cmd), "/\n");
     }
 
-    #[cfg(all(unix, not(target_os="android")))]
     #[test]
+    #[cfg_attr(any(windows, target_os = "android"), ignore)]
     fn stdin_works() {
         let mut p = Command::new("/bin/sh")
                             .arg("-c").arg("read line; echo $line")
@@ -709,8 +710,9 @@ mod tests {
     }
 
 
-    #[cfg(all(unix, not(target_os="android")))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
+    #[cfg(unix)]
     fn uid_works() {
         use os::unix::prelude::*;
         use libc;
@@ -722,8 +724,9 @@ mod tests {
         assert!(p.wait().unwrap().success());
     }
 
-    #[cfg(all(unix, not(target_os="android")))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
+    #[cfg(unix)]
     fn uid_to_root_fails() {
         use os::unix::prelude::*;
         use libc;
@@ -734,8 +737,8 @@ mod tests {
         assert!(Command::new("/bin/ls").uid(0).gid(0).spawn().is_err());
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn test_process_status() {
         let mut status = Command::new("false").status().unwrap();
         assert!(status.code() == Some(1));
@@ -752,8 +755,8 @@ mod tests {
         }
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn test_process_output_output() {
         let Output {status, stdout, stderr}
              = Command::new("echo").arg("hello").output().unwrap();
@@ -764,8 +767,8 @@ mod tests {
         assert_eq!(stderr, Vec::new());
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn test_process_output_error() {
         let Output {status, stdout, stderr}
              = Command::new("mkdir").arg(".").output().unwrap();
@@ -775,23 +778,23 @@ mod tests {
         assert!(!stderr.is_empty());
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn test_finish_once() {
         let mut prog = Command::new("false").spawn().unwrap();
         assert!(prog.wait().unwrap().code() == Some(1));
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn test_finish_twice() {
         let mut prog = Command::new("false").spawn().unwrap();
         assert!(prog.wait().unwrap().code() == Some(1));
         assert!(prog.wait().unwrap().code() == Some(1));
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
+    #[cfg_attr(target_os = "android", ignore)]
     fn test_wait_with_output_once() {
         let prog = Command::new("echo").arg("hello").stdout(Stdio::piped())
             .spawn().unwrap();
@@ -821,7 +824,6 @@ mod tests {
         cmd
     }
 
-    #[cfg(not(target_os="android"))]
     #[test]
     fn test_inherit_env() {
         use env;
@@ -830,36 +832,22 @@ mod tests {
         let output = String::from_utf8(result.stdout).unwrap();
 
         for (ref k, ref v) in env::vars() {
+            // don't check android RANDOM variables
+            if cfg!(target_os = "android") && *k == "RANDOM" {
+                continue
+            }
+
             // Windows has hidden environment variables whose names start with
             // equals signs (`=`). Those do not show up in the output of the
             // `set` command.
             assert!((cfg!(windows) && k.starts_with("=")) ||
                     k.starts_with("DYLD") ||
-                    output.contains(&format!("{}={}", *k, *v)),
+                    output.contains(&format!("{}={}", *k, *v)) ||
+                    output.contains(&format!("{}='{}'", *k, *v)),
                     "output doesn't contain `{}={}`\n{}",
                     k, v, output);
         }
     }
-    #[cfg(target_os="android")]
-    #[test]
-    fn test_inherit_env() {
-        use env;
-
-        let mut result = env_cmd().output().unwrap();
-        let output = String::from_utf8(result.stdout).unwrap();
-
-        for (ref k, ref v) in env::vars() {
-            // don't check android RANDOM variables
-            if *k != "RANDOM".to_string() {
-                assert!(output.contains(&format!("{}={}",
-                                                 *k,
-                                                 *v)) ||
-                        output.contains(&format!("{}=\'{}\'",
-                                                 *k,
-                                                 *v)));
-            }
-        }
-    }
 
     #[test]
     fn test_override_env() {
diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs
index d743cbb1890..5aa4ce81b8a 100644
--- a/src/libstd/sync/mpsc/select.rs
+++ b/src/libstd/sync/mpsc/select.rs
@@ -789,7 +789,7 @@ mod tests {
     fn fmt_debug_handle() {
         let (_, rx) = channel::<i32>();
         let sel = Select::new();
-        let mut handle = sel.handle(&rx);
+        let handle = sel.handle(&rx);
         assert_eq!(format!("{:?}", handle), "Handle { .. }");
     }
 }
diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs
index ac5ce298c5c..dd76444d3ae 100644
--- a/src/libstd/sync/semaphore.rs
+++ b/src/libstd/sync/semaphore.rs
@@ -12,9 +12,6 @@
             reason = "the interaction between semaphores and the acquisition/release \
                       of resources is currently unclear",
             issue = "27798")]
-#![rustc_deprecated(since = "1.7.0",
-                    reason = "easily confused with system semaphores and not \
-                              used enough to pull its weight")]
 #![allow(deprecated)]
 
 use ops::Drop;
@@ -49,6 +46,13 @@ use sync::{Mutex, Condvar};
 /// // Release our initially acquired resource
 /// sem.release();
 /// ```
+#[rustc_deprecated(since = "1.7.0",
+                   reason = "easily confused with system semaphores and not \
+                             used enough to pull its weight")]
+#[unstable(feature = "semaphore",
+           reason = "the interaction between semaphores and the acquisition/release \
+                     of resources is currently unclear",
+           issue = "27798")]
 pub struct Semaphore {
     lock: Mutex<isize>,
     cvar: Condvar,
@@ -56,10 +60,24 @@ pub struct Semaphore {
 
 /// An RAII guard which will release a resource acquired from a semaphore when
 /// dropped.
+#[rustc_deprecated(since = "1.7.0",
+                   reason = "easily confused with system semaphores and not \
+                             used enough to pull its weight")]
+#[unstable(feature = "semaphore",
+           reason = "the interaction between semaphores and the acquisition/release \
+                     of resources is currently unclear",
+           issue = "27798")]
 pub struct SemaphoreGuard<'a> {
     sem: &'a Semaphore,
 }
 
+#[rustc_deprecated(since = "1.7.0",
+                   reason = "easily confused with system semaphores and not \
+                             used enough to pull its weight")]
+#[unstable(feature = "semaphore",
+           reason = "the interaction between semaphores and the acquisition/release \
+                     of resources is currently unclear",
+           issue = "27798")]
 impl Semaphore {
     /// Creates a new semaphore with the initial count specified.
     ///
diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs
index 9771b057d8d..2e89becfa67 100644
--- a/src/libstd/sys/unix/mod.rs
+++ b/src/libstd/sys/unix/mod.rs
@@ -8,14 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![allow(missing_docs)]
-#![allow(non_camel_case_types)]
+#![allow(missing_docs, bad_style)]
 
 use io::{self, ErrorKind};
 use libc;
 use num::One;
 use ops::Neg;
-use alloc::oom;
 
 #[cfg(target_os = "android")]   pub use os::android as platform;
 #[cfg(target_os = "bitrig")]    pub use os::bitrig as platform;
@@ -46,25 +44,10 @@ pub mod thread_local;
 pub mod time;
 pub mod stdio;
 
-// A nicer handler for out-of-memory situations than the default one. This one
-// prints a message to stderr before aborting. It is critical that this code
-// does not allocate any memory since we are in an OOM situation. Any errors are
-// ignored while printing since there's nothing we can do about them and we are
-// about to exit anyways.
-fn oom_handler() -> ! {
-    use intrinsics;
-    let msg = "fatal runtime error: out of memory\n";
-    unsafe {
-        libc::write(libc::STDERR_FILENO,
-                    msg.as_ptr() as *const libc::c_void,
-                    msg.len() as libc::size_t);
-        intrinsics::abort();
-    }
-}
-
-#[cfg(not(any(target_os = "nacl", test)))]
+#[cfg(not(test))]
 pub fn init() {
-    use libc::signal;
+    use alloc::oom;
+
     // By default, some platforms will send a *signal* when an EPIPE error
     // would otherwise be delivered. This runtime doesn't install a SIGPIPE
     // handler, causing it to kill the program, which isn't exactly what we
@@ -73,15 +56,33 @@ pub fn init() {
     // Hence, we set SIGPIPE to ignore when the program starts up in order
     // to prevent this problem.
     unsafe {
-        assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0);
+        reset_sigpipe();
     }
 
     oom::set_oom_handler(oom_handler);
-}
 
-#[cfg(all(target_os = "nacl", not(test)))]
-pub fn init() {
-    oom::set_oom_handler(oom_handler);
+    // A nicer handler for out-of-memory situations than the default one. This
+    // one prints a message to stderr before aborting. It is critical that this
+    // code does not allocate any memory since we are in an OOM situation. Any
+    // errors are ignored while printing since there's nothing we can do about
+    // them and we are about to exit anyways.
+    fn oom_handler() -> ! {
+        use intrinsics;
+        let msg = "fatal runtime error: out of memory\n";
+        unsafe {
+            libc::write(libc::STDERR_FILENO,
+                        msg.as_ptr() as *const libc::c_void,
+                        msg.len() as libc::size_t);
+            intrinsics::abort();
+        }
+    }
+
+    #[cfg(not(target_os = "nacl"))]
+    unsafe fn reset_sigpipe() {
+        assert!(libc::signal(libc::SIGPIPE, libc::SIG_IGN) != !0);
+    }
+    #[cfg(target_os = "nacl")]
+    unsafe fn reset_sigpipe() {}
 }
 
 pub fn decode_error_kind(errno: i32) -> ErrorKind {
diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs
index fc49f4257be..c7614db3299 100644
--- a/src/libstd/sys/unix/stack_overflow.rs
+++ b/src/libstd/sys/unix/stack_overflow.rs
@@ -7,6 +7,7 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+
 #![cfg_attr(test, allow(dead_code))]
 
 use libc;
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index 4d715b579c6..9e28cf06d61 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![allow(dead_code)]
-
 use prelude::v1::*;
 
 use alloc::boxed::FnBox;
@@ -174,6 +172,7 @@ impl Drop for Thread {
           not(target_os = "bitrig"),
           not(all(target_os = "netbsd", not(target_vendor = "rumprun"))),
           not(target_os = "openbsd")))]
+#[cfg_attr(test, allow(dead_code))]
 pub mod guard {
     pub unsafe fn current() -> Option<usize> { None }
     pub unsafe fn init() -> Option<usize> { None }
@@ -185,15 +184,13 @@ pub mod guard {
           target_os = "bitrig",
           all(target_os = "netbsd", not(target_vendor = "rumprun")),
           target_os = "openbsd"))]
-#[allow(unused_imports)]
+#[cfg_attr(test, allow(dead_code))]
 pub mod guard {
     use prelude::v1::*;
 
-    use libc::{self, pthread_t};
+    use libc;
     use libc::mmap;
     use libc::{PROT_NONE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED};
-    use mem;
-    use ptr;
     use sys::os;
 
     #[cfg(any(target_os = "macos",
@@ -206,10 +203,10 @@ pub mod guard {
     #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
     unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
         let mut ret = None;
-        let mut attr: libc::pthread_attr_t = mem::zeroed();
+        let mut attr: libc::pthread_attr_t = ::mem::zeroed();
         assert_eq!(libc::pthread_attr_init(&mut attr), 0);
         if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 {
-            let mut stackaddr = ptr::null_mut();
+            let mut stackaddr = ::ptr::null_mut();
             let mut stacksize = 0;
             assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
                                                    &mut stacksize), 0);
@@ -265,7 +262,7 @@ pub mod guard {
 
     #[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
     pub unsafe fn current() -> Option<usize> {
-        let mut current_stack: libc::stack_t = mem::zeroed();
+        let mut current_stack: libc::stack_t = ::mem::zeroed();
         assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(),
                                              &mut current_stack), 0);
 
@@ -282,7 +279,7 @@ pub mod guard {
     #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
     pub unsafe fn current() -> Option<usize> {
         let mut ret = None;
-        let mut attr: libc::pthread_attr_t = mem::zeroed();
+        let mut attr: libc::pthread_attr_t = ::mem::zeroed();
         assert_eq!(libc::pthread_attr_init(&mut attr), 0);
         if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 {
             let mut guardsize = 0;
@@ -290,7 +287,7 @@ pub mod guard {
             if guardsize == 0 {
                 panic!("there is no guard page");
             }
-            let mut stackaddr = ptr::null_mut();
+            let mut stackaddr = ::ptr::null_mut();
             let mut size = 0;
             assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
                                                    &mut size), 0);
diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs
index 60e3f7c22bd..a8b82ef5f29 100644
--- a/src/libstd/sys/windows/fs.rs
+++ b/src/libstd/sys/windows/fs.rs
@@ -639,7 +639,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
 fn directory_junctions_are_directories() {
     use ffi::OsStr;
     use env;
-    use rand::{self, StdRng, Rng};
+    use rand::{self, Rng};
     use vec::Vec;
 
     macro_rules! t {
@@ -683,7 +683,7 @@ fn directory_junctions_are_directories() {
             let mut data = [0u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
             let mut db = data.as_mut_ptr()
                             as *mut c::REPARSE_MOUNTPOINT_DATA_BUFFER;
-            let mut buf = &mut (*db).ReparseTarget as *mut _;
+            let buf = &mut (*db).ReparseTarget as *mut _;
             let mut i = 0;
             let v = br"\??\";
             let v = v.iter().map(|x| *x as u16);
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index 16c4ae8257c..9ecef5ee92c 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -8,9 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![allow(missing_docs)]
-#![allow(non_camel_case_types)]
-#![allow(non_snake_case)]
+#![allow(missing_docs, bad_style)]
 
 use prelude::v1::*;
 
@@ -20,7 +18,6 @@ use num::Zero;
 use os::windows::ffi::{OsStrExt, OsStringExt};
 use path::PathBuf;
 use time::Duration;
-use alloc::oom;
 
 #[macro_use] pub mod compat;
 
@@ -43,25 +40,26 @@ pub mod thread_local;
 pub mod time;
 pub mod stdio;
 
-// See comment in sys/unix/mod.rs
-fn oom_handler() -> ! {
-    use intrinsics;
-    use ptr;
-    let msg = "fatal runtime error: out of memory\n";
-    unsafe {
-        // WriteFile silently fails if it is passed an invalid handle, so there
-        // is no need to check the result of GetStdHandle.
-        c::WriteFile(c::GetStdHandle(c::STD_ERROR_HANDLE),
-                     msg.as_ptr() as c::LPVOID,
-                     msg.len() as c::DWORD,
-                     ptr::null_mut(),
-                     ptr::null_mut());
-        intrinsics::abort();
-    }
-}
-
+#[cfg(not(test))]
 pub fn init() {
-    oom::set_oom_handler(oom_handler);
+    ::alloc::oom::set_oom_handler(oom_handler);
+
+    // See comment in sys/unix/mod.rs
+    fn oom_handler() -> ! {
+        use intrinsics;
+        use ptr;
+        let msg = "fatal runtime error: out of memory\n";
+        unsafe {
+            // WriteFile silently fails if it is passed an invalid handle, so
+            // there is no need to check the result of GetStdHandle.
+            c::WriteFile(c::GetStdHandle(c::STD_ERROR_HANDLE),
+                         msg.as_ptr() as c::LPVOID,
+                         msg.len() as c::DWORD,
+                         ptr::null_mut(),
+                         ptr::null_mut());
+            intrinsics::abort();
+        }
+    }
 }
 
 pub fn decode_error_kind(errno: i32) -> ErrorKind {
diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs
index e0f8d6f9df9..4ab9f678d06 100644
--- a/src/libstd/sys/windows/process.rs
+++ b/src/libstd/sys/windows/process.rs
@@ -386,7 +386,6 @@ impl Stdio {
 #[cfg(test)]
 mod tests {
     use prelude::v1::*;
-    use str;
     use ffi::{OsStr, OsString};
     use super::make_command_line;
 
diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs
index 01317bec0de..4a406d70e63 100644
--- a/src/libstd/sys/windows/stack_overflow.rs
+++ b/src/libstd/sys/windows/stack_overflow.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![cfg_attr(test, allow(dead_code))]
+
 use sys_common::util::report_overflow;
 use sys::c;
 
diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs
index 1ba85867563..b18772c0c24 100644
--- a/src/libstd/sys/windows/thread.rs
+++ b/src/libstd/sys/windows/thread.rs
@@ -83,6 +83,7 @@ impl Thread {
     pub fn into_handle(self) -> Handle { self.handle }
 }
 
+#[cfg_attr(test, allow(dead_code))]
 pub mod guard {
     pub unsafe fn current() -> Option<usize> { None }
     pub unsafe fn init() -> Option<usize> { None }
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 67817ee0740..c31cd5a06ce 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -3149,7 +3149,6 @@ mod tests {
     use super::*;
 
     use ast;
-    use ast_util;
     use codemap;
     use parse::token;