about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/common/backtrace.rs8
-rw-r--r--src/libstd/sys/common/helper_thread.rs11
-rw-r--r--src/libstd/sys/common/net.rs44
-rw-r--r--src/libstd/sys/common/thread_info.rs4
-rw-r--r--src/libstd/sys/unix/backtrace.rs6
-rw-r--r--src/libstd/sys/unix/c.rs18
-rw-r--r--src/libstd/sys/unix/fs.rs2
-rw-r--r--src/libstd/sys/unix/mod.rs3
-rw-r--r--src/libstd/sys/unix/os.rs6
-rw-r--r--src/libstd/sys/unix/pipe.rs2
-rw-r--r--src/libstd/sys/unix/process.rs8
-rw-r--r--src/libstd/sys/unix/stack_overflow.rs4
-rw-r--r--src/libstd/sys/unix/sync.rs28
-rw-r--r--src/libstd/sys/unix/timer.rs10
-rw-r--r--src/libstd/sys/windows/backtrace.rs24
-rw-r--r--src/libstd/sys/windows/c.rs14
-rw-r--r--src/libstd/sys/windows/fs.rs4
-rw-r--r--src/libstd/sys/windows/mod.rs4
-rw-r--r--src/libstd/sys/windows/os.rs29
-rw-r--r--src/libstd/sys/windows/process.rs5
-rw-r--r--src/libstd/sys/windows/stack_overflow.rs2
-rw-r--r--src/libstd/sys/windows/timer.rs5
-rw-r--r--src/libstd/sys/windows/tty.rs21
23 files changed, 157 insertions, 105 deletions
diff --git a/src/libstd/sys/common/backtrace.rs b/src/libstd/sys/common/backtrace.rs
index c1aace764fc..d4039fd96ff 100644
--- a/src/libstd/sys/common/backtrace.rs
+++ b/src/libstd/sys/common/backtrace.rs
@@ -115,10 +115,10 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
 
                         // in theory we can demangle any Unicode code point, but
                         // for simplicity we just catch the common ones.
