1
Fork 0

Fix warnings during tests

The deny(warnings) attribute is now enabled for tests so we need to weed out
these warnings as well.
This commit is contained in:
Alex Crichton 2016-01-22 23:49:57 -08:00
parent 4b3c35509b
commit cb343c33ac
24 changed files with 137 additions and 141 deletions

View file

@ -15,7 +15,6 @@ use core::ops::Deref;
use core::result::Result::{Ok, Err}; use core::result::Result::{Ok, Err};
use core::clone::Clone; use core::clone::Clone;
use std::boxed;
use std::boxed::Box; use std::boxed::Box;
#[test] #[test]

View file

@ -75,31 +75,28 @@
#![feature(allocator)] #![feature(allocator)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(coerce_unsized)] #![feature(coerce_unsized)]
#![feature(const_fn)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![feature(drop_in_place)]
#![feature(dropck_parametricity)]
#![feature(fundamental)] #![feature(fundamental)]
#![feature(lang_items)] #![feature(lang_items)]
#![feature(needs_allocator)]
#![feature(optin_builtin_traits)] #![feature(optin_builtin_traits)]
#![feature(placement_in_syntax)] #![feature(placement_in_syntax)]
#![feature(placement_new_protocol)]
#![feature(raw)]
#![feature(shared)] #![feature(shared)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(unboxed_closures)] #![feature(unboxed_closures)]
#![feature(unique)] #![feature(unique)]
#![feature(unsafe_no_drop_flag, filling_drop)] #![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(dropck_parametricity)]
#![feature(unsize)] #![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 // Issue# 30592: Systematically use alloc_system during stage0 since jemalloc
// might be unavailable or disabled // might be unavailable or disabled
#![cfg_attr(stage0, feature(alloc_system))] #![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_attr(test, feature(test, rustc_private, box_heap))]
#[cfg(stage0)] #[cfg(stage0)]

View file

@ -56,7 +56,7 @@
#![feature(unicode)] #![feature(unicode)]
#![feature(unique)] #![feature(unique)]
#![feature(unsafe_no_drop_flag)] #![feature(unsafe_no_drop_flag)]
#![cfg_attr(test, feature(clone_from_slice, rand, test))] #![cfg_attr(test, feature(rand, test))]
#![no_std] #![no_std]

View file

