diff options
| author | bors <bors@rust-lang.org> | 2015-12-30 07:35:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-12-30 07:35:10 +0000 |
| commit | a06bb977d86dcfe786d4265f4807a11c39b51141 (patch) | |
| tree | 27a2b4e75bd918cbe2276a3e9a26eac34825e72f /src/libstd/sys | |
| parent | 6e2a64b57a74f35bef215972adf1b803cff288bd (diff) | |
| parent | e27cbeff370897b8450caa204c08049651a10c13 (diff) | |
| download | rust-a06bb977d86dcfe786d4265f4807a11c39b51141.tar.gz rust-a06bb977d86dcfe786d4265f4807a11c39b51141.zip | |
Auto merge of #30458 - fhahn:fix-warnings-tests-stdlib, r=sanxiyn
This PR siliences some warnings when compiling stdlib with --test. Mostly remove some unused imports and added a few `#[allow(..)]`. I also marked some signal handling functions with `#[cfg(not(test))]`, because they are only called through `rt::lang_start`, which is also marked as `#[cfg(not(test))]`
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/common/io.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/common/remutex.rs | 10 | ||||
| -rw-r--r-- | src/libstd/sys/common/wtf8.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/mod.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sys/unix/stack_overflow.rs | 11 |
6 files changed, 19 insertions, 16 deletions
diff --git a/src/libstd/sys/common/io.rs b/src/libstd/sys/common/io.rs index 151d853fc9f..9f2f0df3a64 100644 --- a/src/libstd/sys/common/io.rs +++ b/src/libstd/sys/common/io.rs @@ -133,7 +133,7 @@ mod tests { b.iter(|| { let mut lr = repeat(1).take(10000000); let mut vec = Vec::with_capacity(1024); - unsafe { read_to_end_uninitialized(&mut lr, &mut vec) }; + unsafe { read_to_end_uninitialized(&mut lr, &mut vec) } }); } } diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs index f3f21e47a14..31caa68c4b7 100644 --- a/src/libstd/sys/common/remutex.rs +++ b/src/libstd/sys/common/remutex.rs @@ -167,7 +167,6 @@ mod tests { use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; use cell::RefCell; use sync::Arc; - use boxed; use thread; #[test] @@ -208,13 +207,13 @@ mod tests { fn trylock_works() { let m = Arc::new(ReentrantMutex::new(())); let m2 = m.clone(); - let lock = m.try_lock().unwrap(); - let lock2 = m.try_lock().unwrap(); + let _lock = m.try_lock().unwrap(); + let _lock2 = m.try_lock().unwrap(); thread::spawn(move || { let lock = m2.try_lock(); assert!(lock.is_err()); }).join().unwrap(); - let lock3 = m.try_lock().unwrap(); + let _lock3 = m.try_lock().unwrap(); } pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell<u32>>); @@ -233,9 +232,8 @@ mod tests { *lock.borrow_mut() = 1; let lock2 = mc.lock().unwrap(); *lock.borrow_mut() = 2; - let answer = Answer(lock2); + let _answer = Answer(lock2); panic!("What the answer to my lifetimes dilemma is?"); - drop(answer); }).join(); assert!(result.is_err()); let r = m.lock().err().unwrap().into_inner(); diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 2e092d5f770..bc997af3a27 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -1067,7 +1067,7 @@ mod tests { #[test] fn wtf8buf_show_str() { let text = "a\té 💩\r"; - let mut string = Wtf8Buf::from_str(text); + let string = Wtf8Buf::from_str(text); assert_eq!(format!("{:?}", text), format!("{:?}", string)); } diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 68b0c3d6b0e..929fd2fb0c3 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -45,7 +45,7 @@ pub mod thread_local; pub mod time; pub mod stdio; -#[cfg(not(target_os = "nacl"))] +#[cfg(not(any(target_os = "nacl", test)))] pub fn init() { use libc::signal; // By default, some platforms will send a *signal* when an EPIPE error @@ -59,7 +59,8 @@ pub fn init() { assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0); } } -#[cfg(target_os = "nacl")] + +#[cfg(all(target_os = "nacl", not(test)))] pub fn init() { } pub fn decode_error_kind(errno: i32) -> ErrorKind { diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 407fcb0a1b8..495f45f5c7e 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -462,8 +462,7 @@ mod tests { use mem; use ptr; use libc; - use slice; - use sys::{self, cvt, pipe}; + use sys::{self, cvt}; macro_rules! t { ($e:expr) => { @@ -482,6 +481,8 @@ mod tests { #[cfg(target_os = "android")] unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int { + use slice; + let raw = slice::from_raw_parts_mut(set as *mut u8, mem::size_of::<libc::sigset_t>()); let bit = (signum - 1) as usize; raw[bit / 8] |= 1 << (bit % 8); diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 9a7f98d24cd..776acd20b06 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -7,11 +7,13 @@ // <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; use self::imp::{make_handler, drop_handler}; -pub use self::imp::{init, cleanup}; +pub use self::imp::cleanup; +pub use self::imp::init; pub struct Handler { _data: *mut libc::c_void @@ -40,12 +42,11 @@ impl Drop for Handler { target_os = "openbsd"))] mod imp { use super::Handler; - use sys_common::util::report_overflow; use mem; use ptr; + use libc::{sigaltstack, SIGSTKSZ}; use libc::{sigaction, SIGBUS, SIG_DFL, - SA_SIGINFO, SA_ONSTACK, sigaltstack, - SIGSTKSZ, sighandler_t}; + SA_SIGINFO, SA_ONSTACK, sighandler_t}; use libc; use libc::{mmap, munmap}; use libc::{SIGSEGV, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON}; @@ -94,6 +95,8 @@ mod imp { unsafe extern fn signal_handler(signum: libc::c_int, info: *mut libc::siginfo_t, _data: *mut libc::c_void) { + use sys_common::util::report_overflow; + let guard = thread_info::stack_guard().unwrap_or(0); let addr = siginfo_si_addr(info) as usize; |