-                        "$x20" => " ",
-                        "$x27" => "'",
-                        "$x5b" => "[",
-                        "$x5d" => "]"
+                        "$u{20}" => " ",
+                        "$u{27}" => "'",
+                        "$u{5b}" => "[",
+                        "$u{5d}" => "]"
                     )
                 } else {
                     let idx = match rest.find('$') {
diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs
index b9dc5f0e398..1ce42aaa175 100644
--- a/src/libstd/sys/common/helper_thread.rs
+++ b/src/libstd/sys/common/helper_thread.rs
@@ -23,6 +23,7 @@
 use prelude::v1::*;
 
 use cell::UnsafeCell;
+use comm::{channel, Sender, Receiver};
 use mem;
 use rt;
 use sync::{StaticMutex, StaticCondvar};
@@ -84,7 +85,7 @@ impl<M: Send> Helper<M> {
         F: FnOnce() -> T,
     {
         unsafe {
-            let _guard = self.lock.lock();
+            let _guard = self.lock.lock().unwrap();
             if !*self.initialized.get() {
                 let (tx, rx) = channel();
                 *self.chan.get() = mem::transmute(box tx);
@@ -96,7 +97,7 @@ impl<M: Send> Helper<M> {
                 let t = f();
                 Thread::spawn(move |:| {
                     helper(receive.0, rx, t);
-                    let _g = self.lock.lock();
+                    let _g = self.lock.lock().unwrap();
                     *self.shutdown.get() = true;
                     self.cond.notify_one()
                 }).detach();
@@ -112,7 +113,7 @@ impl<M: Send> Helper<M> {
     /// This is only valid if the worker thread has previously booted
     pub fn send(&'static self, msg: M) {
         unsafe {
-            let _guard = self.lock.lock();
+            let _guard = self.lock.lock().unwrap();
 
             // Must send and *then* signal to ensure that the child receives the
             // message. Otherwise it could wake up and go to sleep before we
@@ -128,7 +129,7 @@ impl<M: Send> Helper<M> {
             // Shut down, but make sure this is done inside our lock to ensure
             // that we'll always receive the exit signal when the thread
             // returns.
-            let guard = self.lock.lock();
+            let mut guard = self.lock.lock().unwrap();
 
             // Close the channel by destroying it
             let chan: Box<Sender<M>> = mem::transmute(*self.chan.get());
@@ -138,7 +139,7 @@ impl<M: Send> Helper<M> {
 
             // Wait for the child to exit
             while !*self.shutdown.get() {
-                self.cond.wait(&guard);
+                guard = self.cond.wait(guard).unwrap();
             }
             drop(guard);
 
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs
index 9ab5077ae79..cb0c5581abd 100644
--- a/src/libstd/sys/common/net.rs
+++ b/src/libstd/sys/common/net.rs
@@ -17,6 +17,7 @@ use io::net::addrinfo;
 use io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr};
 use io::{IoResult, IoError};
 use libc::{mod, c_char, c_int};
+use c_str::CString;
 use mem;
 use num::Int;
 use ptr::{mod, null, null_mut};
@@ -269,7 +270,7 @@ pub fn get_host_addresses(host: Option<&str>, servname: Option<&str>,
     // Collect all the results we found
     let mut addrs = Vec::new();
     let mut rp = res;
-    while rp.is_not_null() {
+    while !rp.is_null() {
         unsafe {
             let addr = try!(sockaddr_to_addr(mem::transmute((*rp).ai_addr),
                                              (*rp).ai_addrlen as uint));
@@ -291,6 +292,43 @@ pub fn get_host_addresses(host: Option<&str>, servname: Option<&str>,
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+// get_address_name
+////////////////////////////////////////////////////////////////////////////////
+
+extern "system" {
+    fn getnameinfo(sa: *const libc::sockaddr, salen: libc::socklen_t,
+        host: *mut c_char, hostlen: libc::size_t,
+        serv: *mut c_char, servlen: libc::size_t,
+        flags: c_int) -> c_int;
+}
+
+const NI_MAXHOST: uint = 1025;
+
+pub fn get_address_name(addr: IpAddr) -> Result<String, IoError> {
+    let addr = SocketAddr{ip: addr, port: 0};
+
+    let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() };
+    let len = addr_to_sockaddr(addr, &mut storage);
+
+    let mut hostbuf = [0 as c_char; NI_MAXHOST];
+
+    let res = unsafe {
+        getnameinfo(&storage as *const _ as *const libc::sockaddr, len,
+            hostbuf.as_mut_ptr(), NI_MAXHOST as libc::size_t,
+            ptr::null_mut(), 0,
+            0)
+    };
+
+    if res != 0 {
+        return Err(last_gai_error(res));
+    }
+
+    unsafe {
+        Ok(CString::new(hostbuf.as_ptr(), false).as_str().unwrap().to_string())
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
 // Timeout helpers
 //
 // The read/write functions below are the helpers for reading/writing a socket
@@ -669,7 +707,7 @@ impl TcpStream {
     fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
         let ret = Guard {
             fd: self.fd(),
-            guard: self.inner.lock.lock(),
+            guard: self.inner.lock.lock().unwrap(),
         };
         assert!(set_nonblocking(self.fd(), true).is_ok());
         ret
@@ -808,7 +846,7 @@ impl UdpSocket {
     fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
         let ret = Guard {
             fd: self.fd(),
-            guard: self.inner.lock.lock(),
+            guard: self.inner.lock.lock().unwrap(),
         };
         assert!(set_nonblocking(self.fd(), true).is_ok());
         ret
diff --git a/src/libstd/sys/common/thread_info.rs b/src/libstd/sys/common/thread_info.rs
index dc21feb17a8..8c76eb1504d 100644
--- a/src/libstd/sys/common/thread_info.rs
+++ b/src/libstd/sys/common/thread_info.rs
@@ -26,13 +26,13 @@ struct ThreadInfo {
 thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(None) }
 
 impl ThreadInfo {
-    fn with<R>(f: |&mut ThreadInfo| -> R) -> R {
+    fn with<R, F>(f: F) -> R where F: FnOnce(&mut ThreadInfo) -> R {
         if THREAD_INFO.destroyed() {
             panic!("Use of std::thread::Thread::current() is not possible after \
                     the thread's local data has been destroyed");
         }
 
-        THREAD_INFO.with(|c| {
+        THREAD_INFO.with(move |c| {
             if c.borrow().is_none() {
                 *c.borrow_mut() = Some(ThreadInfo {
                     stack_bounds: (0, 0),
diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs
index 983d0e5fa14..9e26475f814 100644
--- a/src/libstd/sys/unix/backtrace.rs
+++ b/src/libstd/sys/unix/backtrace.rs
@@ -123,7 +123,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
     try!(writeln!(w, "stack backtrace:"));
     // 100 lines should be enough
     const SIZE: uint = 100;
-    let mut buf: [*mut libc::c_void, ..SIZE] = unsafe {mem::zeroed()};
+    let mut buf: [*mut libc::c_void; SIZE] = unsafe {mem::zeroed()};
     let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as uint};
 
     // skipping the first one as it is write itself
@@ -244,7 +244,7 @@ fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
     use iter::{Iterator, IteratorExt};
     use os;
     use path::GenericPath;
-    use ptr::RawPtr;
+    use ptr::PtrExt;
     use ptr;
     use slice::SliceExt;
 
@@ -320,7 +320,7 @@ fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
     //        tested if this is required or not.
     unsafe fn init_state() -> *mut backtrace_state {
         static mut STATE: *mut backtrace_state = 0 as *mut backtrace_state;
-        static mut LAST_FILENAME: [libc::c_char, ..256] = [0, ..256];
+        static mut LAST_FILENAME: [libc::c_char; 256] = [0; 256];
         if !STATE.is_null() { return STATE }
         let selfname = if cfg!(target_os = "freebsd") ||
                           cfg!(target_os = "dragonfly") {
diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs
index a4ebcbd25d0..1bb8ed78177 100644
--- a/src/libstd/sys/unix/c.rs
+++ b/src/libstd/sys/unix/c.rs
@@ -94,7 +94,7 @@ mod select {
 
     #[repr(C)]
     pub struct fd_set {
-        fds_bits: [i32, ..(FD_SETSIZE / 32)]
+        fds_bits: [i32; (FD_SETSIZE / 32)]
     }
 
     pub fn fd_set(set: &mut fd_set, fd: i32) {
@@ -115,7 +115,7 @@ mod select {
     #[repr(C)]
     pub struct fd_set {
         // FIXME: shouldn't this be a c_ulong?
-        fds_bits: [libc::uintptr_t, ..(FD_SETSIZE / uint::BITS)]
+        fds_bits: [libc::uintptr_t; (FD_SETSIZE / uint::BITS)]
     }
 
     pub fn fd_set(set: &mut fd_set, fd: i32) {
@@ -168,13 +168,13 @@ mod signal {
     #[repr(C)]
     #[cfg(target_word_size = "32")]
     pub struct sigset_t {
-        __val: [libc::c_ulong, ..32],
+        __val: [libc::c_ulong; 32],
     }
 
     #[repr(C)]
     #[cfg(target_word_size = "64")]
     pub struct sigset_t {
-        __val: [libc::c_ulong, ..16],
+        __val: [libc::c_ulong; 16],
     }
 }
 
@@ -211,15 +211,15 @@ mod signal {
         pub sa_handler: extern fn(libc::c_int),
         pub sa_mask: sigset_t,
         sa_restorer: *mut libc::c_void,
-        sa_resv: [libc::c_int, ..1],
+        sa_resv: [libc::c_int; 1],
     }
 
-    impl ::kinds::Send for sigaction { }
-    impl ::kinds::Sync for sigaction { }
+    unsafe impl ::kinds::Send for sigaction { }
+    unsafe impl ::kinds::Sync for sigaction { }
 
     #[repr(C)]
     pub struct sigset_t {
-        __val: [libc::c_ulong, ..32],
+        __val: [libc::c_ulong; 32],
     }
 }
 
@@ -244,7 +244,7 @@ mod signal {
     #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
     #[repr(C)]
     pub struct sigset_t {
-        bits: [u32, ..4],
+        bits: [u32; 4],
     }
 
     // This structure has more fields, but we're not all that interested in
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index d537579d453..e3e0b279c12 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -371,7 +371,7 @@ mod tests {
         let mut writer = FileDesc::new(writer, true);
 
         writer.write(b"test").ok().unwrap();
-        let mut buf = [0u8, ..4];
+        let mut buf = [0u8; 4];
         match reader.read(&mut buf) {
             Ok(4) => {
                 assert_eq!(buf[0], 't' as u8);
diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs
index 15dad810756..4199cbc1bb9 100644
--- a/src/libstd/sys/unix/mod.rs
+++ b/src/libstd/sys/unix/mod.rs
@@ -56,6 +56,7 @@ pub mod udp;
 
 pub mod addrinfo {
     pub use sys_common::net::get_host_addresses;
+    pub use sys_common::net::get_address_name;
 }
 
 // FIXME: move these to c module
@@ -109,6 +110,8 @@ pub fn decode_error(errno: i32) -> IoError {
              "file descriptor is not a TTY"),
         libc::ETIMEDOUT => (io::TimedOut, "operation timed out"),
         libc::ECANCELED => (io::TimedOut, "operation aborted"),
+        libc::consts::os::posix88::EEXIST =>
+            (io::PathAlreadyExists, "path already exists"),
 
         // These two constants can have the same value on some systems,
         // but different values on others, so we can't use a match
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index a221a6bc15b..6d145e47516 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -101,7 +101,7 @@ pub fn error_string(errno: i32) -> String {
         }
     }
 
-    let mut buf = [0 as c_char, ..TMPBUF_SZ];
+    let mut buf = [0 as c_char; TMPBUF_SZ];
 
     let p = buf.as_mut_ptr();
     unsafe {
@@ -114,7 +114,7 @@ pub fn error_string(errno: i32) -> String {
 }
 
 pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
-    let mut fds = [0, ..2];
+    let mut fds = [0; 2];
     if libc::pipe(fds.as_mut_ptr()) == 0 {
         Ok((FileDesc::new(fds[0], true), FileDesc::new(fds[1], true)))
     } else {
@@ -125,7 +125,7 @@ pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
 pub fn getcwd() -> IoResult<Path> {
     use c_str::CString;
 
-    let mut buf = [0 as c_char, ..BUF_BYTES];
+    let mut buf = [0 as c_char; BUF_BYTES];
     unsafe {
         if libc::getcwd(buf.as_mut_ptr(), buf.len() as libc::size_t).is_null() {
             Err(IoError::last_error())
diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs
index 6954866257e..e46814ef4a2 100644
--- a/src/libstd/sys/unix/pipe.rs
+++ b/src/libstd/sys/unix/pipe.rs
@@ -145,7 +145,7 @@ impl UnixStream {
     fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
         let ret = Guard {
             fd: self.fd(),
-            guard: unsafe { self.inner.lock.lock() },
+            guard: unsafe { self.inner.lock.lock().unwrap() },
         };
         assert!(set_nonblocking(self.fd(), true).is_ok());
         ret
diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs
index a11fe3487a8..af09bf4fbd0 100644
--- a/src/libstd/sys/unix/process.rs
+++ b/src/libstd/sys/unix/process.rs
@@ -121,7 +121,7 @@ impl Process {
 
                     let p = Process{ pid: pid };
                     drop(output);
-                    let mut bytes = [0, ..8];
+                    let mut bytes = [0; 8];
                     return match input.read(&mut bytes) {
                         Ok(8) => {
                             assert!(combine(CLOEXEC_MSG_FOOTER) == combine(bytes.slice(4, 8)),
@@ -196,7 +196,7 @@ impl Process {
                 // up /dev/null into that file descriptor. Otherwise, the first file
                 // descriptor opened up in the child would be numbered as one of the
                 // stdio file descriptors, which is likely to wreak havoc.
-                let setup = |src: Option<P>, dst: c_int| {
+                let setup = |&: src: Option<P>, dst: c_int| {
                     let src = match src {
                         None => {
                             let flags = if dst == libc::STDIN_FILENO {
@@ -349,7 +349,7 @@ impl Process {
         // handler we're going to start receiving signals.
         fn register_sigchld() -> (libc::c_int, c::sigaction) {
             unsafe {
-                let mut pipes = [0, ..2];
+                let mut pipes = [0; 2];
                 assert_eq!(libc::pipe(pipes.as_mut_ptr()), 0);
                 set_nonblocking(pipes[0], true).ok().unwrap();
                 set_nonblocking(pipes[1], true).ok().unwrap();
@@ -483,7 +483,7 @@ impl Process {
         fn drain(fd: libc::c_int) -> bool {
             let mut ret = false;
             loop {
-                let mut buf = [0u8, ..1];
+                let mut buf = [0u8; 1];
                 match unsafe {
                     libc::read(fd, buf.as_mut_ptr() as *mut libc::c_void,
                                buf.len() as libc::size_t)
diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs
index bcbbb8766b7..95ab9b459d6 100644
--- a/src/libstd/sys/unix/stack_overflow.rs
+++ b/src/libstd/sys/unix/stack_overflow.rs
@@ -184,12 +184,12 @@ mod imp {
         #[cfg(target_word_size = "32")]
         #[repr(C)]
         pub struct sigset_t {
-            __val: [libc::c_ulong, ..32],
+            __val: [libc::c_ulong; 32],
         }
         #[cfg(target_word_size = "64")]
         #[repr(C)]
         pub struct sigset_t {
-            __val: [libc::c_ulong, ..16],
+            __val: [libc::c_ulong; 16],
         }
 
         #[repr(C)]
diff --git a/src/libstd/sys/unix/sync.rs b/src/libstd/sys/unix/sync.rs
index 007826b4b9d..77c5582d8a4 100644
--- a/src/libstd/sys/unix/sync.rs
+++ b/src/libstd/sys/unix/sync.rs
@@ -86,30 +86,30 @@ mod os {
     #[repr(C)]
     pub struct pthread_mutex_t {
         __sig: libc::c_long,
-        __opaque: [u8, ..__PTHREAD_MUTEX_SIZE__],
+        __opaque: [u8; __PTHREAD_MUTEX_SIZE__],
     }
     #[repr(C)]
     pub struct pthread_cond_t {
         __sig: libc::c_long,
-        __opaque: [u8, ..__PTHREAD_COND_SIZE__],
+        __opaque: [u8; __PTHREAD_COND_SIZE__],
     }
     #[repr(C)]
     pub struct pthread_rwlock_t {
         __sig: libc::c_long,
-        __opaque: [u8, ..__PTHREAD_RWLOCK_SIZE__],
+        __opaque: [u8; __PTHREAD_RWLOCK_SIZE__],
     }
 
     pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
         __sig: _PTHREAD_MUTEX_SIG_INIT,
-        __opaque: [0, ..__PTHREAD_MUTEX_SIZE__],
+        __opaque: [0; __PTHREAD_MUTEX_SIZE__],
     };
     pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
         __sig: _PTHREAD_COND_SIG_INIT,
-        __opaque: [0, ..__PTHREAD_COND_SIZE__],
+        __opaque: [0; __PTHREAD_COND_SIZE__],
     };
     pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
         __sig: _PTHREAD_RWLOCK_SIG_INIT,
-        __opaque: [0, ..__PTHREAD_RWLOCK_SIZE__],
+        __opaque: [0; __PTHREAD_RWLOCK_SIZE__],
     };
 }
 
@@ -145,30 +145,30 @@ mod os {
     #[repr(C)]
     pub struct pthread_mutex_t {
         __align: libc::c_longlong,
-        size: [u8, ..__SIZEOF_PTHREAD_MUTEX_T],
+        size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
     }
     #[repr(C)]
     pub struct pthread_cond_t {
         __align: libc::c_longlong,
-        size: [u8, ..__SIZEOF_PTHREAD_COND_T],
+        size: [u8; __SIZEOF_PTHREAD_COND_T],
     }
     #[repr(C)]
     pub struct pthread_rwlock_t {
         __align: libc::c_longlong,
-        size: [u8, ..__SIZEOF_PTHREAD_RWLOCK_T],
+        size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
     }
 
     pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
         __align: 0,
-        size: [0, ..__SIZEOF_PTHREAD_MUTEX_T],
+        size: [0; __SIZEOF_PTHREAD_MUTEX_T],
     };
     pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
         __align: 0,
-        size: [0, ..__SIZEOF_PTHREAD_COND_T],
+        size: [0; __SIZEOF_PTHREAD_COND_T],
     };
     pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
         __align: 0,
-        size: [0, ..__SIZEOF_PTHREAD_RWLOCK_T],
+        size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
     };
 }
 #[cfg(target_os = "android")]
@@ -187,7 +187,7 @@ mod os {
         writerThreadId: libc::c_int,
         pendingReaders: libc::c_int,
         pendingWriters: libc::c_int,
-        reserved: [*mut libc::c_void, ..4],
+        reserved: [*mut libc::c_void; 4],
     }
 
     pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
@@ -203,6 +203,6 @@ mod os {
         writerThreadId: 0,
         pendingReaders: 0,
         pendingWriters: 0,
-        reserved: [0 as *mut _, ..4],
+        reserved: [0 as *mut _; 4],
     };
 }
diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs
index 4afe13d8735..afa77140d13 100644
--- a/src/libstd/sys/unix/timer.rs
+++ b/src/libstd/sys/unix/timer.rs
@@ -120,9 +120,9 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
     // signals the first requests in the queue, possible re-enqueueing it.
     fn signal(active: &mut Vec<Box<Inner>>,
               dead: &mut Vec<(uint, Box<Inner>)>) {
-        let mut timer = match active.remove(0) {
-            Some(timer) => timer, None => return
-        };
+        if active.is_empty() { return }
+
+        let mut timer = active.remove(0);
         let mut cb = timer.cb.take().unwrap();
         cb.call();
         if timer.repeat {
@@ -178,7 +178,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
                         Ok(RemoveTimer(id, ack)) => {
                             match dead.iter().position(|&(i, _)| id == i) {
                                 Some(i) => {
-                                    let (_, i) = dead.remove(i).unwrap();
+                                    let (_, i) = dead.remove(i);
                                     ack.send(i).unwrap();
                                     continue
                                 }
@@ -186,7 +186,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
                             }
                             let i = active.iter().position(|i| i.id == id);
                             let i = i.expect("no timer found");
-                            let t = active.remove(i).unwrap();
+                            let t = active.remove(i);
                             ack.send(t).unwrap();
                         }
                         Err(..) => break
diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs
index 42c8f7705e1..319a458087b 100644
--- a/src/libstd/sys/windows/backtrace.rs
+++ b/src/libstd/sys/windows/backtrace.rs
@@ -68,7 +68,7 @@ const IMAGE_FILE_MACHINE_AMD64: libc::DWORD = 0x8664;
 struct SYMBOL_INFO {
     SizeOfStruct: libc::c_ulong,
     TypeIndex: libc::c_ulong,
-    Reserved: [u64, ..2],
+    Reserved: [u64; 2],
     Index: libc::c_ulong,
     Size: libc::c_ulong,
     ModBase: u64,
@@ -83,7 +83,7 @@ struct SYMBOL_INFO {
     // note that windows has this as 1, but it basically just means that
     // the name is inline at the end of the struct. For us, we just bump
     // the struct size up to MAX_SYM_NAME.
-    Name: [libc::c_char, ..MAX_SYM_NAME],
+    Name: [libc::c_char; MAX_SYM_NAME],
 }
 
 
@@ -108,10 +108,10 @@ struct STACKFRAME64 {
     AddrStack: ADDRESS64,
     AddrBStore: ADDRESS64,
     FuncTableEntry: *mut libc::c_void,
-    Params: [u64, ..4],
+    Params: [u64; 4],
     Far: libc::BOOL,
     Virtual: libc::BOOL,
-    Reserved: [u64, ..3],
+    Reserved: [u64; 3],
     KdHelp: KDHELP64,
 }
 
@@ -127,7 +127,7 @@ struct KDHELP64 {
     KiUserExceptionDispatcher: u64,
     StackBase: u64,
     StackLimit: u64,
-    Reserved: [u64, ..5],
+    Reserved: [u64; 5],
 }
 
 #[cfg(target_arch = "x86")]
@@ -162,7 +162,7 @@ mod arch {
         EFlags: libc::DWORD,
         Esp: libc::DWORD,
         SegSs: libc::DWORD,
-        ExtendedRegisters: [u8, ..MAXIMUM_SUPPORTED_EXTENSION],
+        ExtendedRegisters: [u8; MAXIMUM_SUPPORTED_EXTENSION],
     }
 
     #[repr(C)]
@@ -174,7 +174,7 @@ mod arch {
         ErrorSelector: libc::DWORD,
         DataOffset: libc::DWORD,
         DataSelector: libc::DWORD,
-        RegisterArea: [u8, ..80],
+        RegisterArea: [u8; 80],
         Cr0NpxState: libc::DWORD,
     }
 
@@ -198,7 +198,7 @@ mod arch {
 
     #[repr(C)]
     pub struct CONTEXT {
-        _align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte
+        _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
         P1Home: DWORDLONG,
         P2Home: DWORDLONG,
         P3Home: DWORDLONG,
@@ -245,7 +245,7 @@ mod arch {
 
         FltSave: FLOATING_SAVE_AREA,
 
-        VectorRegister: [M128A, .. 26],
+        VectorRegister: [M128A; 26],
         VectorControl: DWORDLONG,
 
         DebugControl: DWORDLONG,
@@ -257,15 +257,15 @@ mod arch {
 
     #[repr(C)]
     pub struct M128A {
-        _align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte
+        _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
         Low:  c_ulonglong,
         High: c_longlong
     }
 
     #[repr(C)]
     pub struct FLOATING_SAVE_AREA {
-        _align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte
-        _Dummy: [u8, ..512] // FIXME: Fill this out
+        _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
+        _Dummy: [u8; 512] // FIXME: Fill this out
     }
 
     pub fn init_frame(frame: &mut super::STACKFRAME64,
diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs
index d1177776dd8..1ee57434fb9 100644
--- a/src/libstd/sys/windows/c.rs
+++ b/src/libstd/sys/windows/c.rs
@@ -43,8 +43,8 @@ pub const WSA_WAIT_FAILED: libc::DWORD = libc::consts::os::extra::WAIT_FAILED;
 pub struct WSADATA {
     pub wVersion: libc::WORD,
     pub wHighVersion: libc::WORD,
-    pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1],
-    pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1],
+    pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
+    pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
     pub iMaxSockets: u16,
     pub iMaxUdpDg: u16,
     pub lpVendorInfo: *mut u8,
@@ -57,8 +57,8 @@ pub struct WSADATA {
     pub iMaxSockets: u16,
     pub iMaxUdpDg: u16,
     pub lpVendorInfo: *mut u8,
-    pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1],
-    pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1],
+    pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
+    pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
 }
 
 pub type LPWSADATA = *mut WSADATA;
@@ -66,7 +66,7 @@ pub type LPWSADATA = *mut WSADATA;
 #[repr(C)]
 pub struct WSANETWORKEVENTS {
     pub lNetworkEvents: libc::c_long,
-    pub iErrorCode: [libc::c_int, ..FD_MAX_EVENTS],
+    pub iErrorCode: [libc::c_int; FD_MAX_EVENTS],
 }
 
 pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS;
@@ -76,7 +76,7 @@ pub type WSAEVENT = libc::HANDLE;
 #[repr(C)]
 pub struct fd_set {
     fd_count: libc::c_uint,
-    fd_array: [libc::SOCKET, ..FD_SETSIZE],
+    fd_array: [libc::SOCKET; FD_SETSIZE],
 }
 
 pub fn fd_set(set: &mut fd_set, s: libc::SOCKET) {
@@ -131,9 +131,9 @@ extern "system" {
 
 pub mod compat {
     use intrinsics::{atomic_store_relaxed, transmute};
-    use iter::IteratorExt;
     use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
     use prelude::v1::*;
+    use c_str::ToCStr;
 
     extern "system" {
         fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs
index 632261f0ad9..523d60c71aa 100644
--- a/src/libstd/sys/windows/fs.rs
+++ b/src/libstd/sys/windows/fs.rs
@@ -265,8 +265,8 @@ pub fn readdir(p: &Path) -> IoResult<Vec<Path>> {
                 {
                     let filename = os::truncate_utf16_at_nul(&wfd.cFileName);
                     match String::from_utf16(filename) {
-                        Some(filename) => paths.push(Path::new(filename)),
-                        None => {
+                        Ok(filename) => paths.push(Path::new(filename)),
+                        Err(..) => {
                             assert!(libc::FindClose(find_handle) != 0);
                             return Err(IoError {
                                 kind: io::InvalidInput,
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index 94f5822ccea..c354e7b3ece 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -24,6 +24,7 @@ use num;
 use mem;
 use io::{mod, IoResult, IoError};
 use sync::{Once, ONCE_INIT};
+use comm::Sender;
 
 macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => (
     static $name: Helper<$m> = Helper {
@@ -58,6 +59,7 @@ pub mod udp;
 
 pub mod addrinfo {
     pub use sys_common::net::get_host_addresses;
+    pub use sys_common::net::get_address_name;
 }
 
 // FIXME: move these to c module
@@ -122,6 +124,8 @@ pub fn decode_error(errno: i32) -> IoError {
              "invalid handle provided to function"),
         libc::ERROR_NOTHING_TO_TERMINATE =>
             (io::InvalidInput, "no process to kill"),
+        libc::ERROR_ALREADY_EXISTS =>
+            (io::PathAlreadyExists, "path already exists"),
 
         // libuv maps this error code to EISDIR. we do too. if it is found
         // to be incorrect, we can add in some more machinery to only
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 159512525d8..dfdee0e0385 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -17,14 +17,14 @@ use prelude::v1::*;
 
 use fmt;
 use io::{IoResult, IoError};
-use libc::{c_int, c_char, c_void};
+use iter::repeat;
+use libc::{c_int, c_void};
 use libc;
 use os;
 use path::BytesContainer;
 use ptr;
-use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
-use sys::fs::FileDesc;
 use slice;
+use sys::fs::FileDesc;
 
 use os::TMPBUF_SZ;
 use libc::types::os::arch::extra::DWORD;
@@ -80,7 +80,7 @@ pub fn error_string(errnum: i32) -> String {
     // MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)
     let langId = 0x0800 as DWORD;
 
-    let mut buf = [0 as WCHAR, ..TMPBUF_SZ];
+    let mut buf = [0 as WCHAR; TMPBUF_SZ];
 
     unsafe {
         let res = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
@@ -99,8 +99,9 @@ pub fn error_string(errnum: i32) -> String {
 
         let msg = String::from_utf16(truncate_utf16_at_nul(&buf));
         match msg {
-            Some(msg) => format!("OS Error {}: {}", errnum, msg),
-            None => format!("OS Error {} (FormatMessageW() returned invalid UTF-16)", errnum),
+            Ok(msg) => format!("OS Error {}: {}", errnum, msg),
+            Err(..) => format!("OS Error {} (FormatMessageW() returned \
+                                invalid UTF-16)", errnum),
         }
     }
 }
@@ -111,7 +112,7 @@ pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
     // fully understand. Here we explicitly make the pipe non-inheritable,
     // which means to pass it to a subprocess they need to be duplicated
     // first, as in std::run.
-    let mut fds = [0, ..2];
+    let mut fds = [0; 2];
     match libc::pipe(fds.as_mut_ptr(), 1024 as ::libc::c_uint,
                      (libc::O_BINARY | libc::O_NOINHERIT) as c_int) {
         0 => {
@@ -123,13 +124,15 @@ pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
     }
 }
 
-pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD) -> Option<String> {
+pub fn fill_utf16_buf_and_decode<F>(mut f: F) -> Option<String> where
+    F: FnMut(*mut u16, DWORD) -> DWORD,
+{
     unsafe {
         let mut n = TMPBUF_SZ as DWORD;
         let mut res = None;
         let mut done = false;
         while !done {
-            let mut buf = Vec::from_elem(n as uint, 0u16);
+            let mut buf: Vec<u16> = repeat(0u16).take(n as uint).collect();
             let k = f(buf.as_mut_ptr(), n);
             if k == (0 as DWORD) {
                 done = true;
@@ -147,7 +150,7 @@ pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD) -> Option<String
                 // We want to explicitly catch the case when the
                 // closure returned invalid UTF-16, rather than
                 // set `res` to None and continue.
-                let s = String::from_utf16(sub)
+                let s = String::from_utf16(sub).ok()
                     .expect("fill_utf16_buf_and_decode: closure created invalid UTF-16");
                 res = Some(s)
             }
@@ -161,7 +164,7 @@ pub fn getcwd() -> IoResult<Path> {
     use libc::GetCurrentDirectoryW;
     use io::OtherIoError;
 
-    let mut buf = [0 as u16, ..BUF_BYTES];
+    let mut buf = [0 as u16; BUF_BYTES];
     unsafe {
         if libc::GetCurrentDirectoryW(buf.len() as DWORD, buf.as_mut_ptr()) == 0 as DWORD {
             return Err(IoError::last_error());
@@ -169,8 +172,8 @@ pub fn getcwd() -> IoResult<Path> {
     }
 
     match String::from_utf16(truncate_utf16_at_nul(&buf)) {
-        Some(ref cwd) => Ok(Path::new(cwd)),
-        None => Err(IoError {
+        Ok(ref cwd) => Ok(Path::new(cwd)),
+        Err(..) => Err(IoError {
             kind: OtherIoError,
             desc: "GetCurrentDirectoryW returned invalid UTF-16",
             detail: None,
diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs
index f99995eb028..cb99a886ce4 100644
--- a/src/libstd/sys/windows/process.rs
+++ b/src/libstd/sys/windows/process.rs
@@ -12,7 +12,7 @@ use prelude::v1::*;
 
 use libc::{pid_t, c_void, c_int};
 use libc;
-use c_str::CString;
+use c_str::{CString, ToCStr};
 use io;
 use mem;
 use os;
@@ -163,7 +163,7 @@ impl Process {
             // Similarly to unix, we don't actually leave holes for the stdio file
             // descriptors, but rather open up /dev/null equivalents. These
             // equivalents are drawn from libuv's windows process spawning.
-            let set_fd = |fd: &Option<P>, slot: &mut HANDLE,
+            let set_fd = |&: fd: &Option<P>, slot: &mut HANDLE,
                           is_stdin: bool| {
                 match *fd {
                     None => {
@@ -467,6 +467,7 @@ fn free_handle(handle: *mut ()) {
 
 #[cfg(test)]
 mod tests {
+    use c_str::ToCStr;
 
     #[test]
     fn test_make_command_line() {
diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs
index bdf2e0bccb1..e8b447022cb 100644
--- a/src/libstd/sys/windows/stack_overflow.rs
+++ b/src/libstd/sys/windows/stack_overflow.rs
@@ -90,7 +90,7 @@ pub struct EXCEPTION_RECORD {
     pub ExceptionRecord: *mut EXCEPTION_RECORD,
     pub ExceptionAddress: LPVOID,
     pub NumberParameters: DWORD,
-    pub ExceptionInformation: [LPVOID, ..EXCEPTION_MAXIMUM_PARAMETERS]
+    pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
 }
 
 pub struct EXCEPTION_POINTERS {
diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs
index 3df0debff51..485dc251050 100644
--- a/src/libstd/sys/windows/timer.rs
+++ b/src/libstd/sys/windows/timer.rs
@@ -21,16 +21,17 @@
 //! the other two implementations of timers with nothing *that* new showing up.
 
 use self::Req::*;
+use prelude::v1::*;
 
 use libc;
 use ptr;
 use comm;
 
+use comm::{channel, Sender, Receiver};
+use io::IoResult;
 use sys::c;
 use sys::fs::FileDesc;
 use sys_common::helper_thread::Helper;
-use prelude::v1::*;
-use io::IoResult;
 
 helper_init! { static HELPER: Helper<Req> }
 
diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs
index dfa3440067a..7591025d76d 100644
--- a/src/libstd/sys/windows/tty.rs
+++ b/src/libstd/sys/windows/tty.rs
@@ -27,17 +27,18 @@
 
 use prelude::v1::*;
 
-use super::c::{ReadConsoleW, WriteConsoleW, GetConsoleMode, SetConsoleMode};
-use super::c::{ERROR_ILLEGAL_CHARACTER};
-use super::c::{ENABLE_ECHO_INPUT, ENABLE_EXTENDED_FLAGS};
-use super::c::{ENABLE_INSERT_MODE, ENABLE_LINE_INPUT};
-use super::c::{ENABLE_PROCESSED_INPUT, ENABLE_QUICK_EDIT_MODE};
+use io::{mod, IoError, IoResult, MemReader};
+use iter::repeat;
+use libc::types::os::arch::extra::LPCVOID;
 use libc::{c_int, HANDLE, LPDWORD, DWORD, LPVOID};
 use libc::{get_osfhandle, CloseHandle};
-use libc::types::os::arch::extra::LPCVOID;
-use io::{mod, IoError, IoResult, MemReader};
 use ptr;
 use str::from_utf8;
+use super::c::{ENABLE_ECHO_INPUT, ENABLE_EXTENDED_FLAGS};
+use super::c::{ENABLE_INSERT_MODE, ENABLE_LINE_INPUT};
+use super::c::{ENABLE_PROCESSED_INPUT, ENABLE_QUICK_EDIT_MODE};
+use super::c::{ERROR_ILLEGAL_CHARACTER};
+use super::c::{ReadConsoleW, WriteConsoleW, GetConsoleMode, SetConsoleMode};
 
 fn invalid_encoding() -> IoError {
     IoError {
@@ -90,7 +91,7 @@ impl TTY {
     pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
         // Read more if the buffer is empty
         if self.utf8.eof() {
-            let mut utf16 = Vec::from_elem(0x1000, 0u16);
+            let mut utf16: Vec<u16> = repeat(0u16).take(0x1000).collect();
             let mut num: DWORD = 0;
             match unsafe { ReadConsoleW(self.handle,
                                          utf16.as_mut_ptr() as LPVOID,
@@ -102,8 +103,8 @@ impl TTY {
             };
             utf16.truncate(num as uint);
             let utf8 = match String::from_utf16(utf16.as_slice()) {
-                Some(utf8) => utf8.into_bytes(),
-                None => return Err(invalid_encoding()),
+                Ok(utf8) => utf8.into_bytes(),
+                Err(..) => return Err(invalid_encoding()),
             };
             self.utf8 = MemReader::new(utf8);
         }