@ -83,20 +83,14 @@
// Many of the usings in this module are only used in the test configuration. // 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. // 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 alloc::boxed::Box;
use core::clone::Clone;
use core::cmp::Ordering::{self, Greater, Less}; use core::cmp::Ordering::{self, Greater, Less};
use core::cmp::{self, Ord, PartialEq}; use core::cmp;
use core::iter::Iterator;
use core::marker::Sized;
use core::mem::size_of; use core::mem::size_of;
use core::mem; use core::mem;
use core::ops::FnMut;
use core::option::Option::{self, Some, None};
use core::ptr; use core::ptr;
use core::result::Result;
use core::slice as core_slice; use core::slice as core_slice;
use borrow::{Borrow, BorrowMut, ToOwned}; use borrow::{Borrow, BorrowMut, ToOwned};
@ -136,12 +130,7 @@ pub use self::hack::to_vec;
// `test_permutations` test // `test_permutations` test
mod hack { mod hack {
use alloc::boxed::Box; use alloc::boxed::Box;
use core::clone::Clone;
#[cfg(test)]
use core::iter::Iterator;
use core::mem; use core::mem;
#[cfg(test)]
use core::option::Option::{Some, None};
#[cfg(test)] #[cfg(test)]
use string::ToString; use string::ToString;

View file

@ -19,10 +19,6 @@
// It's cleaner to just turn off the unused_imports warning than to fix them. // It's cleaner to just turn off the unused_imports warning than to fix them.
#![allow(unused_imports)] #![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 as core_str;
use core::str::pattern::Pattern; use core::str::pattern::Pattern;
use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};

View file

@ -9,7 +9,6 @@
// except according to those terms. // except according to those terms.
use std::cmp::Ordering::{Equal, Greater, Less}; use std::cmp::Ordering::{Equal, Greater, Less};
use std::default::Default;
use std::mem; use std::mem;
use std::__rand::{Rng, thread_rng}; use std::__rand::{Rng, thread_rng};
use std::rc::Rc; use std::rc::Rc;

View file

@ -36,7 +36,7 @@
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![cfg_attr(test, feature(test, rand, rustc_private, iter_order_deprecated))] #![cfg_attr(test, feature(test, rand, rustc_private))]
#![allow(deprecated)] #![allow(deprecated)]

View file

@ -2606,7 +2606,6 @@ impl FromStr for Json {
mod tests { mod tests {
extern crate test; extern crate test;
use self::Animal::*; use self::Animal::*;
use self::DecodeEnum::*;
use self::test::Bencher; use self::test::Bencher;
use {Encodable, Decodable}; use {Encodable, Decodable};
use super::Json::*; use super::Json::*;

View file

@ -16,7 +16,6 @@
reason = "API has not been scrutinized and is highly likely to \ reason = "API has not been scrutinized and is highly likely to \
either disappear or change", either disappear or change",
issue = "27810")] issue = "27810")]
#![rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")]
#![allow(missing_docs)] #![allow(missing_docs)]
#![allow(deprecated)] #![allow(deprecated)]
@ -26,6 +25,11 @@ use env;
use ffi::{CString, OsString}; use ffi::{CString, OsString};
use path::{Path, PathBuf}; 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 { pub struct DynamicLibrary {
handle: *mut u8 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 { impl DynamicLibrary {
/// Lazily open a dynamic library. When passed None it gives a /// Lazily open a dynamic library. When passed None it gives a
/// handle to the calling process /// handle to the calling process
@ -126,7 +135,6 @@ mod tests {
use prelude::v1::*; use prelude::v1::*;
use libc; use libc;
use mem; use mem;
use path::Path;
#[test] #[test]
#[cfg_attr(any(windows, #[cfg_attr(any(windows,
@ -167,6 +175,8 @@ mod tests {
target_os = "openbsd"))] target_os = "openbsd"))]
#[allow(deprecated)] #[allow(deprecated)]
fn test_errors_do_not_crash() { fn test_errors_do_not_crash() {
use path::Path;
// Open /dev/null as a library to get an error, and make sure // Open /dev/null as a library to get an error, and make sure
// that only causes an error, and not a crash. // that only causes an error, and not a crash.
let path = Path::new("/dev/null"); let path = Path::new("/dev/null");

View file

@ -1095,8 +1095,8 @@ mod tests {
thread::spawn(|| { thread::spawn(|| {
let mut writer = BufWriter::new(PanicWriter); let mut writer = BufWriter::new(PanicWriter);
writer.write(b"hello world"); let _ = writer.write(b"hello world");
writer.flush(); let _ = writer.flush();
}).join().err().unwrap(); }).join().err().unwrap();
assert_eq!(WRITES.load(Ordering::SeqCst), 1); assert_eq!(WRITES.load(Ordering::SeqCst), 1);

View file

@ -68,6 +68,7 @@ pub enum c_void {
} }
#[cfg(test)] #[cfg(test)]
#[allow(unused_imports)]
mod tests { mod tests {
use any::TypeId; use any::TypeId;
use libc; use libc;

View file

@ -3326,11 +3326,13 @@ mod tests {
"{:?}.ends_with({:?}), expected {:?}, got {:?}", $path1, $path2, "{:?}.ends_with({:?}), expected {:?}, got {:?}", $path1, $path2,
$ends_with, ends_with); $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; let exp: Option<&str> = $relative_from;
assert!(relative_from == exp, assert!(relative_from == exp,
"{:?}.relative_from({:?}), expected {:?}, got {:?}", $path1, $path2, "{:?}.strip_prefix({:?}), expected {:?}, got {:?}",
exp, relative_from); $path1, $path2, exp, relative_from);
}); });
); );

View file

