about summary refs log tree commit diff
path: root/src/libstd/sys/unix
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2016-03-22 22:01:37 -0500
committerJorge Aparicio <japaricious@gmail.com>2016-03-22 22:01:37 -0500
commit0f02309e4b0ea05ee905205278fb6d131341c41f (patch)
treea259129eeb84705de15b51587ddebd0f82735075 /src/libstd/sys/unix
parent0dcc413e42f15f4fc51a0ca88a99cc89454ec43d (diff)
downloadrust-0f02309e4b0ea05ee905205278fb6d131341c41f.tar.gz
rust-0f02309e4b0ea05ee905205278fb6d131341c41f.zip
try! -> ?
Automated conversion using the untry tool [1] and the following command:

```
$ find -name '*.rs' -type f | xargs untry
```

at the root of the Rust repo.

[1]: https://github.com/japaric/untry
Diffstat (limited to 'src/libstd/sys/unix')
-rw-r--r--src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs4
-rw-r--r--src/libstd/sys/unix/backtrace/tracing/gcc_s.rs2
-rw-r--r--src/libstd/sys/unix/ext/net.rs50
-rw-r--r--src/libstd/sys/unix/fd.rs8
-rw-r--r--src/libstd/sys/unix/fs.rs104
-rw-r--r--src/libstd/sys/unix/net.rs16
-rw-r--r--src/libstd/sys/unix/os.rs26
-rw-r--r--src/libstd/sys/unix/pipe.rs8
-rw-r--r--src/libstd/sys/unix/process.rs44
-rw-r--r--src/libstd/sys/unix/rand.rs2
10 files changed, 132 insertions, 132 deletions
diff --git a/src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs b/src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs
index 46f276aecf4..de93d3d4e50 100644
--- a/src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs
+++ b/src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs
@@ -40,7 +40,7 @@ pub fn write(w: &mut Write) -> io::Result<()> {
     static LOCK: StaticMutex = StaticMutex::new();
     let _g = LOCK.lock();
 
-    try!(writeln!(w, "stack backtrace:"));
+    writeln!(w, "stack backtrace:")?;
     // 100 lines should be enough
     const SIZE: usize = 100;
     let mut buf: [*mut libc::c_void; SIZE] = unsafe { mem::zeroed() };
@@ -48,7 +48,7 @@ pub fn write(w: &mut Write) -> io::Result<()> {
 
     // skipping the first one as it is write itself
     for i in 1..cnt {
-        try!(print(w, i as isize, buf[i], buf[i]))
+        print(w, i as isize, buf[i], buf[i])?
     }
     Ok(())
 }
diff --git a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
index 8b32b5ec040..8d880917166 100644
--- a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
+++ b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
@@ -33,7 +33,7 @@ pub fn write(w: &mut Write) -> io::Result<()> {
     static LOCK: StaticMutex = StaticMutex::new();
     let _g = LOCK.lock();
 
-    try!(writeln!(w, "stack backtrace:"));
+    writeln!(w, "stack backtrace:")?;
 
     let mut cx = Context { writer: w, last_error: None, idx: 0 };
     return match unsafe {
diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs
index 2ee825f1ec2..51ac8cb82d1 100644
--- a/src/libstd/sys/unix/ext/net.rs
+++ b/src/libstd/sys/unix/ext/net.rs
@@ -87,7 +87,7 @@ impl SocketAddr {
         unsafe {
             let mut addr: libc::sockaddr_un = mem::zeroed();
             let mut len = mem::size_of::<libc::sockaddr_un>() as libc::socklen_t;
-            try!(cvt(f(&mut addr as *mut _ as *mut _, &mut len)));
+            cvt(f(&mut addr as *mut _ as *mut _, &mut len))?;
             SocketAddr::from_parts(addr, len)
         }
     }
@@ -155,9 +155,9 @@ struct AsciiEscaped<'a>(&'a [u8]);
 
 impl<'a> fmt::Display for AsciiEscaped<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(fmt, "\""));
+        write!(fmt, "\"")?;
         for byte in self.0.iter().cloned().flat_map(ascii::escape_default) {
-            try!(write!(fmt, "{}", byte as char));
+            write!(fmt, "{}", byte as char)?;
         }
         write!(fmt, "\"")
     }
@@ -200,10 +200,10 @@ impl UnixStream {
     pub fn connect<P: AsRef<Path>>(path: P) -> io::Result<UnixStream> {
         fn inner(path: &Path) -> io::Result<UnixStream> {
             unsafe {
-                let inner = try!(Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM));
-                let (addr, len) = try!(sockaddr_un(path));
+                let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
+                let (addr, len) = sockaddr_un(path)?;
 
-                try!(cvt(libc::connect(*inner.as_inner(), &addr as *const _ as *const _, len)));
+                cvt(libc::connect(*inner.as_inner(), &addr as *const _ as *const _, len))?;
                 Ok(UnixStream(inner))
             }
         }
@@ -214,7 +214,7 @@ impl UnixStream {
     ///
     /// Returns two `UnixStream`s which are connected to each other.
     pub fn pair() -> io::Result<(UnixStream, UnixStream)> {
-        let (i1, i2) = try!(Socket::new_pair(libc::AF_UNIX, libc::SOCK_STREAM));
+        let (i1, i2) = Socket::new_pair(libc::AF_UNIX, libc::SOCK_STREAM)?;
         Ok((UnixStream(i1), UnixStream(i2)))
     }
 
@@ -395,11 +395,11 @@ impl UnixListener {
     pub fn bind<P: AsRef<Path>>(path: P) -> io::Result<UnixListener> {
         fn inner(path: &Path) -> io::Result<UnixListener> {
             unsafe {
-                let inner = try!(Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM));
-                let (addr, len) = try!(sockaddr_un(path));
+                let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
+                let (addr, len) = sockaddr_un(path)?;
 
-                try!(cvt(libc::bind(*inner.as_inner(), &addr as *const _ as *const _, len)));
-                try!(cvt(libc::listen(*inner.as_inner(), 128)));
+                cvt(libc::bind(*inner.as_inner(), &addr as *const _ as *const _, len))?;
+                cvt(libc::listen(*inner.as_inner(), 128))?;
 
                 Ok(UnixListener(inner))
             }
@@ -415,8 +415,8 @@ impl UnixListener {
     pub fn accept(&self) -> io::Result<(UnixStream, SocketAddr)> {
         let mut storage: libc::sockaddr_un = unsafe { mem::zeroed() };
         let mut len = mem::size_of_val(&storage) as libc::socklen_t;
-        let sock = try!(self.0.accept(&mut storage as *mut _ as *mut _, &mut len));
-        let addr = try!(SocketAddr::from_parts(storage, len));
+        let sock = self.0.accept(&mut storage as *mut _ as *mut _, &mut len)?;
+        let addr = SocketAddr::from_parts(storage, len)?;
         Ok((UnixStream(sock), addr))
     }
 
@@ -536,10 +536,10 @@ impl UnixDatagram {
     pub fn bind<P: AsRef<Path>>(path: P) -> io::Result<UnixDatagram> {
         fn inner(path: &Path) -> io::Result<UnixDatagram> {
             unsafe {
-                let socket = try!(UnixDatagram::unbound());
-                let (addr, len) = try!(sockaddr_un(path));
+                let socket = UnixDatagram::unbound()?;
+                let (addr, len) = sockaddr_un(path)?;
 
-                try!(cvt(libc::bind(*socket.0.as_inner(), &addr as *const _ as *const _, len)));
+                cvt(libc::bind(*socket.0.as_inner(), &addr as *const _ as *const _, len))?;
 
                 Ok(socket)
             }
@@ -549,7 +549,7 @@ impl UnixDatagram {
 
     /// Creates a Unix Datagram socket which is not bound to any address.
     pub fn unbound() -> io::Result<UnixDatagram> {
-        let inner = try!(Socket::new_raw(libc::AF_UNIX, libc::SOCK_DGRAM));
+        let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_DGRAM)?;
         Ok(UnixDatagram(inner))
     }
 
@@ -557,7 +557,7 @@ impl UnixDatagram {
     ///
     /// Returns two `UnixDatagrams`s which are connected to each other.
     pub fn pair() -> io::Result<(UnixDatagram, UnixDatagram)> {
-        let (i1, i2) = try!(Socket::new_pair(libc::AF_UNIX, libc::SOCK_DGRAM));
+        let (i1, i2) = Socket::new_pair(libc::AF_UNIX, libc::SOCK_DGRAM)?;
         Ok((UnixDatagram(i1), UnixDatagram(i2)))
     }
 
@@ -568,9 +568,9 @@ impl UnixDatagram {
     pub fn connect<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
         fn inner(d: &UnixDatagram, path: &Path) -> io::Result<()> {
             unsafe {
-                let (addr, len) = try!(sockaddr_un(path));
+                let (addr, len) = sockaddr_un(path)?;
 
-                try!(cvt(libc::connect(*d.0.as_inner(), &addr as *const _ as *const _, len)));
+                cvt(libc::connect(*d.0.as_inner(), &addr as *const _ as *const _, len))?;
 
                 Ok(())
             }
@@ -605,7 +605,7 @@ impl UnixDatagram {
     /// whence the data came.
     pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
         let mut count = 0;
-        let addr = try!(SocketAddr::new(|addr, len| {
+        let addr = SocketAddr::new(|addr, len| {
             unsafe {
                 count = libc::recvfrom(*self.0.as_inner(),
                                        buf.as_mut_ptr() as *mut _,
@@ -621,7 +621,7 @@ impl UnixDatagram {
                     -1
                 }
             }
-        }));
+        })?;
 
         Ok((count as usize, addr))
     }
@@ -639,14 +639,14 @@ impl UnixDatagram {
     pub fn send_to<P: AsRef<Path>>(&self, buf: &[u8], path: P) -> io::Result<usize> {
         fn inner(d: &UnixDatagram, buf: &[u8], path: &Path) -> io::Result<usize> {
             unsafe {
-                let (addr, len) = try!(sockaddr_un(path));
+                let (addr, len) = sockaddr_un(path)?;
 
-                let count = try!(cvt(libc::sendto(*d.0.as_inner(),
+                let count = cvt(libc::sendto(*d.0.as_inner(),
                                                   buf.as_ptr() as *const _,
                                                   buf.len(),
                                                   0,
                                                   &addr as *const _ as *const _,
-                                                  len)));
+                                                  len))?;
                 Ok(count as usize)
             }
         }
diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs
index 8ec073858fd..94c48be02ff 100644
--- a/src/libstd/sys/unix/fd.rs
+++ b/src/libstd/sys/unix/fd.rs
@@ -39,11 +39,11 @@ impl FileDesc {
     }
 
     pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
-        let ret = try!(cvt(unsafe {
+        let ret = cvt(unsafe {
             libc::read(self.fd,
                        buf.as_mut_ptr() as *mut c_void,
                        buf.len() as size_t)
-        }));
+        })?;
         Ok(ret as usize)
     }
 
@@ -53,11 +53,11 @@ impl FileDesc {
     }
 
     pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
-        let ret = try!(cvt(unsafe {
+        let ret = cvt(unsafe {
             libc::write(self.fd,
                         buf.as_ptr() as *const c_void,
                         buf.len() as size_t)
-        }));
+        })?;
         Ok(ret as usize)
     }
 
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index 3985a07470e..810a34478c5 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -418,18 +418,18 @@ impl OpenOptions {
 
 impl File {
     pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
-        let path = try!(cstr(path));
+        let path = cstr(path)?;
         File::open_c(&path, opts)
     }
 
     pub fn open_c(path: &CStr, opts: &OpenOptions) -> io::Result<File> {
         let flags = libc::O_CLOEXEC |
-                    try!(opts.get_access_mode()) |
-                    try!(opts.get_creation_mode()) |
+                    opts.get_access_mode()? |
+                    opts.get_creation_mode()? |
                     (opts.custom_flags as c_int & !libc::O_ACCMODE);
-        let fd = try!(cvt_r(|| unsafe {
+        let fd = cvt_r(|| unsafe {
             open64(path.as_ptr(), flags, opts.mode as c_int)
-        }));
+        })?;
         let fd = FileDesc::new(fd);
 
         // Currently the standard library supports Linux 2.6.18 which did not
@@ -448,19 +448,19 @@ impl File {
 
     pub fn file_attr(&self) -> io::Result<FileAttr> {
         let mut stat: stat64 = unsafe { mem::zeroed() };
-        try!(cvt(unsafe {
+        cvt(unsafe {
             fstat64(self.0.raw(), &mut stat)
-        }));
+        })?;
         Ok(FileAttr { stat: stat })
     }
 
     pub fn fsync(&self) -> io::Result<()> {
-        try!(cvt_r(|| unsafe { libc::fsync(self.0.raw()) }));
+        cvt_r(|| unsafe { libc::fsync(self.0.raw()) })?;
         Ok(())
     }
 
     pub fn datasync(&self) -> io::Result<()> {
-        try!(cvt_r(|| unsafe { os_datasync(self.0.raw()) }));
+        cvt_r(|| unsafe { os_datasync(self.0.raw()) })?;
         return Ok(());
 
         #[cfg(any(target_os = "macos", target_os = "ios"))]
@@ -476,9 +476,9 @@ impl File {
     }
 
     pub fn truncate(&self, size: u64) -> io::Result<()> {
-        try!(cvt_r(|| unsafe {
+        cvt_r(|| unsafe {
             ftruncate64(self.0.raw(), size as off64_t)
-        }));
+        })?;
         Ok(())
     }
 
@@ -502,7 +502,7 @@ impl File {
             SeekFrom::End(off) => (libc::SEEK_END, off as off64_t),
             SeekFrom::Current(off) => (libc::SEEK_CUR, off as off64_t),
         };
-        let n = try!(cvt(unsafe { lseek64(self.0.raw(), pos, whence) }));
+        let n = cvt(unsafe { lseek64(self.0.raw(), pos, whence) })?;
         Ok(n as u64)
     }
 
@@ -521,8 +521,8 @@ impl DirBuilder {
     }
 
     pub fn mkdir(&self, p: &Path) -> io::Result<()> {
-        let p = try!(cstr(p));
-        try!(cvt(unsafe { libc::mkdir(p.as_ptr(), self.mode) }));
+        let p = cstr(p)?;
+        cvt(unsafe { libc::mkdir(p.as_ptr(), self.mode) })?;
         Ok(())
     }
 
@@ -532,7 +532,7 @@ impl DirBuilder {
 }
 
 fn cstr(path: &Path) -> io::Result<CString> {
-    Ok(try!(CString::new(path.as_os_str().as_bytes())))
+    Ok(CString::new(path.as_os_str().as_bytes())?)
 }
 
 impl FromInner<c_int> for File {
@@ -610,7 +610,7 @@ impl fmt::Debug for File {
 
 pub fn readdir(p: &Path) -> io::Result<ReadDir> {
     let root = Arc::new(p.to_path_buf());
-    let p = try!(cstr(p));
+    let p = cstr(p)?;
     unsafe {
         let ptr = libc::opendir(p.as_ptr());
         if ptr.is_null() {
@@ -622,32 +622,32 @@ pub fn readdir(p: &Path) -> io::Result<ReadDir> {
 }
 
 pub fn unlink(p: &Path) -> io::Result<()> {
-    let p = try!(cstr(p));
-    try!(cvt(unsafe { libc::unlink(p.as_ptr()) }));
+    let p = cstr(p)?;
+    cvt(unsafe { libc::unlink(p.as_ptr()) })?;
     Ok(())
 }
 
 pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
-    let old = try!(cstr(old));
-    let new = try!(cstr(new));
-    try!(cvt(unsafe { libc::rename(old.as_ptr(), new.as_ptr()) }));
+    let old = cstr(old)?;
+    let new = cstr(new)?;
+    cvt(unsafe { libc::rename(old.as_ptr(), new.as_ptr()) })?;
     Ok(())
 }
 
 pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
-    let p = try!(cstr(p));
-    try!(cvt_r(|| unsafe { libc::chmod(p.as_ptr(), perm.mode) }));
+    let p = cstr(p)?;
+    cvt_r(|| unsafe { libc::chmod(p.as_ptr(), perm.mode) })?;
     Ok(())
 }
 
 pub fn rmdir(p: &Path) -> io::Result<()> {
-    let p = try!(cstr(p));
-    try!(cvt(unsafe { libc::rmdir(p.as_ptr()) }));
+    let p = cstr(p)?;
+    cvt(unsafe { libc::rmdir(p.as_ptr()) })?;
     Ok(())
 }
 
 pub fn remove_dir_all(path: &Path) -> io::Result<()> {
-    let filetype = try!(lstat(path)).file_type();
+    let filetype = lstat(path)?.file_type();
     if filetype.is_symlink() {
         unlink(path)
     } else {
@@ -656,27 +656,27 @@ pub fn remove_dir_all(path: &Path) -> io::Result<()> {
 }
 
 fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
-    for child in try!(readdir(path)) {
-        let child = try!(child);
-        if try!(child.file_type()).is_dir() {
-            try!(remove_dir_all_recursive(&child.path()));
+    for child in readdir(path)? {
+        let child = child?;
+        if child.file_type()?.is_dir() {
+            remove_dir_all_recursive(&child.path())?;
         } else {
-            try!(unlink(&child.path()));
+            unlink(&child.path())?;
         }
     }
     rmdir(path)
 }
 
 pub fn readlink(p: &Path) -> io::Result<PathBuf> {
-    let c_path = try!(cstr(p));
+    let c_path = cstr(p)?;
     let p = c_path.as_ptr();
 
     let mut buf = Vec::with_capacity(256);
 
     loop {
-        let buf_read = try!(cvt(unsafe {
+        let buf_read = cvt(unsafe {
             libc::readlink(p, buf.as_mut_ptr() as *mut _, buf.capacity() as libc::size_t)
-        })) as usize;
+        })? as usize;
 
         unsafe { buf.set_len(buf_read); }
 
@@ -694,39 +694,39 @@ pub fn readlink(p: &Path) -> io::Result<PathBuf> {
 }
 
 pub fn symlink(src: &Path, dst: &Path) -> io::Result<()> {
-    let src = try!(cstr(src));
-    let dst = try!(cstr(dst));
-    try!(cvt(unsafe { libc::symlink(src.as_ptr(), dst.as_ptr()) }));
+    let src = cstr(src)?;
+    let dst = cstr(dst)?;
+    cvt(unsafe { libc::symlink(src.as_ptr(), dst.as_ptr()) })?;
     Ok(())
 }
 
 pub fn link(src: &Path, dst: &Path) -> io::Result<()> {
-    let src = try!(cstr(src));
-    let dst = try!(cstr(dst));
-    try!(cvt(unsafe { libc::link(src.as_ptr(), dst.as_ptr()) }));
+    let src = cstr(src)?;
+    let dst = cstr(dst)?;
+    cvt(unsafe { libc::link(src.as_ptr(), dst.as_ptr()) })?;
     Ok(())
 }
 
 pub fn stat(p: &Path) -> io::Result<FileAttr> {
-    let p = try!(cstr(p));
+    let p = cstr(p)?;
     let mut stat: stat64 = unsafe { mem::zeroed() };
-    try!(cvt(unsafe {
+    cvt(unsafe {
         stat64(p.as_ptr(), &mut stat as *mut _ as *mut _)
-    }));
+    })?;
     Ok(FileAttr { stat: stat })
 }
 
 pub fn lstat(p: &Path) -> io::Result<FileAttr> {
-    let p = try!(cstr(p));
+    let p = cstr(p)?;
     let mut stat: stat64 = unsafe { mem::zeroed() };
-    try!(cvt(unsafe {
+    cvt(unsafe {
         lstat64(p.as_ptr(), &mut stat as *mut _ as *mut _)
-    }));
+    })?;
     Ok(FileAttr { stat: stat })
 }
 
 pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
-    let path = try!(CString::new(p.as_os_str().as_bytes()));
+    let path = CString::new(p.as_os_str().as_bytes())?;
     let buf;
     unsafe {
         let r = libc::realpath(path.as_ptr(), ptr::null_mut());
@@ -746,11 +746,11 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
                               "the source path is not an existing regular file"))
     }
 
-    let mut reader = try!(File::open(from));
-    let mut writer = try!(File::create(to));
-    let perm = try!(reader.metadata()).permissions();
+    let mut reader = File::open(from)?;
+    let mut writer = File::create(to)?;
+    let perm = reader.metadata()?.permissions();
 
-    let ret = try!(io::copy(&mut reader, &mut writer));
-    try!(set_permissions(to, perm));
+    let ret = io::copy(&mut reader, &mut writer)?;
+    set_permissions(to, perm)?;
     Ok(ret)
 }
diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs
index d7b353c9b2a..830957a7e59 100644
--- a/src/libstd/sys/unix/net.rs
+++ b/src/libstd/sys/unix/net.rs
@@ -75,7 +75,7 @@ impl Socket {
                 }
             }
 
-            let fd = try!(cvt(libc::socket(fam, ty, 0)));
+            let fd = cvt(libc::socket(fam, ty, 0))?;
             let fd = FileDesc::new(fd);
             fd.set_cloexec();
             Ok(Socket(fd))
@@ -97,7 +97,7 @@ impl Socket {
                 }
             }
 
-            try!(cvt(libc::socketpair(fam, ty, 0, fds.as_mut_ptr())));
+            cvt(libc::socketpair(fam, ty, 0, fds.as_mut_ptr()))?;
             let a = FileDesc::new(fds[0]);
             a.set_cloexec();
             let b = FileDesc::new(fds[1]);
@@ -128,9 +128,9 @@ impl Socket {
             }
         }
 
-        let fd = try!(cvt_r(|| unsafe {
+        let fd = cvt_r(|| unsafe {
             libc::accept(self.0.raw(), storage, len)
-        }));
+        })?;
         let fd = FileDesc::new(fd);
         fd.set_cloexec();
         Ok(Socket(fd))
@@ -185,7 +185,7 @@ impl Socket {
     }
 
     pub fn timeout(&self, kind: libc::c_int) -> io::Result<Option<Duration>> {
-        let raw: libc::timeval = try!(getsockopt(self, libc::SOL_SOCKET, kind));
+        let raw: libc::timeval = getsockopt(self, libc::SOL_SOCKET, kind)?;
         if raw.tv_sec == 0 && raw.tv_usec == 0 {
             Ok(None)
         } else {
@@ -201,7 +201,7 @@ impl Socket {
             Shutdown::Read => libc::SHUT_RD,
             Shutdown::Both => libc::SHUT_RDWR,
         };
-        try!(cvt(unsafe { libc::shutdown(self.0.raw(), how) }));
+        cvt(unsafe { libc::shutdown(self.0.raw(), how) })?;
         Ok(())
     }
 
@@ -210,7 +210,7 @@ impl Socket {
     }
 
     pub fn nodelay(&self) -> io::Result<bool> {
-        let raw: c_int = try!(getsockopt(self, libc::IPPROTO_TCP, libc::TCP_NODELAY));
+        let raw: c_int = getsockopt(self, libc::IPPROTO_TCP, libc::TCP_NODELAY)?;
         Ok(raw != 0)
     }
 
@@ -220,7 +220,7 @@ impl Socket {
     }
 
     pub fn take_error(&self) -> io::Result<Option<io::Error>> {
-        let raw: c_int = try!(getsockopt(self, libc::SOL_SOCKET, libc::SO_ERROR));
+        let raw: c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_ERROR)?;
         if raw == 0 {
             Ok(None)
         } else {
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index b6a0bd84409..0d77f344914 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -110,7 +110,7 @@ pub fn getcwd() -> io::Result<PathBuf> {
 
 pub fn chdir(p: &path::Path) -> io::Result<()> {
     let p: &OsStr = p.as_ref();
-    let p = try!(CString::new(p.as_bytes()));
+    let p = CString::new(p.as_bytes())?;
     unsafe {
         match libc::chdir(p.as_ptr()) == (0 as c_int) {
             true => Ok(()),
@@ -180,16 +180,16 @@ pub fn current_exe() -> io::Result<PathBuf> {
                        libc::KERN_PROC_PATHNAME as c_int,
                        -1 as c_int];
         let mut sz: libc::size_t = 0;
-        try!(cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
+        cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
                               ptr::null_mut(), &mut sz, ptr::null_mut(),
-                              0 as libc::size_t)));
+                              0 as libc::size_t))?;
         if sz == 0 {
             return Err(io::Error::last_os_error())
         }
         let mut v: Vec<u8> = Vec::with_capacity(sz as usize);
-        try!(cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
+        cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
                               v.as_mut_ptr() as *mut libc::c_void, &mut sz,
-                              ptr::null_mut(), 0 as libc::size_t)));
+                              ptr::null_mut(), 0 as libc::size_t))?;
         if sz == 0 {
             return Err(io::Error::last_os_error());
         }
@@ -217,11 +217,11 @@ pub fn current_exe() -> io::Result<PathBuf> {
                        libc::KERN_PROC_ARGV];
         let mib = mib.as_mut_ptr();
         let mut argv_len = 0;
-        try!(cvt(libc::sysctl(mib, 4, 0 as *mut _, &mut argv_len,
-                              0 as *mut _, 0)));
+        cvt(libc::sysctl(mib, 4, 0 as *mut _, &mut argv_len,
+                              0 as *mut _, 0))?;
         let mut argv = Vec::<*const libc::c_char>::with_capacity(argv_len as usize);
-        try!(cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _,
-                              &mut argv_len, 0 as *mut _, 0)));
+        cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _,
+                              &mut argv_len, 0 as *mut _, 0))?;
         argv.set_len(argv_len as usize);
         if argv[0].is_null() {
             return Err(io::Error::new(io::ErrorKind::Other,
@@ -460,7 +460,7 @@ pub fn env() -> Env {
 pub fn getenv(k: &OsStr) -> io::Result<Option<OsString>> {
     // environment variables with a nul byte can't be set, so their value is
     // always None as well
-    let k = try!(CString::new(k.as_bytes()));
+    let k = CString::new(k.as_bytes())?;
     let _g = ENV_LOCK.lock();
     Ok(unsafe {
         let s = libc::getenv(k.as_ptr()) as *const _;
@@ -473,8 +473,8 @@ pub fn getenv(k: &OsStr) -> io::Result<Option<OsString>> {
 }
 
 pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
-    let k = try!(CString::new(k.as_bytes()));
-    let v = try!(CString::new(v.as_bytes()));
+    let k = CString::new(k.as_bytes())?;
+    let v = CString::new(v.as_bytes())?;
     let _g = ENV_LOCK.lock();
     cvt(unsafe {
         libc::setenv(k.as_ptr(), v.as_ptr(), 1)
@@ -482,7 +482,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
 }
 
 pub fn unsetenv(n: &OsStr) -> io::Result<()> {
-    let nbuf = try!(CString::new(n.as_bytes()));
+    let nbuf = CString::new(n.as_bytes())?;
     let _g = ENV_LOCK.lock();
     cvt(unsafe {
         libc::unsetenv(nbuf.as_ptr())
diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs
index e5cb3761001..beca2d46753 100644
--- a/src/libstd/sys/unix/pipe.rs
+++ b/src/libstd/sys/unix/pipe.rs
@@ -87,13 +87,13 @@ pub fn read2(p1: AnonPipe,
     let max = cmp::max(p1.raw(), p2.raw());
     loop {
         // wait for either pipe to become readable using `select`
-        try!(cvt_r(|| unsafe {
+        cvt_r(|| unsafe {
             let mut read: libc::fd_set = mem::zeroed();
             libc::FD_SET(p1.raw(), &mut read);
             libc::FD_SET(p2.raw(), &mut read);
             libc::select(max + 1, &mut read, 0 as *mut _, 0 as *mut _,
                          0 as *mut _)
-        }));
+        })?;
 
         // Read as much as we can from each pipe, ignoring EWOULDBLOCK or
         // EAGAIN. If we hit EOF, then this will happen because the underlying
@@ -113,11 +113,11 @@ pub fn read2(p1: AnonPipe,
                 }
             }
         };
-        if try!(read(&p1, v1)) {
+        if read(&p1, v1)? {
             p2.set_nonblocking(false);
             return p2.read_to_end(v2).map(|_| ());
         }
-        if try!(read(&p2, v2)) {
+        if read(&p2, v2)? {
             p1.set_nonblocking(false);
             return p1.read_to_end(v1).map(|_| ());
         }
diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs
index 47b0ff42f93..83f76c1cbc5 100644
--- a/src/libstd/sys/unix/process.rs
+++ b/src/libstd/sys/unix/process.rs
@@ -225,11 +225,11 @@ impl Command {
                                       "nul byte found in provided data"));
         }
 
-        let (ours, theirs) = try!(self.setup_io(default, needs_stdin));
-        let (input, output) = try!(sys::pipe::anon_pipe());
+        let (ours, theirs) = self.setup_io(default, needs_stdin)?;
+        let (input, output) = sys::pipe::anon_pipe()?;
 
         let pid = unsafe {
-            match try!(cvt(libc::fork())) {
+            match cvt(libc::fork())? {
                 0 => {
                     drop(input);
                     let err = self.do_exec(theirs);
@@ -343,17 +343,17 @@ impl Command {
         }
 
         if let Some(fd) = stdio.stdin.fd() {
-            try!(cvt_r(|| libc::dup2(fd, libc::STDIN_FILENO)));
+            cvt_r(|| libc::dup2(fd, libc::STDIN_FILENO))?;
         }
         if let Some(fd) = stdio.stdout.fd() {
-            try!(cvt_r(|| libc::dup2(fd, libc::STDOUT_FILENO)));
+            cvt_r(|| libc::dup2(fd, libc::STDOUT_FILENO))?;
         }
         if let Some(fd) = stdio.stderr.fd() {
-            try!(cvt_r(|| libc::dup2(fd, libc::STDERR_FILENO)));
+            cvt_r(|| libc::dup2(fd, libc::STDERR_FILENO))?;
         }
 
         if let Some(u) = self.gid {
-            try!(cvt(libc::setgid(u as gid_t)));
+            cvt(libc::setgid(u as gid_t))?;
         }
         if let Some(u) = self.uid {
             // When dropping privileges from root, the `setgroups` call
@@ -365,7 +365,7 @@ impl Command {
             // privilege dropping function.
             let _ = libc::setgroups(0, ptr::null());
 
-            try!(cvt(libc::setuid(u as uid_t)));
+            cvt(libc::setuid(u as uid_t))?;
         }
         if self.session_leader {
             // Don't check the error of setsid because it fails if we're the
@@ -374,7 +374,7 @@ impl Command {
             let _ = libc::setsid();
         }
         if let Some(ref cwd) = self.cwd {
-            try!(cvt(libc::chdir(cwd.as_ptr())));
+            cvt(libc::chdir(cwd.as_ptr()))?;
         }
         if let Some(ref envp) = self.envp {
             *sys::os::environ() = envp.as_ptr();
@@ -390,9 +390,9 @@ impl Command {
             // need to clean things up now to avoid confusing the program
             // we're about to run.
             let mut set: libc::sigset_t = mem::uninitialized();
-            try!(cvt(libc::sigemptyset(&mut set)));
-            try!(cvt(libc::pthread_sigmask(libc::SIG_SETMASK, &set,
-                                           ptr::null_mut())));
+            cvt(libc::sigemptyset(&mut set))?;
+            cvt(libc::pthread_sigmask(libc::SIG_SETMASK, &set,
+                                           ptr::null_mut()))?;
             let ret = libc::signal(libc::SIGPIPE, libc::SIG_DFL);
             if ret == libc::SIG_ERR {
                 return io::Error::last_os_error()
@@ -400,7 +400,7 @@ impl Command {
         }
 
         for callback in self.closures.iter_mut() {
-            try!(callback());
+            callback()?;
         }
 
         libc::execvp(self.argv[0], self.argv.as_ptr());
@@ -415,9 +415,9 @@ impl Command {
         let stdin = self.stdin.as_ref().unwrap_or(default_stdin);
         let stdout = self.stdout.as_ref().unwrap_or(&default);
         let stderr = self.stderr.as_ref().unwrap_or(&default);
-        let (their_stdin, our_stdin) = try!(stdin.to_child_stdio(true));
-        let (their_stdout, our_stdout) = try!(stdout.to_child_stdio(false));
-        let (their_stderr, our_stderr) = try!(stderr.to_child_stdio(false));
+        let (their_stdin, our_stdin) = stdin.to_child_stdio(true)?;
+        let (their_stdout, our_stdout) = stdout.to_child_stdio(false)?;
+        let (their_stderr, our_stderr) = stderr.to_child_stdio(false)?;
         let ours = StdioPipes {
             stdin: our_stdin,
             stdout: our_stdout,
@@ -454,14 +454,14 @@ impl Stdio {
             // overwritten prematurely.
             Stdio::Fd(ref fd) => {
                 if fd.raw() >= 0 && fd.raw() <= libc::STDERR_FILENO {
-                    Ok((ChildStdio::Owned(try!(fd.duplicate())), None))
+                    Ok((ChildStdio::Owned(fd.duplicate()?), None))
                 } else {
                     Ok((ChildStdio::Explicit(fd.raw()), None))
                 }
             }
 
             Stdio::MakePipe => {
-                let (reader, writer) = try!(pipe::anon_pipe());
+                let (reader, writer) = pipe::anon_pipe()?;
                 let (ours, theirs) = if readable {
                     (writer, reader)
                 } else {
@@ -477,7 +477,7 @@ impl Stdio {
                 let path = unsafe {
                     CStr::from_ptr("/dev/null\0".as_ptr() as *const _)
                 };
-                let fd = try!(File::open_c(&path, &opts));
+                let fd = File::open_c(&path, &opts)?;
                 Ok((ChildStdio::Owned(fd.into_fd()), None))
             }
         }
@@ -508,9 +508,9 @@ fn pair_to_key(key: &OsStr, value: &OsStr, saw_nul: &mut bool) -> CString {
 
 impl fmt::Debug for Command {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{:?}", self.program));
+        write!(f, "{:?}", self.program)?;
         for arg in &self.args {
-            try!(write!(f, " {:?}", arg));
+            write!(f, " {:?}", arg)?;
         }
         Ok(())
     }
@@ -589,7 +589,7 @@ impl Process {
             return Ok(status)
         }
         let mut status = 0 as c_int;
-        try!(cvt_r(|| unsafe { libc::waitpid(self.pid, &mut status, 0) }));
+        cvt_r(|| unsafe { libc::waitpid(self.pid, &mut status, 0) })?;
         self.status = Some(ExitStatus(status));
         Ok(ExitStatus(status))
     }
diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs
index fa504ade084..92c3bf8829a 100644
--- a/src/libstd/sys/unix/rand.rs
+++ b/src/libstd/sys/unix/rand.rs
@@ -138,7 +138,7 @@ mod imp {
                 return Ok(OsRng { inner: OsGetrandomRng });
             }
 
-            let reader = try!(File::open("/dev/urandom"));
+            let reader = File::open("/dev/urandom")?;
             let reader_rng = ReaderRng::new(reader);
 
             Ok(OsRng { inner: OsReaderRng(reader_rng) })