@ -618,8 +618,8 @@ mod tests {
// FIXME(#10380) these tests should not all be ignored on android. // FIXME(#10380) these tests should not all be ignored on android.
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn smoke() { fn smoke() {
let p = Command::new("true").spawn(); let p = Command::new("true").spawn();
assert!(p.is_ok()); assert!(p.is_ok());
@ -627,8 +627,8 @@ mod tests {
assert!(p.wait().unwrap().success()); assert!(p.wait().unwrap().success());
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn smoke_failure() { fn smoke_failure() {
match Command::new("if-this-is-a-binary-then-the-world-has-ended").spawn() { match Command::new("if-this-is-a-binary-then-the-world-has-ended").spawn() {
Ok(..) => panic!(), Ok(..) => panic!(),
@ -636,8 +636,8 @@ mod tests {
} }
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn exit_reported_right() { fn exit_reported_right() {
let p = Command::new("false").spawn(); let p = Command::new("false").spawn();
assert!(p.is_ok()); assert!(p.is_ok());
@ -646,8 +646,9 @@ mod tests {
drop(p.wait()); drop(p.wait());
} }
#[cfg(all(unix, not(target_os="android")))]
#[test] #[test]
#[cfg(unix)]
#[cfg_attr(target_os = "android", ignore)]
fn signal_reported_right() { fn signal_reported_right() {
use os::unix::process::ExitStatusExt; use os::unix::process::ExitStatusExt;
@ -674,16 +675,16 @@ mod tests {
return ret; return ret;
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn stdout_works() { fn stdout_works() {
let mut cmd = Command::new("echo"); let mut cmd = Command::new("echo");
cmd.arg("foobar").stdout(Stdio::piped()); cmd.arg("foobar").stdout(Stdio::piped());
assert_eq!(run_output(cmd), "foobar\n"); assert_eq!(run_output(cmd), "foobar\n");
} }
#[cfg(all(unix, not(target_os="android")))]
#[test] #[test]
#[cfg_attr(any(windows, target_os = "android"), ignore)]
fn set_current_dir_works() { fn set_current_dir_works() {
let mut cmd = Command::new("/bin/sh"); let mut cmd = Command::new("/bin/sh");
cmd.arg("-c").arg("pwd") cmd.arg("-c").arg("pwd")
@ -692,8 +693,8 @@ mod tests {
assert_eq!(run_output(cmd), "/\n"); assert_eq!(run_output(cmd), "/\n");
} }
#[cfg(all(unix, not(target_os="android")))]
#[test] #[test]
#[cfg_attr(any(windows, target_os = "android"), ignore)]
fn stdin_works() { fn stdin_works() {
let mut p = Command::new("/bin/sh") let mut p = Command::new("/bin/sh")
.arg("-c").arg("read line; echo $line") .arg("-c").arg("read line; echo $line")
@ -709,8 +710,9 @@ mod tests {
} }
#[cfg(all(unix, not(target_os="android")))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
#[cfg(unix)]
fn uid_works() { fn uid_works() {
use os::unix::prelude::*; use os::unix::prelude::*;
use libc; use libc;
@ -722,8 +724,9 @@ mod tests {
assert!(p.wait().unwrap().success()); assert!(p.wait().unwrap().success());
} }
#[cfg(all(unix, not(target_os="android")))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
#[cfg(unix)]
fn uid_to_root_fails() { fn uid_to_root_fails() {
use os::unix::prelude::*; use os::unix::prelude::*;
use libc; use libc;
@ -734,8 +737,8 @@ mod tests {
assert!(Command::new("/bin/ls").uid(0).gid(0).spawn().is_err()); assert!(Command::new("/bin/ls").uid(0).gid(0).spawn().is_err());
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn test_process_status() { fn test_process_status() {
let mut status = Command::new("false").status().unwrap(); let mut status = Command::new("false").status().unwrap();
assert!(status.code() == Some(1)); assert!(status.code() == Some(1));
@ -752,8 +755,8 @@ mod tests {
} }
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn test_process_output_output() { fn test_process_output_output() {
let Output {status, stdout, stderr} let Output {status, stdout, stderr}
= Command::new("echo").arg("hello").output().unwrap(); = Command::new("echo").arg("hello").output().unwrap();
@ -764,8 +767,8 @@ mod tests {
assert_eq!(stderr, Vec::new()); assert_eq!(stderr, Vec::new());
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn test_process_output_error() { fn test_process_output_error() {
let Output {status, stdout, stderr} let Output {status, stdout, stderr}
= Command::new("mkdir").arg(".").output().unwrap(); = Command::new("mkdir").arg(".").output().unwrap();
@ -775,23 +778,23 @@ mod tests {
assert!(!stderr.is_empty()); assert!(!stderr.is_empty());
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn test_finish_once() { fn test_finish_once() {
let mut prog = Command::new("false").spawn().unwrap(); 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] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn test_finish_twice() { fn test_finish_twice() {
let mut prog = Command::new("false").spawn().unwrap(); let mut prog = Command::new("false").spawn().unwrap();
assert!(prog.wait().unwrap().code() == Some(1)); assert!(prog.wait().unwrap().code() == Some(1));
assert!(prog.wait().unwrap().code() == Some(1)); assert!(prog.wait().unwrap().code() == Some(1));
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
#[cfg_attr(target_os = "android", ignore)]
fn test_wait_with_output_once() { fn test_wait_with_output_once() {
let prog = Command::new("echo").arg("hello").stdout(Stdio::piped()) let prog = Command::new("echo").arg("hello").stdout(Stdio::piped())
.spawn().unwrap(); .spawn().unwrap();
@ -821,7 +824,6 @@ mod tests {
cmd cmd
} }
#[cfg(not(target_os="android"))]
#[test] #[test]
fn test_inherit_env() { fn test_inherit_env() {
use env; use env;
@ -830,36 +832,22 @@ mod tests {
let output = String::from_utf8(result.stdout).unwrap(); let output = String::from_utf8(result.stdout).unwrap();
for (ref k, ref v) in env::vars() { 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 // Windows has hidden environment variables whose names start with
// equals signs (`=`). Those do not show up in the output of the // equals signs (`=`). Those do not show up in the output of the
// `set` command. // `set` command.
assert!((cfg!(windows) && k.starts_with("=")) || assert!((cfg!(windows) && k.starts_with("=")) ||
k.starts_with("DYLD") || k.starts_with("DYLD") ||
output.contains(&format!("{}={}", *k, *v)), output.contains(&format!("{}={}", *k, *v)) ||
output.contains(&format!("{}='{}'", *k, *v)),
"output doesn't contain `{}={}`\n{}", "output doesn't contain `{}={}`\n{}",
k, v, output); 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] #[test]
fn test_override_env() { fn test_override_env() {

View file

@ -789,7 +789,7 @@ mod tests {
fn fmt_debug_handle() { fn fmt_debug_handle() {
let (_, rx) = channel::<i32>(); let (_, rx) = channel::<i32>();
let sel = Select::new(); let sel = Select::new();
let mut handle = sel.handle(&rx); let handle = sel.handle(&rx);
assert_eq!(format!("{:?}", handle), "Handle { .. }"); assert_eq!(format!("{:?}", handle), "Handle { .. }");
} }
} }

View file

@ -12,9 +12,6 @@
reason = "the interaction between semaphores and the acquisition/release \ reason = "the interaction between semaphores and the acquisition/release \
of resources is currently unclear", of resources is currently unclear",
issue = "27798")] issue = "27798")]
#![rustc_deprecated(since = "1.7.0",
reason = "easily confused with system semaphores and not \
used enough to pull its weight")]
#![allow(deprecated)] #![allow(deprecated)]
use ops::Drop; use ops::Drop;
@ -49,6 +46,13 @@ use sync::{Mutex, Condvar};
/// // Release our initially acquired resource /// // Release our initially acquired resource
/// sem.release(); /// 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 { pub struct Semaphore {
lock: Mutex<isize>, lock: Mutex<isize>,
cvar: Condvar, cvar: Condvar,
@ -56,10 +60,24 @@ pub struct Semaphore {
/// An RAII guard which will release a resource acquired from a semaphore when /// An RAII guard which will release a resource acquired from a semaphore when
/// dropped. /// 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> { pub struct SemaphoreGuard<'a> {
sem: &'a Semaphore, 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 { impl Semaphore {
/// Creates a new semaphore with the initial count specified. /// Creates a new semaphore with the initial count specified.
/// ///

View file

@ -8,14 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![allow(missing_docs)] #![allow(missing_docs, bad_style)]
#![allow(non_camel_case_types)]
use io::{self, ErrorKind}; use io::{self, ErrorKind};
use libc; use libc;
use num::One; use num::One;
use ops::Neg; use ops::Neg;
use alloc::oom;
#[cfg(target_os = "android")] pub use os::android as platform; #[cfg(target_os = "android")] pub use os::android as platform;
#[cfg(target_os = "bitrig")] pub use os::bitrig 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 time;
pub mod stdio; pub mod stdio;
// A nicer handler for out-of-memory situations than the default one. This one #[cfg(not(test))]
// 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)))]
pub fn init() { pub fn init() {
use libc::signal; use alloc::oom;
// By default, some platforms will send a *signal* when an EPIPE error // By default, some platforms will send a *signal* when an EPIPE error
// would otherwise be delivered. This runtime doesn't install a SIGPIPE // would otherwise be delivered. This runtime doesn't install a SIGPIPE
// handler, causing it to kill the program, which isn't exactly what we // 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 // Hence, we set SIGPIPE to ignore when the program starts up in order
// to prevent this problem. // to prevent this problem.
unsafe { unsafe {
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0); reset_sigpipe();
} }
oom::set_oom_handler(oom_handler); oom::set_oom_handler(oom_handler);
}
#[cfg(all(target_os = "nacl", not(test)))] // A nicer handler for out-of-memory situations than the default one. This
pub fn init() { // one prints a message to stderr before aborting. It is critical that this
oom::set_oom_handler(oom_handler); // 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 { pub fn decode_error_kind(errno: i32) -> ErrorKind {

View file

@ -7,6 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![cfg_attr(test, allow(dead_code))] #![cfg_attr(test, allow(dead_code))]
use libc; use libc;

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![allow(dead_code)]
use prelude::v1::*; use prelude::v1::*;
use alloc::boxed::FnBox; use alloc::boxed::FnBox;
@ -174,6 +172,7 @@ impl Drop for Thread {
not(target_os = "bitrig"), not(target_os = "bitrig"),
not(all(target_os = "netbsd", not(target_vendor = "rumprun"))), not(all(target_os = "netbsd", not(target_vendor = "rumprun"))),
not(target_os = "openbsd")))] not(target_os = "openbsd")))]
#[cfg_attr(test, allow(dead_code))]
pub mod guard { pub mod guard {
pub unsafe fn current() -> Option<usize> { None } pub unsafe fn current() -> Option<usize> { None }
pub unsafe fn init() -> Option<usize> { None } pub unsafe fn init() -> Option<usize> { None }
@ -185,15 +184,13 @@ pub mod guard {
target_os = "bitrig", target_os = "bitrig",
all(target_os = "netbsd", not(target_vendor = "rumprun")), all(target_os = "netbsd", not(target_vendor = "rumprun")),
target_os = "openbsd"))] target_os = "openbsd"))]
#[allow(unused_imports)] #[cfg_attr(test, allow(dead_code))]
pub mod guard { pub mod guard {
use prelude::v1::*; use prelude::v1::*;
use libc::{self, pthread_t}; use libc;
use libc::mmap; use libc::mmap;
use libc::{PROT_NONE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED}; use libc::{PROT_NONE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED};
use mem;
use ptr;
use sys::os; use sys::os;
#[cfg(any(target_os = "macos", #[cfg(any(target_os = "macos",
@ -206,10 +203,10 @@ pub mod guard {
#[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))] #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
unsafe fn get_stack_start() -> Option<*mut libc::c_void> { unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
let mut ret = None; 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); assert_eq!(libc::pthread_attr_init(&mut attr), 0);
if libc::pthread_getattr_np(libc::pthread_self(), &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; let mut stacksize = 0;
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
&mut stacksize), 0); &mut stacksize), 0);
@ -265,7 +262,7 @@ pub mod guard {
#[cfg(any(target_os = "openbsd", target_os = "bitrig"))] #[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
pub unsafe fn current() -> Option<usize> { 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(), assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(),
&mut current_stack), 0); &mut current_stack), 0);
@ -282,7 +279,7 @@ pub mod guard {
#[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))] #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
pub unsafe fn current() -> Option<usize> { pub unsafe fn current() -> Option<usize> {
let mut ret = None; 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); assert_eq!(libc::pthread_attr_init(&mut attr), 0);
if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 { if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 {
let mut guardsize = 0; let mut guardsize = 0;
@ -290,7 +287,7 @@ pub mod guard {
if guardsize == 0 { if guardsize == 0 {
panic!("there is no guard page"); panic!("there is no guard page");
} }
let mut stackaddr = ptr::null_mut(); let mut stackaddr = ::ptr::null_mut();
let mut size = 0; let mut size = 0;
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
&mut size), 0); &mut size), 0);

View file

@ -639,7 +639,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
fn directory_junctions_are_directories() { fn directory_junctions_are_directories() {
use ffi::OsStr; use ffi::OsStr;
use env; use env;
use rand::{self, StdRng, Rng}; use rand::{self, Rng};
use vec::Vec; use vec::Vec;
macro_rules! t { macro_rules! t {
@ -683,7 +683,7 @@ fn directory_junctions_are_directories() {
let mut data = [0u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; let mut data = [0u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
let mut db = data.as_mut_ptr() let mut db = data.as_mut_ptr()
as *mut c::REPARSE_MOUNTPOINT_DATA_BUFFER; 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 mut i = 0;
let v = br"\??\"; let v = br"\??\";
let v = v.iter().map(|x| *x as u16); let v = v.iter().map(|x| *x as u16);

View file

@ -8,9 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![allow(missing_docs)] #![allow(missing_docs, bad_style)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use prelude::v1::*; use prelude::v1::*;
@ -20,7 +18,6 @@ use num::Zero;
use os::windows::ffi::{OsStrExt, OsStringExt}; use os::windows::ffi::{OsStrExt, OsStringExt};
use path::PathBuf; use path::PathBuf;
use time::Duration; use time::Duration;
use alloc::oom;
#[macro_use] pub mod compat; #[macro_use] pub mod compat;
@ -43,25 +40,26 @@ pub mod thread_local;
pub mod time; pub mod time;
pub mod stdio; pub mod stdio;
// See comment in sys/unix/mod.rs #[cfg(not(test))]
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 init() { 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 { pub fn decode_error_kind(errno: i32) -> ErrorKind {

View file

@ -386,7 +386,6 @@ impl Stdio {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use prelude::v1::*; use prelude::v1::*;
use str;
use ffi::{OsStr, OsString}; use ffi::{OsStr, OsString};
use super::make_command_line; use super::make_command_line;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![cfg_attr(test, allow(dead_code))]
use sys_common::util::report_overflow; use sys_common::util::report_overflow;
use sys::c; use sys::c;

View file

@ -83,6 +83,7 @@ impl Thread {
pub fn into_handle(self) -> Handle { self.handle } pub fn into_handle(self) -> Handle { self.handle }
} }
#[cfg_attr(test, allow(dead_code))]
pub mod guard { pub mod guard {
pub unsafe fn current() -> Option<usize> { None } pub unsafe fn current() -> Option<usize> { None }
pub unsafe fn init() -> Option<usize> { None } pub unsafe fn init() -> Option<usize> { None }

View file

@ -3149,7 +3149,6 @@ mod tests {
use super::*; use super::*;
use ast; use ast;
use ast_util;
use codemap; use codemap;
use parse::token; use parse::token;