about summary refs log tree commit diff
path: root/src/libstd/sys/unix
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2019-11-27 10:28:39 -0800
committerDavid Tolnay <dtolnay@gmail.com>2019-11-29 18:37:58 -0800
commitc34fbfaad38cf5829ef5cfe780dc9d58480adeaa (patch)
treee57b66ed06aec18dc13ff7f14a243ca3dc3c27d1 /src/libstd/sys/unix
parent9081929d45f12d3f56d43b1d6db7519981580fc9 (diff)
downloadrust-c34fbfaad38cf5829ef5cfe780dc9d58480adeaa.tar.gz
rust-c34fbfaad38cf5829ef5cfe780dc9d58480adeaa.zip
Format libstd/sys with rustfmt
This commit applies rustfmt with rust-lang/rust's default settings to
files in src/libstd/sys *that are not involved in any currently open PR*
to minimize merge conflicts. THe list of files involved in open PRs was
determined by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8

With the list of files from the script in outstanding_files, the
relevant commands were:

    $ find src/libstd/sys -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd/sys outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of the files.

To confirm no funny business:

    $ git checkout $THIS_COMMIT^
    $ git show --pretty= --name-only $THIS_COMMIT \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ git diff $THIS_COMMIT  # there should be no difference
Diffstat (limited to 'src/libstd/sys/unix')
-rw-r--r--src/libstd/sys/unix/alloc.rs20
-rw-r--r--src/libstd/sys/unix/android.rs51
-rw-r--r--src/libstd/sys/unix/cmath.rs4
-rw-r--r--src/libstd/sys/unix/ext/fs.rs108
-rw-r--r--src/libstd/sys/unix/ext/io.rs26
-rw-r--r--src/libstd/sys/unix/ext/process.rs19
-rw-r--r--src/libstd/sys/unix/ext/raw.rs25
-rw-r--r--src/libstd/sys/unix/fast_thread_local.rs40
-rw-r--r--src/libstd/sys/unix/fd.rs131
-rw-r--r--src/libstd/sys/unix/io.rs24
-rw-r--r--src/libstd/sys/unix/l4re.rs74
-rw-r--r--src/libstd/sys/unix/memchr.rs23
-rw-r--r--src/libstd/sys/unix/net.rs112
-rw-r--r--src/libstd/sys/unix/path.rs2
-rw-r--r--src/libstd/sys/unix/pipe.rs38
-rw-r--r--src/libstd/sys/unix/process/process_common.rs64
-rw-r--r--src/libstd/sys/unix/process/process_fuchsia.rs102
-rw-r--r--src/libstd/sys/unix/process/zircon.rs173
-rw-r--r--src/libstd/sys/unix/rand.rs63
-rw-r--r--src/libstd/sys/unix/stack_overflow.rs87
-rw-r--r--src/libstd/sys/unix/stdio.rs14
-rw-r--r--src/libstd/sys/unix/thread.rs172
-rw-r--r--src/libstd/sys/unix/thread_local.rs2
-rw-r--r--src/libstd/sys/unix/weak.rs6
24 files changed, 775 insertions, 605 deletions
diff --git a/src/libstd/sys/unix/alloc.rs b/src/libstd/sys/unix/alloc.rs
index cf4900b4894..77417e41331 100644
--- a/src/libstd/sys/unix/alloc.rs
+++ b/src/libstd/sys/unix/alloc.rs
@@ -1,6 +1,6 @@
-use crate::ptr;
-use crate::sys_common::alloc::{MIN_ALIGN, realloc_fallback};
 use crate::alloc::{GlobalAlloc, Layout, System};
+use crate::ptr;
+use crate::sys_common::alloc::{realloc_fallback, MIN_ALIGN};
 
 #[stable(feature = "alloc_system_type", since = "1.28.0")]
 unsafe impl GlobalAlloc for System {
@@ -16,7 +16,7 @@ unsafe impl GlobalAlloc for System {
             #[cfg(target_os = "macos")]
             {
                 if layout.align() > (1 << 31) {
-                    return ptr::null_mut()
+                    return ptr::null_mut();
                 }
             }
             aligned_malloc(&layout)
@@ -52,9 +52,7 @@ unsafe impl GlobalAlloc for System {
     }
 }
 
-#[cfg(any(target_os = "android",
-          target_os = "redox",
-          target_os = "solaris"))]
+#[cfg(any(target_os = "android", target_os = "redox", target_os = "solaris"))]
 #[inline]
 unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
     // On android we currently target API level 9 which unfortunately
@@ -77,9 +75,7 @@ unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
     libc::memalign(layout.align(), layout.size()) as *mut u8
 }
 
-#[cfg(not(any(target_os = "android",
-              target_os = "redox",
-              target_os = "solaris")))]
+#[cfg(not(any(target_os = "android", target_os = "redox", target_os = "solaris")))]
 #[inline]
 unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
     let mut out = ptr::null_mut();
@@ -87,9 +83,5 @@ unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
     // Since these are all powers of 2, we can just use max.
     let align = layout.align().max(crate::mem::size_of::<usize>());
     let ret = libc::posix_memalign(&mut out, align, layout.size());
-    if ret != 0 {
-        ptr::null_mut()
-    } else {
-        out as *mut u8
-    }
+    if ret != 0 { ptr::null_mut() } else { out as *mut u8 }
 }
diff --git a/src/libstd/sys/unix/android.rs b/src/libstd/sys/unix/android.rs
index 6774160bb25..c5e9d66e85e 100644
--- a/src/libstd/sys/unix/android.rs
+++ b/src/libstd/sys/unix/android.rs
@@ -21,8 +21,8 @@
 use libc::{c_int, c_void, sighandler_t, size_t, ssize_t};
 use libc::{ftruncate, pread, pwrite};
 
-use crate::io;
 use super::{cvt, cvt_r};
+use crate::io;
 
 // The `log2` and `log2f` functions apparently appeared in android-18, or at
 // least you can see they're not present in the android-17 header [1] and they
@@ -96,8 +96,7 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
             Some(f) => cvt_r(|| f(fd, size as i64)).map(|_| ()),
             None => {
                 if size > i32::max_value() as u64 {
-                    Err(io::Error::new(io::ErrorKind::InvalidInput,
-                                       "cannot truncate >2GB"))
+                    Err(io::Error::new(io::ErrorKind::InvalidInput, "cannot truncate >2GB"))
                 } else {
                     cvt_r(|| ftruncate(fd, size as i32)).map(|_| ())
                 }
@@ -108,53 +107,61 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
 
 #[cfg(target_pointer_width = "64")]
 pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
-    unsafe {
-        cvt_r(|| ftruncate(fd, size as i64)).map(|_| ())
-    }
+    unsafe { cvt_r(|| ftruncate(fd, size as i64)).map(|_| ()) }
 }
 
 #[cfg(target_pointer_width = "32")]
-pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i64)
-    -> io::Result<ssize_t>
-{
+pub unsafe fn cvt_pread64(
+    fd: c_int,
+    buf: *mut c_void,
+    count: size_t,
+    offset: i64,
+) -> io::Result<ssize_t> {
     use crate::convert::TryInto;
     weak!(fn pread64(c_int, *mut c_void, size_t, i64) -> ssize_t);
     pread64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| {
         if let Ok(o) = offset.try_into() {
             cvt(pread(fd, buf, count, o))
         } else {
-            Err(io::Error::new(io::ErrorKind::InvalidInput,
-                               "cannot pread >2GB"))
+            Err(io::Error::new(io::ErrorKind::InvalidInput, "cannot pread >2GB"))
         }
     })
 }
 
 #[cfg(target_pointer_width = "32")]
-pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64)
-    -> io::Result<ssize_t>
-{
+pub unsafe fn cvt_pwrite64(
+    fd: c_int,
+    buf: *const c_void,
+    count: size_t,
+    offset: i64,
+) -> io::Result<ssize_t> {
     use crate::convert::TryInto;
     weak!(fn pwrite64(c_int, *const c_void, size_t, i64) -> ssize_t);
     pwrite64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| {
         if let Ok(o) = offset.try_into() {
             cvt(pwrite(fd, buf, count, o))
         } else {
-            Err(io::Error::new(io::ErrorKind::InvalidInput,
-                               "cannot pwrite >2GB"))
+            Err(io::Error::new(io::ErrorKind::InvalidInput, "cannot pwrite >2GB"))
         }
     })
 }
 
 #[cfg(target_pointer_width = "64")]
-pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i64)
-    -> io::Result<ssize_t>
-{
+pub unsafe fn cvt_pread64(
+    fd: c_int,
+    buf: *mut c_void,
+    count: size_t,
+    offset: i64,
+) -> io::Result<ssize_t> {
     cvt(pread(fd, buf, count, offset))
 }
 
 #[cfg(target_pointer_width = "64")]
-pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64)
-    -> io::Result<ssize_t>
-{
+pub unsafe fn cvt_pwrite64(
+    fd: c_int,
+    buf: *const c_void,
+    count: size_t,
+    offset: i64,
+) -> io::Result<ssize_t> {
     cvt(pwrite(fd, buf, count, offset))
 }
diff --git a/src/libstd/sys/unix/cmath.rs b/src/libstd/sys/unix/cmath.rs
index f6bb58934fc..2916ebe4440 100644
--- a/src/libstd/sys/unix/cmath.rs
+++ b/src/libstd/sys/unix/cmath.rs
@@ -1,9 +1,9 @@
 #![cfg(not(test))]
 
-use libc::{c_float, c_double};
+use libc::{c_double, c_float};
 
 #[link_name = "m"]
-extern {
+extern "C" {
     pub fn acos(n: c_double) -> c_double;
     pub fn acosf(n: c_float) -> c_float;
     pub fn asin(n: c_double) -> c_double;
diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs
index 0c52dc5b81b..732cd677a18 100644
--- a/src/libstd/sys/unix/ext/fs.rs
+++ b/src/libstd/sys/unix/ext/fs.rs
@@ -2,12 +2,12 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use crate::fs::{self, Permissions, OpenOptions};
+use crate::fs::{self, OpenOptions, Permissions};
 use crate::io;
 use crate::path::Path;
 use crate::sys;
-use crate::sys_common::{FromInner, AsInner, AsInnerMut};
 use crate::sys::platform::fs::MetadataExt as UnixMetadataExt;
+use crate::sys_common::{AsInner, AsInnerMut, FromInner};
 
 /// Unix-specific extensions to [`File`].
 ///
@@ -112,8 +112,7 @@ pub trait FileExt {
             }
         }
         if !buf.is_empty() {
-            Err(io::Error::new(io::ErrorKind::UnexpectedEof,
-                               "failed to fill whole buffer"))
+            Err(io::Error::new(io::ErrorKind::UnexpectedEof, "failed to fill whole buffer"))
         } else {
             Ok(())
         }
@@ -195,8 +194,12 @@ pub trait FileExt {
     fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> {
         while !buf.is_empty() {
             match self.write_at(buf, offset) {
-                Ok(0) => return Err(io::Error::new(io::ErrorKind::WriteZero,
-                                                   "failed to write whole buffer")),
+                Ok(0) => {
+                    return Err(io::Error::new(
+                        io::ErrorKind::WriteZero,
+                        "failed to write whole buffer",
+                    ));
+                }
                 Ok(n) => {
                     buf = &buf[n..];
                     offset += n as u64
@@ -356,11 +359,13 @@ pub trait OpenOptionsExt {
 #[stable(feature = "fs_ext", since = "1.1.0")]
 impl OpenOptionsExt for OpenOptions {
     fn mode(&mut self, mode: u32) -> &mut OpenOptions {
-        self.as_inner_mut().mode(mode); self
+        self.as_inner_mut().mode(mode);
+        self
     }
 
     fn custom_flags(&mut self, flags: i32) -> &mut OpenOptions {
-        self.as_inner_mut().custom_flags(flags); self
+        self.as_inner_mut().custom_flags(flags);
+        self
     }
 }
 
@@ -657,22 +662,54 @@ pub trait MetadataExt {
 
 #[stable(feature = "metadata_ext", since = "1.1.0")]
 impl MetadataExt for fs::Metadata {
-    fn dev(&self) -> u64 { self.st_dev() }
-    fn ino(&self) -> u64 { self.st_ino() }
-    fn mode(&self) -> u32 { self.st_mode() }
-    fn nlink(&self) -> u64 { self.st_nlink() }
-    fn uid(&self) -> u32 { self.st_uid() }
-    fn gid(&self) -> u32 { self.st_gid() }
-    fn rdev(&self) -> u64 { self.st_rdev() }
-    fn size(&self) -> u64 { self.st_size() }
-    fn atime(&self) -> i64 { self.st_atime() }
-    fn atime_nsec(&self) -> i64 { self.st_atime_nsec() }
-    fn mtime(&self) -> i64 { self.st_mtime() }
-    fn mtime_nsec(&self) -> i64 { self.st_mtime_nsec() }
-    fn ctime(&self) -> i64 { self.st_ctime() }
-    fn ctime_nsec(&self) -> i64 { self.st_ctime_nsec() }
-    fn blksize(&self) -> u64 { self.st_blksize() }
-    fn blocks(&self) -> u64 { self.st_blocks() }
+    fn dev(&self) -> u64 {
+        self.st_dev()
+    }
+    fn ino(&self) -> u64 {
+        self.st_ino()
+    }
+    fn mode(&self) -> u32 {
+        self.st_mode()
+    }
+    fn nlink(&self) -> u64 {
+        self.st_nlink()
+    }
+    fn uid(&self) -> u32 {
+        self.st_uid()
+    }
+    fn gid(&self) -> u32 {
+        self.st_gid()
+    }
+    fn rdev(&self) -> u64 {
+        self.st_rdev()
+    }
+    fn size(&self) -> u64 {
+        self.st_size()
+    }
+    fn atime(&self) -> i64 {
+        self.st_atime()
+    }
+    fn atime_nsec(&self) -> i64 {
+        self.st_atime_nsec()
+    }
+    fn mtime(&self) -> i64 {
+        self.st_mtime()
+    }
+    fn mtime_nsec(&self) -> i64 {
+        self.st_mtime_nsec()
+    }
+    fn ctime(&self) -> i64 {
+        self.st_ctime()
+    }
+    fn ctime_nsec(&self) -> i64 {
+        self.st_ctime_nsec()
+    }
+    fn blksize(&self) -> u64 {
+        self.st_blksize()
+    }
+    fn blocks(&self) -> u64 {
+        self.st_blocks()
+    }
 }
 
 /// Unix-specific extensions for [`FileType`].
@@ -759,10 +796,18 @@ pub trait FileTypeExt {
 
 #[stable(feature = "file_type_ext", since = "1.5.0")]
 impl FileTypeExt for fs::FileType {
-    fn is_block_device(&self) -> bool { self.as_inner().is(libc::S_IFBLK) }
-    fn is_char_device(&self) -> bool { self.as_inner().is(libc::S_IFCHR) }
-    fn is_fifo(&self) -> bool { self.as_inner().is(libc::S_IFIFO) }
-    fn is_socket(&self) -> bool { self.as_inner().is(libc::S_IFSOCK) }
+    fn is_block_device(&self) -> bool {
+        self.as_inner().is(libc::S_IFBLK)
+    }
+    fn is_char_device(&self) -> bool {
+        self.as_inner().is(libc::S_IFCHR)
+    }
+    fn is_fifo(&self) -> bool {
+        self.as_inner().is(libc::S_IFIFO)
+    }
+    fn is_socket(&self) -> bool {
+        self.as_inner().is(libc::S_IFSOCK)
+    }
 }
 
 /// Unix-specific extension methods for [`fs::DirEntry`].
@@ -794,7 +839,9 @@ pub trait DirEntryExt {
 
 #[stable(feature = "dir_entry_ext", since = "1.1.0")]
 impl DirEntryExt for fs::DirEntry {
-    fn ino(&self) -> u64 { self.as_inner().ino() }
+    fn ino(&self) -> u64 {
+        self.as_inner().ino()
+    }
 }
 
 /// Creates a new symbolic link on the filesystem.
@@ -821,8 +868,7 @@ impl DirEntryExt for fs::DirEntry {
 /// }
 /// ```
 #[stable(feature = "symlink", since = "1.1.0")]
-pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>
-{
+pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
     sys::fs::symlink(src.as_ref(), dst.as_ref())
 }
 
diff --git a/src/libstd/sys/unix/ext/io.rs b/src/libstd/sys/unix/ext/io.rs
index 6bcc59495e3..5077e2e28d1 100644
--- a/src/libstd/sys/unix/ext/io.rs
+++ b/src/libstd/sys/unix/ext/io.rs
@@ -3,9 +3,9 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 use crate::fs;
+use crate::io;
 use crate::os::raw;
 use crate::sys;
-use crate::io;
 use crate::sys_common::{AsInner, FromInner, IntoInner};
 
 /// Raw file descriptors.
@@ -83,30 +83,42 @@ impl IntoRawFd for fs::File {
 
 #[stable(feature = "asraw_stdio", since = "1.21.0")]
 impl AsRawFd for io::Stdin {
-    fn as_raw_fd(&self) -> RawFd { libc::STDIN_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDIN_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio", since = "1.21.0")]
 impl AsRawFd for io::Stdout {
-    fn as_raw_fd(&self) -> RawFd { libc::STDOUT_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDOUT_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio", since = "1.21.0")]
 impl AsRawFd for io::Stderr {
-    fn as_raw_fd(&self) -> RawFd { libc::STDERR_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDERR_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
 impl<'a> AsRawFd for io::StdinLock<'a> {
-    fn as_raw_fd(&self) -> RawFd { libc::STDIN_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDIN_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
 impl<'a> AsRawFd for io::StdoutLock<'a> {
-    fn as_raw_fd(&self) -> RawFd { libc::STDOUT_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDOUT_FILENO
+    }
 }
 
 #[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
 impl<'a> AsRawFd for io::StderrLock<'a> {
-    fn as_raw_fd(&self) -> RawFd { libc::STDERR_FILENO }
+    fn as_raw_fd(&self) -> RawFd {
+        libc::STDERR_FILENO
+    }
 }
diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs
index 0e95f97486b..fa8670b4aec 100644
--- a/src/libstd/sys/unix/ext/process.rs
+++ b/src/libstd/sys/unix/ext/process.rs
@@ -4,10 +4,10 @@
 
 use crate::ffi::OsStr;
 use crate::io;
-use crate::os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
+use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
 use crate::process;
 use crate::sys;
-use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
+use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
 
 /// Unix-specific extensions to the [`process::Command`] builder.
 ///
@@ -56,7 +56,8 @@ pub trait CommandExt {
     /// locations may not appear where intended.
     #[stable(feature = "process_pre_exec", since = "1.34.0")]
     unsafe fn pre_exec<F>(&mut self, f: F) -> &mut process::Command
-        where F: FnMut() -> io::Result<()> + Send + Sync + 'static;
+    where
+        F: FnMut() -> io::Result<()> + Send + Sync + 'static;
 
     /// Schedules a closure to be run just before the `exec` function is
     /// invoked.
@@ -68,7 +69,8 @@ pub trait CommandExt {
     #[stable(feature = "process_exec", since = "1.15.0")]
     #[rustc_deprecated(since = "1.37.0", reason = "should be unsafe, use `pre_exec` instead")]
     fn before_exec<F>(&mut self, f: F) -> &mut process::Command
-        where F: FnMut() -> io::Result<()> + Send + Sync + 'static
+    where
+        F: FnMut() -> io::Result<()> + Send + Sync + 'static,
     {
         unsafe { self.pre_exec(f) }
     }
@@ -111,7 +113,8 @@ pub trait CommandExt {
     /// default executable path.
     #[unstable(feature = "process_set_argv0", issue = "66510")]
     fn arg0<S>(&mut self, arg: S) -> &mut process::Command
-        where S: AsRef<OsStr>;
+    where
+        S: AsRef<OsStr>;
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -127,7 +130,8 @@ impl CommandExt for process::Command {
     }
 
     unsafe fn pre_exec<F>(&mut self, f: F) -> &mut process::Command
-        where F: FnMut() -> io::Result<()> + Send + Sync + 'static
+    where
+        F: FnMut() -> io::Result<()> + Send + Sync + 'static,
     {
         self.as_inner_mut().pre_exec(Box::new(f));
         self
@@ -138,7 +142,8 @@ impl CommandExt for process::Command {
     }
 
     fn arg0<S>(&mut self, arg: S) -> &mut process::Command
-        where S: AsRef<OsStr>
+    where
+        S: AsRef<OsStr>,
     {
         self.as_inner_mut().set_arg_0(arg.as_ref());
         self
diff --git a/src/libstd/sys/unix/ext/raw.rs b/src/libstd/sys/unix/ext/raw.rs
index 75ae54a919a..d81368a18b4 100644
--- a/src/libstd/sys/unix/ext/raw.rs
+++ b/src/libstd/sys/unix/ext/raw.rs
@@ -1,23 +1,28 @@
 //! Unix-specific primitives available on all unix platforms
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
-#![rustc_deprecated(since = "1.8.0",
-                    reason = "these type aliases are no longer supported by \
-                              the standard library, the `libc` crate on \
-                              crates.io should be used instead for the correct \
-                              definitions")]
+#![rustc_deprecated(
+    since = "1.8.0",
+    reason = "these type aliases are no longer supported by \
+              the standard library, the `libc` crate on \
+              crates.io should be used instead for the correct \
+              definitions"
+)]
 #![allow(deprecated)]
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type pid_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type uid_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type gid_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type pid_t = i32;
 
 #[doc(inline)]
 #[stable(feature = "pthread_t", since = "1.8.0")]
 pub use crate::sys::platform::raw::pthread_t;
 #[doc(inline)]
 #[stable(feature = "raw_ext", since = "1.1.0")]
-pub use crate::sys::platform::raw::{dev_t, ino_t, mode_t, nlink_t, off_t, blksize_t};
+pub use crate::sys::platform::raw::{blkcnt_t, time_t};
 #[doc(inline)]
 #[stable(feature = "raw_ext", since = "1.1.0")]
-pub use crate::sys::platform::raw::{blkcnt_t, time_t};
+pub use crate::sys::platform::raw::{blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t};
diff --git a/src/libstd/sys/unix/fast_thread_local.rs b/src/libstd/sys/unix/fast_thread_local.rs
index 7d718032ef6..dfb9307daea 100644
--- a/src/libstd/sys/unix/fast_thread_local.rs
+++ b/src/libstd/sys/unix/fast_thread_local.rs
@@ -10,25 +10,34 @@
 // fallback implementation to use as well.
 //
 // Due to rust-lang/rust#18804, make sure this is not generic!
-#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox",
-          target_os = "emscripten"))]
-pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
+#[cfg(any(
+    target_os = "linux",
+    target_os = "fuchsia",
+    target_os = "redox",
+    target_os = "emscripten"
+))]
+pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
     use crate::mem;
     use crate::sys_common::thread_local::register_dtor_fallback;
 
-    extern {
+    extern "C" {
         #[linkage = "extern_weak"]
         static __dso_handle: *mut u8;
         #[linkage = "extern_weak"]
         static __cxa_thread_atexit_impl: *const libc::c_void;
     }
     if !__cxa_thread_atexit_impl.is_null() {
-        type F = unsafe extern fn(dtor: unsafe extern fn(*mut u8),
-                                  arg: *mut u8,
-                                  dso_handle: *mut u8) -> libc::c_int;
-        mem::transmute::<*const libc::c_void, F>(__cxa_thread_atexit_impl)
-            (dtor, t, &__dso_handle as *const _ as *mut _);
-        return
+        type F = unsafe extern "C" fn(
+            dtor: unsafe extern "C" fn(*mut u8),
+            arg: *mut u8,
+            dso_handle: *mut u8,
+        ) -> libc::c_int;
+        mem::transmute::<*const libc::c_void, F>(__cxa_thread_atexit_impl)(
+            dtor,
+            t,
+            &__dso_handle as *const _ as *mut _,
+        );
+        return;
     }
     register_dtor_fallback(t, dtor);
 }
@@ -44,7 +53,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
 // thread. thread_local dtors are pushed to the DTOR list without calling
 // _tlv_atexit.
 #[cfg(target_os = "macos")]
-pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
+pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
     use crate::cell::Cell;
     use crate::ptr;
 
@@ -55,7 +64,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
         REGISTERED.set(true);
     }
 
-    type List = Vec<(*mut u8, unsafe extern fn(*mut u8))>;
+    type List = Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>;
 
     #[thread_local]
     static DTORS: Cell<*mut List> = Cell::new(ptr::null_mut());
@@ -64,15 +73,14 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
         DTORS.set(Box::into_raw(v));
     }
 
-    extern {
-        fn _tlv_atexit(dtor: unsafe extern fn(*mut u8),
-                       arg: *mut u8);
+    extern "C" {
+        fn _tlv_atexit(dtor: unsafe extern "C" fn(*mut u8), arg: *mut u8);
     }
 
     let list: &mut List = &mut *DTORS.get();
     list.push((t, dtor));
 
-    unsafe extern fn run_dtors(_: *mut u8) {
+    unsafe extern "C" fn run_dtors(_: *mut u8) {
         let mut ptr = DTORS.replace(ptr::null_mut());
         while !ptr.is_null() {
             let list = Box::from_raw(ptr);
diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs
index ba611a6b7e7..53b50763fbf 100644
--- a/src/libstd/sys/unix/fd.rs
+++ b/src/libstd/sys/unix/fd.rs
@@ -1,7 +1,7 @@
 #![unstable(reason = "not public", issue = "0", feature = "fd")]
 
 use crate::cmp;
-use crate::io::{self, Read, Initializer, IoSlice, IoSliceMut};
+use crate::io::{self, Initializer, IoSlice, IoSliceMut, Read};
 use crate::mem;
 use crate::sync::atomic::{AtomicBool, Ordering};
 use crate::sys::cvt;
@@ -35,7 +35,9 @@ impl FileDesc {
         FileDesc { fd }
     }
 
-    pub fn raw(&self) -> c_int { self.fd }
+    pub fn raw(&self) -> c_int {
+        self.fd
+    }
 
     /// Extracts the actual file descriptor without closing it.
     pub fn into_raw(self) -> c_int {
@@ -46,18 +48,18 @@ impl FileDesc {
 
     pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
         let ret = cvt(unsafe {
-            libc::read(self.fd,
-                       buf.as_mut_ptr() as *mut c_void,
-                       cmp::min(buf.len(), max_len()))
+            libc::read(self.fd, buf.as_mut_ptr() as *mut c_void, cmp::min(buf.len(), max_len()))
         })?;
         Ok(ret as usize)
     }
 
     pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
         let ret = cvt(unsafe {
-            libc::readv(self.fd,
-                        bufs.as_ptr() as *const libc::iovec,
-                        cmp::min(bufs.len(), c_int::max_value() as usize) as c_int)
+            libc::readv(
+                self.fd,
+                bufs.as_ptr() as *const libc::iovec,
+                cmp::min(bufs.len(), c_int::max_value() as usize) as c_int,
+            )
         })?;
         Ok(ret as usize)
     }
@@ -72,39 +74,44 @@ impl FileDesc {
         use super::android::cvt_pread64;
 
         #[cfg(not(target_os = "android"))]
-        unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: usize, offset: i64)
-            -> io::Result<isize>
-        {
-            #[cfg(target_os = "linux")]
-            use libc::pread64;
+        unsafe fn cvt_pread64(
+            fd: c_int,
+            buf: *mut c_void,
+            count: usize,
+            offset: i64,
+        ) -> io::Result<isize> {
             #[cfg(not(target_os = "linux"))]
             use libc::pread as pread64;
+            #[cfg(target_os = "linux")]
+            use libc::pread64;
             cvt(pread64(fd, buf, count, offset))
         }
 
         unsafe {
-            cvt_pread64(self.fd,
-                        buf.as_mut_ptr() as *mut c_void,
-                        cmp::min(buf.len(), max_len()),
-                        offset as i64)
-                .map(|n| n as usize)
+            cvt_pread64(
+                self.fd,
+                buf.as_mut_ptr() as *mut c_void,
+                cmp::min(buf.len(), max_len()),
+                offset as i64,
+            )
+            .map(|n| n as usize)
         }
     }
 
     pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
         let ret = cvt(unsafe {
-            libc::write(self.fd,
-                        buf.as_ptr() as *const c_void,
-                        cmp::min(buf.len(), max_len()))
+            libc::write(self.fd, buf.as_ptr() as *const c_void, cmp::min(buf.len(), max_len()))
         })?;
         Ok(ret as usize)
     }
 
     pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
         let ret = cvt(unsafe {
-            libc::writev(self.fd,
-                         bufs.as_ptr() as *const libc::iovec,
-                         cmp::min(bufs.len(), c_int::max_value() as usize) as c_int)
+            libc::writev(
+                self.fd,
+                bufs.as_ptr() as *const libc::iovec,
+                cmp::min(bufs.len(), c_int::max_value() as usize) as c_int,
+            )
         })?;
         Ok(ret as usize)
     }
@@ -114,54 +121,61 @@ impl FileDesc {
         use super::android::cvt_pwrite64;
 
         #[cfg(not(target_os = "android"))]
-        unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: usize, offset: i64)
-            -> io::Result<isize>
-        {
-            #[cfg(target_os = "linux")]
-            use libc::pwrite64;
+        unsafe fn cvt_pwrite64(
+            fd: c_int,
+            buf: *const c_void,
+            count: usize,
+            offset: i64,
+        ) -> io::Result<isize> {
             #[cfg(not(target_os = "linux"))]
             use libc::pwrite as pwrite64;
+            #[cfg(target_os = "linux")]
+            use libc::pwrite64;
             cvt(pwrite64(fd, buf, count, offset))
         }
 
         unsafe {
-            cvt_pwrite64(self.fd,
-                         buf.as_ptr() as *const c_void,
-                         cmp::min(buf.len(), max_len()),
-                         offset as i64)
-                .map(|n| n as usize)
+            cvt_pwrite64(
+                self.fd,
+                buf.as_ptr() as *const c_void,
+                cmp::min(buf.len(), max_len()),
+                offset as i64,
+            )
+            .map(|n| n as usize)
         }
     }
 
     #[cfg(target_os = "linux")]
     pub fn get_cloexec(&self) -> io::Result<bool> {
-        unsafe {
-            Ok((cvt(libc::fcntl(self.fd, libc::F_GETFD))? & libc::FD_CLOEXEC) != 0)
-        }
+        unsafe { Ok((cvt(libc::fcntl(self.fd, libc::F_GETFD))? & libc::FD_CLOEXEC) != 0) }
     }
 
-    #[cfg(not(any(target_env = "newlib",
-                  target_os = "solaris",
-                  target_os = "emscripten",
-                  target_os = "fuchsia",
-                  target_os = "l4re",
-                  target_os = "linux",
-                  target_os = "haiku",
-                  target_os = "redox")))]
+    #[cfg(not(any(
+        target_env = "newlib",
+        target_os = "solaris",
+        target_os = "emscripten",
+        target_os = "fuchsia",
+        target_os = "l4re",
+        target_os = "linux",
+        target_os = "haiku",
+        target_os = "redox"
+    )))]
     pub fn set_cloexec(&self) -> io::Result<()> {
         unsafe {
             cvt(libc::ioctl(self.fd, libc::FIOCLEX))?;
             Ok(())
         }
     }
-    #[cfg(any(target_env = "newlib",
-              target_os = "solaris",
-              target_os = "emscripten",
-              target_os = "fuchsia",
-              target_os = "l4re",
-              target_os = "linux",
-              target_os = "haiku",
-              target_os = "redox"))]
+    #[cfg(any(
+        target_env = "newlib",
+        target_os = "solaris",
+        target_os = "emscripten",
+        target_os = "fuchsia",
+        target_os = "l4re",
+        target_os = "linux",
+        target_os = "haiku",
+        target_os = "redox"
+    ))]
     pub fn set_cloexec(&self) -> io::Result<()> {
         unsafe {
             let previous = cvt(libc::fcntl(self.fd, libc::F_GETFD))?;
@@ -216,7 +230,7 @@ impl FileDesc {
         // [1]: http://comments.gmane.org/gmane.linux.lib.musl.general/2963
         #[cfg(any(target_os = "android", target_os = "haiku"))]
         use libc::F_DUPFD as F_DUPFD_CLOEXEC;
-        #[cfg(not(any(target_os = "android", target_os="haiku")))]
+        #[cfg(not(any(target_os = "android", target_os = "haiku")))]
         use libc::F_DUPFD_CLOEXEC;
 
         let make_filedesc = |fd| {
@@ -224,8 +238,7 @@ impl FileDesc {
             fd.set_cloexec()?;
             Ok(fd)
         };
-        static TRY_CLOEXEC: AtomicBool =
-            AtomicBool::new(!cfg!(target_os = "android"));
+        static TRY_CLOEXEC: AtomicBool = AtomicBool::new(!cfg!(target_os = "android"));
         let fd = self.raw();
         if TRY_CLOEXEC.load(Ordering::Relaxed) {
             match cvt(unsafe { libc::fcntl(fd, F_DUPFD_CLOEXEC, 0) }) {
@@ -237,7 +250,7 @@ impl FileDesc {
                         make_filedesc(fd)?
                     } else {
                         FileDesc::new(fd)
-                    })
+                    });
                 }
                 Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => {
                     TRY_CLOEXEC.store(false, Ordering::Relaxed);
@@ -261,7 +274,9 @@ impl<'a> Read for &'a FileDesc {
 }
 
 impl AsInner<c_int> for FileDesc {
-    fn as_inner(&self) -> &c_int { &self.fd }
+    fn as_inner(&self) -> &c_int {
+        &self.fd
+    }
 }
 
 impl Drop for FileDesc {
diff --git a/src/libstd/sys/unix/io.rs b/src/libstd/sys/unix/io.rs
index a3a72919176..b4a64e93c84 100644
--- a/src/libstd/sys/unix/io.rs
+++ b/src/libstd/sys/unix/io.rs
@@ -1,7 +1,7 @@
 use crate::marker::PhantomData;
 use crate::slice;
 
-use libc::{iovec, c_void};
+use libc::{c_void, iovec};
 
 #[repr(transparent)]
 pub struct IoSlice<'a> {
@@ -13,10 +13,7 @@ impl<'a> IoSlice<'a> {
     #[inline]
     pub fn new(buf: &'a [u8]) -> IoSlice<'a> {
         IoSlice {
-            vec: iovec {
-                iov_base: buf.as_ptr() as *mut u8 as *mut c_void,
-                iov_len: buf.len()
-            },
+            vec: iovec { iov_base: buf.as_ptr() as *mut u8 as *mut c_void, iov_len: buf.len() },
             _p: PhantomData,
         }
     }
@@ -35,9 +32,7 @@ impl<'a> IoSlice<'a> {
 
     #[inline]
     pub fn as_slice(&self) -> &[u8] {
-        unsafe {
-            slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len)
-        }
+        unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) }
     }
 }
 
@@ -51,10 +46,7 @@ impl<'a> IoSliceMut<'a> {
     #[inline]
     pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> {
         IoSliceMut {
-            vec: iovec {
-                iov_base: buf.as_mut_ptr() as *mut c_void,
-                iov_len: buf.len()
-            },
+            vec: iovec { iov_base: buf.as_mut_ptr() as *mut c_void, iov_len: buf.len() },
             _p: PhantomData,
         }
     }
@@ -73,15 +65,11 @@ impl<'a> IoSliceMut<'a> {
 
     #[inline]
     pub fn as_slice(&self) -> &[u8] {
-        unsafe {
-            slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len)
-        }
+        unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) }
     }
 
     #[inline]
     pub fn as_mut_slice(&mut self) -> &mut [u8] {
-        unsafe {
-            slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len)
-        }
+        unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) }
     }
 }
diff --git a/src/libstd/sys/unix/l4re.rs b/src/libstd/sys/unix/l4re.rs
index 2c6f21aa21a..c6e4f5693ed 100644
--- a/src/libstd/sys/unix/l4re.rs
+++ b/src/libstd/sys/unix/l4re.rs
@@ -1,16 +1,18 @@
 macro_rules! unimpl {
-    () => (return Err(io::Error::new(io::ErrorKind::Other, "No networking available on L4Re."));)
+    () => {
+        return Err(io::Error::new(io::ErrorKind::Other, "No networking available on L4Re."));
+    };
 }
 
 pub mod net {
     #![allow(warnings)]
+    use crate::convert::TryFrom;
     use crate::fmt;
     use crate::io::{self, IoSlice, IoSliceMut};
-    use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
-    use crate::sys_common::{AsInner, FromInner, IntoInner};
+    use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
     use crate::sys::fd::FileDesc;
+    use crate::sys_common::{AsInner, FromInner, IntoInner};
     use crate::time::Duration;
-    use crate::convert::TryFrom;
 
     #[allow(unused_extern_crates)]
     pub extern crate libc as netc;
@@ -33,8 +35,11 @@ pub mod net {
             unimpl!();
         }
 
-        pub fn accept(&self, _: *mut libc::sockaddr, _: *mut libc::socklen_t)
-                  -> io::Result<Socket> {
+        pub fn accept(
+            &self,
+            _: *mut libc::sockaddr,
+            _: *mut libc::socklen_t,
+        ) -> io::Result<Socket> {
             unimpl!();
         }
 
@@ -100,15 +105,21 @@ pub mod net {
     }
 
     impl AsInner<libc::c_int> for Socket {
-        fn as_inner(&self) -> &libc::c_int { self.0.as_inner() }
+        fn as_inner(&self) -> &libc::c_int {
+            self.0.as_inner()
+        }
     }
 
     impl FromInner<libc::c_int> for Socket {
-        fn from_inner(fd: libc::c_int) -> Socket { Socket(FileDesc::new(fd)) }
+        fn from_inner(fd: libc::c_int) -> Socket {
+            Socket(FileDesc::new(fd))
+        }
     }
 
     impl IntoInner<libc::c_int> for Socket {
-        fn into_inner(self) -> libc::c_int { self.0.into_raw() }
+        fn into_inner(self) -> libc::c_int {
+            self.0.into_raw()
+        }
     }
 
     pub struct TcpStream {
@@ -124,9 +135,13 @@ pub mod net {
             unimpl!();
         }
 
-        pub fn socket(&self) -> &Socket { &self.inner }
+        pub fn socket(&self) -> &Socket {
+            &self.inner
+        }
 
-        pub fn into_socket(self) -> Socket { self.inner }
+        pub fn into_socket(self) -> Socket {
+            self.inner
+        }
 
         pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
             unimpl!();
@@ -226,9 +241,13 @@ pub mod net {
             unimpl!();
         }
 
-        pub fn socket(&self) -> &Socket { &self.inner }
+        pub fn socket(&self) -> &Socket {
+            &self.inner
+        }
 
-        pub fn into_socket(self) -> Socket { self.inner }
+        pub fn into_socket(self) -> Socket {
+            self.inner
+        }
 
         pub fn socket_addr(&self) -> io::Result<SocketAddr> {
             unimpl!();
@@ -288,9 +307,13 @@ pub mod net {
             unimpl!();
         }
 
-        pub fn socket(&self) -> &Socket { &self.inner }
+        pub fn socket(&self) -> &Socket {
+            &self.inner
+        }
 
-        pub fn into_socket(self) -> Socket { self.inner }
+        pub fn into_socket(self) -> Socket {
+            self.inner
+        }
 
         pub fn peer_addr(&self) -> io::Result<SocketAddr> {
             unimpl!();
@@ -364,24 +387,20 @@ pub mod net {
             unimpl!();
         }
 
-        pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr)
-                             -> io::Result<()> {
-                                 unimpl!();
+        pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
+            unimpl!();
         }
 
-        pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32)
-                             -> io::Result<()> {
-                                 unimpl!();
+        pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
+            unimpl!();
         }
 
-        pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr)
-                              -> io::Result<()> {
-                                  unimpl!();
+        pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
+            unimpl!();
         }
 
-        pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32)
-                              -> io::Result<()> {
-                                  unimpl!();
+        pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
+            unimpl!();
         }
 
         pub fn set_ttl(&self, _: u32) -> io::Result<()> {
@@ -450,7 +469,6 @@ pub mod net {
     unsafe impl Sync for LookupHost {}
     unsafe impl Send for LookupHost {}
 
-
     impl TryFrom<&str> for LookupHost {
         type Error = io::Error;
 
diff --git a/src/libstd/sys/unix/memchr.rs b/src/libstd/sys/unix/memchr.rs
index 1984678bdde..a9273ea676c 100644
--- a/src/libstd/sys/unix/memchr.rs
+++ b/src/libstd/sys/unix/memchr.rs
@@ -6,32 +6,27 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
         libc::memchr(
             haystack.as_ptr() as *const libc::c_void,
             needle as libc::c_int,
-            haystack.len())
+            haystack.len(),
+        )
     };
-    if p.is_null() {
-        None
-    } else {
-        Some(p as usize - (haystack.as_ptr() as usize))
-    }
+    if p.is_null() { None } else { Some(p as usize - (haystack.as_ptr() as usize)) }
 }
 
 pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
-
     #[cfg(target_os = "linux")]
     fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> {
         // GNU's memrchr() will - unlike memchr() - error if haystack is empty.
-        if haystack.is_empty() {return None}
+        if haystack.is_empty() {
+            return None;
+        }
         let p = unsafe {
             libc::memrchr(
                 haystack.as_ptr() as *const libc::c_void,
                 needle as libc::c_int,
-                haystack.len())
+                haystack.len(),
+            )
         };
-        if p.is_null() {
-            None
-        } else {
-            Some(p as usize - (haystack.as_ptr() as usize))
-        }
+        if p.is_null() { None } else { Some(p as usize - (haystack.as_ptr() as usize)) }
     }
 
     #[cfg(not(target_os = "linux"))]
diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs
index 75750b5c4e5..946b2b9d8de 100644
--- a/src/libstd/sys/unix/net.rs
+++ b/src/libstd/sys/unix/net.rs
@@ -1,13 +1,13 @@
+use crate::cmp;
 use crate::ffi::CStr;
 use crate::io::{self, IoSlice, IoSliceMut};
 use crate::mem;
-use crate::net::{SocketAddr, Shutdown};
+use crate::net::{Shutdown, SocketAddr};
 use crate::str;
 use crate::sys::fd::FileDesc;
-use crate::sys_common::{AsInner, FromInner, IntoInner};
 use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
+use crate::sys_common::{AsInner, FromInner, IntoInner};
 use crate::time::{Duration, Instant};
-use crate::cmp;
 
 use libc::{c_int, c_void, size_t, sockaddr, socklen_t, EAI_SYSTEM, MSG_PEEK};
 
@@ -42,23 +42,23 @@ pub fn init() {}
 
 pub fn cvt_gai(err: c_int) -> io::Result<()> {
     if err == 0 {
-        return Ok(())
+        return Ok(());
     }
 
     // We may need to trigger a glibc workaround. See on_resolver_failure() for details.
     on_resolver_failure();
 
     if err == EAI_SYSTEM {
-        return Err(io::Error::last_os_error())
+        return Err(io::Error::last_os_error());
     }
 
     let detail = unsafe {
-        str::from_utf8(CStr::from_ptr(libc::gai_strerror(err)).to_bytes()).unwrap()
-            .to_owned()
+        str::from_utf8(CStr::from_ptr(libc::gai_strerror(err)).to_bytes()).unwrap().to_owned()
     };
-    Err(io::Error::new(io::ErrorKind::Other,
-                       &format!("failed to lookup address information: {}",
-                                detail)[..]))
+    Err(io::Error::new(
+        io::ErrorKind::Other,
+        &format!("failed to lookup address information: {}", detail)[..],
+    ))
 }
 
 impl Socket {
@@ -106,7 +106,7 @@ impl Socket {
                     Ok(_) => {
                         return Ok((Socket(FileDesc::new(fds[0])), Socket(FileDesc::new(fds[1]))));
                     }
-                    Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => {},
+                    Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => {}
                     Err(e) => return Err(e),
                 }
             }
@@ -135,15 +135,13 @@ impl Socket {
             Err(e) => return Err(e),
         }
 
-        let mut pollfd = libc::pollfd {
-            fd: self.0.raw(),
-            events: libc::POLLOUT,
-            revents: 0,
-        };
+        let mut pollfd = libc::pollfd { fd: self.0.raw(), events: libc::POLLOUT, revents: 0 };
 
         if timeout.as_secs() == 0 && timeout.subsec_nanos() == 0 {
-            return Err(io::Error::new(io::ErrorKind::InvalidInput,
-                                      "cannot set a 0 duration timeout"));
+            return Err(io::Error::new(
+                io::ErrorKind::InvalidInput,
+                "cannot set a 0 duration timeout",
+            ));
         }
 
         let start = Instant::now();
@@ -155,7 +153,8 @@ impl Socket {
             }
 
             let timeout = timeout - elapsed;
-            let mut timeout = timeout.as_secs()
+            let mut timeout = timeout
+                .as_secs()
                 .saturating_mul(1_000)
                 .saturating_add(timeout.subsec_nanos() as u64 / 1_000_000);
             if timeout == 0 {
@@ -176,10 +175,9 @@ impl Socket {
                     // linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look
                     // for POLLHUP rather than read readiness
                     if pollfd.revents & libc::POLLHUP != 0 {
-                        let e = self.take_error()?
-                            .unwrap_or_else(|| {
-                                io::Error::new(io::ErrorKind::Other, "no error set after POLLHUP")
-                            });
+                        let e = self.take_error()?.unwrap_or_else(|| {
+                            io::Error::new(io::ErrorKind::Other, "no error set after POLLHUP")
+                        });
                         return Err(e);
                     }
 
@@ -189,8 +187,7 @@ impl Socket {
         }
     }
 
-    pub fn accept(&self, storage: *mut sockaddr, len: *mut socklen_t)
-                  -> io::Result<Socket> {
+    pub fn accept(&self, storage: *mut sockaddr, len: *mut socklen_t) -> io::Result<Socket> {
         // Unfortunately the only known way right now to accept a socket and
         // atomically set the CLOEXEC flag is to use the `accept4` syscall on
         // Linux. This was added in 2.6.28, however, and because we support
@@ -204,9 +201,7 @@ impl Socket {
                     flags: c_int
                 ) -> c_int
             }
-            let res = cvt_r(|| unsafe {
-                accept4(self.0.raw(), storage, len, SOCK_CLOEXEC)
-            });
+            let res = cvt_r(|| unsafe { accept4(self.0.raw(), storage, len, SOCK_CLOEXEC) });
             match res {
                 Ok(fd) => return Ok(Socket(FileDesc::new(fd))),
                 Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {}
@@ -214,9 +209,7 @@ impl Socket {
             }
         }
 
-        let fd = cvt_r(|| unsafe {
-            libc::accept(self.0.raw(), storage, len)
-        })?;
+        let fd = cvt_r(|| unsafe { libc::accept(self.0.raw(), storage, len) })?;
         let fd = FileDesc::new(fd);
         fd.set_cloexec()?;
         Ok(Socket(fd))
@@ -228,10 +221,7 @@ impl Socket {
 
     fn recv_with_flags(&self, buf: &mut [u8], flags: c_int) -> io::Result<usize> {
         let ret = cvt(unsafe {
-            libc::recv(self.0.raw(),
-                       buf.as_mut_ptr() as *mut c_void,
-                       buf.len(),
-                       flags)
+            libc::recv(self.0.raw(), buf.as_mut_ptr() as *mut c_void, buf.len(), flags)
         })?;
         Ok(ret as usize)
     }
@@ -248,18 +238,23 @@ impl Socket {
         self.0.read_vectored(bufs)
     }
 
-    fn recv_from_with_flags(&self, buf: &mut [u8], flags: c_int)
-                            -> io::Result<(usize, SocketAddr)> {
+    fn recv_from_with_flags(
+        &self,
+        buf: &mut [u8],
+        flags: c_int,
+    ) -> io::Result<(usize, SocketAddr)> {
         let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() };
         let mut addrlen = mem::size_of_val(&storage) as libc::socklen_t;
 
         let n = cvt(unsafe {
-            libc::recvfrom(self.0.raw(),
-                        buf.as_mut_ptr() as *mut c_void,
-                        buf.len(),
-                        flags,
-                        &mut storage as *mut _ as *mut _,
-                        &mut addrlen)
+            libc::recvfrom(
+                self.0.raw(),
+                buf.as_mut_ptr() as *mut c_void,
+                buf.len(),
+                flags,
+                &mut storage as *mut _ as *mut _,
+                &mut addrlen,
+            )
         })?;
         Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?))
     }
@@ -284,8 +279,10 @@ impl Socket {
         let timeout = match dur {
             Some(dur) => {
                 if dur.as_secs() == 0 && dur.subsec_nanos() == 0 {
-                    return Err(io::Error::new(io::ErrorKind::InvalidInput,
-                                              "cannot set a 0 duration timeout"));
+                    return Err(io::Error::new(
+                        io::ErrorKind::InvalidInput,
+                        "cannot set a 0 duration timeout",
+                    ));
                 }
 
                 let secs = if dur.as_secs() > libc::time_t::max_value() as u64 {
@@ -302,12 +299,7 @@ impl Socket {
                 }
                 timeout
             }
-            None => {
-                libc::timeval {
-                    tv_sec: 0,
-                    tv_usec: 0,
-                }
-            }
+            None => libc::timeval { tv_sec: 0, tv_usec: 0 },
         };
         setsockopt(self, libc::SOL_SOCKET, kind, timeout)
     }
@@ -349,24 +341,26 @@ impl Socket {
 
     pub fn take_error(&self) -> io::Result<Option<io::Error>> {
         let raw: c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_ERROR)?;
-        if raw == 0 {
-            Ok(None)
-        } else {
-            Ok(Some(io::Error::from_raw_os_error(raw as i32)))
-        }
+        if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) }
     }
 }
 
 impl AsInner<c_int> for Socket {
-    fn as_inner(&self) -> &c_int { self.0.as_inner() }
+    fn as_inner(&self) -> &c_int {
+        self.0.as_inner()
+    }
 }
 
 impl FromInner<c_int> for Socket {
-    fn from_inner(fd: c_int) -> Socket { Socket(FileDesc::new(fd)) }
+    fn from_inner(fd: c_int) -> Socket {
+        Socket(FileDesc::new(fd))
+    }
 }
 
 impl IntoInner<c_int> for Socket {
-    fn into_inner(self) -> c_int { self.0.into_raw() }
+    fn into_inner(self) -> c_int {
+        self.0.into_raw()
+    }
 }
 
 // In versions of glibc prior to 2.26, there's a bug where the DNS resolver
diff --git a/src/libstd/sys/unix/path.rs b/src/libstd/sys/unix/path.rs
index 7a183956107..840a7ae0426 100644
--- a/src/libstd/sys/unix/path.rs
+++ b/src/libstd/sys/unix/path.rs
@@ -1,5 +1,5 @@
-use crate::path::Prefix;
 use crate::ffi::OsStr;
+use crate::path::Prefix;
 
 #[inline]
 pub fn is_sep_byte(b: u8) -> bool {
diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs
index 029f4216b7e..77fefef8a18 100644
--- a/src/libstd/sys/unix/pipe.rs
+++ b/src/libstd/sys/unix/pipe.rs
@@ -22,15 +22,15 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
     // CLOEXEC flag is to use the `pipe2` syscall on Linux. This was added in
     // 2.6.27, however, and because we support 2.6.18 we must detect this
     // support dynamically.
-    if cfg!(any(target_os = "dragonfly",
-                target_os = "freebsd",
-                target_os = "linux",
-                target_os = "netbsd",
-                target_os = "openbsd",
-                target_os = "redox")) &&
-       !INVALID.load(Ordering::SeqCst)
+    if cfg!(any(
+        target_os = "dragonfly",
+        target_os = "freebsd",
+        target_os = "linux",
+        target_os = "netbsd",
+        target_os = "openbsd",
+        target_os = "redox"
+    )) && !INVALID.load(Ordering::SeqCst)
     {
-
         // Note that despite calling a glibc function here we may still
         // get ENOSYS. Glibc has `pipe2` since 2.9 and doesn't try to
         // emulate on older kernels, so if you happen to be running on
@@ -38,8 +38,7 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
         // see the syscall.
         match cvt(unsafe { pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC) }) {
             Ok(_) => {
-                return Ok((AnonPipe(FileDesc::new(fds[0])),
-                            AnonPipe(FileDesc::new(fds[1]))));
+                return Ok((AnonPipe(FileDesc::new(fds[0])), AnonPipe(FileDesc::new(fds[1]))));
             }
             Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {
                 INVALID.store(true, Ordering::SeqCst);
@@ -73,15 +72,15 @@ impl AnonPipe {
         self.0.write_vectored(bufs)
     }
 
-    pub fn fd(&self) -> &FileDesc { &self.0 }
-    pub fn into_fd(self) -> FileDesc { self.0 }
+    pub fn fd(&self) -> &FileDesc {
+        &self.0
+    }
+    pub fn into_fd(self) -> FileDesc {
+        self.0
+    }
 }
 
-pub fn read2(p1: AnonPipe,
-             v1: &mut Vec<u8>,
-             p2: AnonPipe,
-             v2: &mut Vec<u8>) -> io::Result<()> {
-
+pub fn read2(p1: AnonPipe, v1: &mut Vec<u8>, p2: AnonPipe, v2: &mut Vec<u8>) -> io::Result<()> {
     // Set both pipes into nonblocking mode as we're gonna be reading from both
     // in the `select` loop below, and we wouldn't want one to block the other!
     let p1 = p1.into_fd();
@@ -117,8 +116,9 @@ pub fn read2(p1: AnonPipe,
         match fd.read_to_end(dst) {
             Ok(_) => Ok(true),
             Err(e) => {
-                if e.raw_os_error() == Some(libc::EWOULDBLOCK) ||
-                   e.raw_os_error() == Some(libc::EAGAIN) {
+                if e.raw_os_error() == Some(libc::EWOULDBLOCK)
+                    || e.raw_os_error() == Some(libc::EAGAIN)
+                {
                     Ok(false)
                 } else {
                     Err(e)
diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs
index 0e6f96bb228..c9109b0c9d4 100644
--- a/src/libstd/sys/unix/process/process_common.rs
+++ b/src/libstd/sys/unix/process/process_common.rs
@@ -1,6 +1,7 @@
 use crate::os::unix::prelude::*;
 
-use crate::ffi::{OsString, OsStr, CString, CStr};
+use crate::collections::BTreeMap;
+use crate::ffi::{CStr, CString, OsStr, OsString};
 use crate::fmt;
 use crate::io;
 use crate::ptr;
@@ -8,12 +9,11 @@ use crate::sys::fd::FileDesc;
 use crate::sys::fs::File;
 use crate::sys::pipe::{self, AnonPipe};
 use crate::sys_common::process::CommandEnv;
-use crate::collections::BTreeMap;
 
 #[cfg(not(target_os = "fuchsia"))]
 use crate::sys::fs::OpenOptions;
 
-use libc::{c_int, gid_t, uid_t, c_char, EXIT_SUCCESS, EXIT_FAILURE};
+use libc::{c_char, c_int, gid_t, uid_t, EXIT_FAILURE, EXIT_SUCCESS};
 
 cfg_if::cfg_if! {
     if #[cfg(target_os = "fuchsia")] {
@@ -204,10 +204,7 @@ impl Command {
         &mut self.closures
     }
 
-    pub unsafe fn pre_exec(
-        &mut self,
-        f: Box<dyn FnMut() -> io::Result<()> + Send + Sync>,
-    ) {
+    pub unsafe fn pre_exec(&mut self, f: Box<dyn FnMut() -> io::Result<()> + Send + Sync>) {
         self.closures.push(f);
     }
 
@@ -236,26 +233,21 @@ impl Command {
         self.env.have_changed_path()
     }
 
-    pub fn setup_io(&self, default: Stdio, needs_stdin: bool)
-                -> io::Result<(StdioPipes, ChildPipes)> {
+    pub fn setup_io(
+        &self,
+        default: Stdio,
+        needs_stdin: bool,
+    ) -> io::Result<(StdioPipes, ChildPipes)> {
         let null = Stdio::Null;
-        let default_stdin = if needs_stdin {&default} else {&null};
+        let default_stdin = if needs_stdin { &default } else { &null };
         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) = 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,
-            stderr: our_stderr,
-        };
-        let theirs = ChildPipes {
-            stdin: their_stdin,
-            stdout: their_stdout,
-            stderr: their_stderr,
-        };
+        let ours = StdioPipes { stdin: our_stdin, stdout: our_stdout, stderr: our_stderr };
+        let theirs = ChildPipes { stdin: their_stdin, stdout: their_stdout, stderr: their_stderr };
         Ok((ours, theirs))
     }
 }
@@ -270,21 +262,21 @@ fn os2c(s: &OsStr, saw_nul: &mut bool) -> CString {
 // Helper type to manage ownership of the strings within a C-style array.
 pub struct CStringArray {
     items: Vec<CString>,
-    ptrs: Vec<*const c_char>
+    ptrs: Vec<*const c_char>,
 }
 
 impl CStringArray {
     pub fn with_capacity(capacity: usize) -> Self {
         let mut result = CStringArray {
             items: Vec::with_capacity(capacity),
-            ptrs: Vec::with_capacity(capacity+1)
+            ptrs: Vec::with_capacity(capacity + 1),
         };
         result.ptrs.push(ptr::null());
         result
     }
     pub fn push(&mut self, item: CString) {
         let l = self.ptrs.len();
-        self.ptrs[l-1] = item.as_ptr();
+        self.ptrs[l - 1] = item.as_ptr();
         self.ptrs.push(ptr::null());
         self.items.push(item);
     }
@@ -315,12 +307,9 @@ fn construct_envp(env: BTreeMap<OsString, OsString>, saw_nul: &mut bool) -> CStr
 }
 
 impl Stdio {
-    pub fn to_child_stdio(&self, readable: bool)
-                      -> io::Result<(ChildStdio, Option<AnonPipe>)> {
+    pub fn to_child_stdio(&self, readable: bool) -> io::Result<(ChildStdio, Option<AnonPipe>)> {
         match *self {
-            Stdio::Inherit => {
-                Ok((ChildStdio::Inherit, None))
-            },
+            Stdio::Inherit => Ok((ChildStdio::Inherit, None)),
 
             // Make sure that the source descriptors are not an stdio
             // descriptor, otherwise the order which we set the child's
@@ -339,11 +328,7 @@ impl Stdio {
 
             Stdio::MakePipe => {
                 let (reader, writer) = pipe::anon_pipe()?;
-                let (ours, theirs) = if readable {
-                    (writer, reader)
-                } else {
-                    (reader, writer)
-                };
+                let (ours, theirs) = if readable { (writer, reader) } else { (reader, writer) };
                 Ok((ChildStdio::Owned(theirs.into_fd()), Some(ours)))
             }
 
@@ -352,17 +337,13 @@ impl Stdio {
                 let mut opts = OpenOptions::new();
                 opts.read(readable);
                 opts.write(!readable);
-                let path = unsafe {
-                    CStr::from_ptr(DEV_NULL.as_ptr() as *const _)
-                };
+                let path = unsafe { CStr::from_ptr(DEV_NULL.as_ptr() as *const _) };
                 let fd = File::open_c(&path, &opts)?;
                 Ok((ChildStdio::Owned(fd.into_fd()), None))
             }
 
             #[cfg(target_os = "fuchsia")]
-            Stdio::Null => {
-                Ok((ChildStdio::Null, None))
-            }
+            Stdio::Null => Ok((ChildStdio::Null, None)),
         }
     }
 }
@@ -430,7 +411,7 @@ mod tests {
                 Ok(t) => t,
                 Err(e) => panic!("received error for `{}`: {}", stringify!($e), e),
             }
-        }
+        };
     }
 
     // See #14232 for more information, but it appears that signal delivery to a
@@ -461,8 +442,7 @@ mod tests {
             let stdin_write = pipes.stdin.take().unwrap();
             let stdout_read = pipes.stdout.take().unwrap();
 
-            t!(cvt(libc::pthread_sigmask(libc::SIG_SETMASK, old_set.as_ptr(),
-                                         ptr::null_mut())));
+            t!(cvt(libc::pthread_sigmask(libc::SIG_SETMASK, old_set.as_ptr(), ptr::null_mut())));
 
             t!(cvt(libc::kill(cat.id() as libc::pid_t, libc::SIGINT)));
             // We need to wait until SIGINT is definitely delivered. The
diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs
index 486c12f9bf8..f0bd1cdfed5 100644
--- a/src/libstd/sys/unix/process/process_fuchsia.rs
+++ b/src/libstd/sys/unix/process/process_fuchsia.rs
@@ -1,11 +1,11 @@
 use crate::convert::TryInto;
-use crate::io;
 use crate::fmt;
+use crate::io;
 use crate::mem;
 use crate::ptr;
 
-use crate::sys::process::zircon::{Handle, zx_handle_t};
 use crate::sys::process::process_common::*;
+use crate::sys::process::zircon::{zx_handle_t, Handle};
 
 use libc::{c_int, size_t};
 
@@ -14,13 +14,18 @@ use libc::{c_int, size_t};
 ////////////////////////////////////////////////////////////////////////////////
 
 impl Command {
-    pub fn spawn(&mut self, default: Stdio, needs_stdin: bool)
-                 -> io::Result<(Process, StdioPipes)> {
+    pub fn spawn(
+        &mut self,
+        default: Stdio,
+        needs_stdin: bool,
+    ) -> io::Result<(Process, StdioPipes)> {
         let envp = self.capture_env();
 
         if self.saw_nul() {
-            return Err(io::Error::new(io::ErrorKind::InvalidInput,
-                                      "nul byte found in provided data"));
+            return Err(io::Error::new(
+                io::ErrorKind::InvalidInput,
+                "nul byte found in provided data",
+            ));
         }
 
         let (ours, theirs) = self.setup_io(default, needs_stdin)?;
@@ -32,21 +37,23 @@ impl Command {
 
     pub fn exec(&mut self, default: Stdio) -> io::Error {
         if self.saw_nul() {
-            return io::Error::new(io::ErrorKind::InvalidInput,
-                                  "nul byte found in provided data")
+            return io::Error::new(io::ErrorKind::InvalidInput, "nul byte found in provided data");
         }
 
         match self.setup_io(default, true) {
             Ok((_, _)) => {
                 // FIXME: This is tough because we don't support the exec syscalls
                 unimplemented!();
-            },
+            }
             Err(e) => e,
         }
     }
 
-    unsafe fn do_exec(&mut self, stdio: ChildPipes, maybe_envp: Option<&CStringArray>)
-                      -> io::Result<zx_handle_t> {
+    unsafe fn do_exec(
+        &mut self,
+        stdio: ChildPipes,
+        maybe_envp: Option<&CStringArray>,
+    ) -> io::Result<zx_handle_t> {
         use crate::sys::process::zircon::*;
 
         let envp = match maybe_envp {
@@ -108,10 +115,15 @@ impl Command {
         let mut process_handle: zx_handle_t = 0;
         zx_cvt(fdio_spawn_etc(
             ZX_HANDLE_INVALID,
-            FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE
-            | FDIO_SPAWN_CLONE_ENVIRON,  // this is ignored when envp is non-null
-            self.get_program().as_ptr(), self.get_argv().as_ptr(), envp,
-            actions.len() as size_t, actions.as_ptr(),
+            FDIO_SPAWN_CLONE_JOB
+                | FDIO_SPAWN_CLONE_LDSVC
+                | FDIO_SPAWN_CLONE_NAMESPACE
+                | FDIO_SPAWN_CLONE_ENVIRON, // this is ignored when envp is non-null
+            self.get_program().as_ptr(),
+            self.get_argv().as_ptr(),
+            envp,
+            actions.len() as size_t,
+            actions.as_ptr(),
             &mut process_handle,
             ptr::null_mut(),
         ))?;
@@ -137,7 +149,9 @@ impl Process {
     pub fn kill(&mut self) -> io::Result<()> {
         use crate::sys::process::zircon::*;
 
-        unsafe { zx_cvt(zx_task_kill(self.handle.raw()))?; }
+        unsafe {
+            zx_cvt(zx_task_kill(self.handle.raw()))?;
+        }
 
         Ok(())
     }
@@ -151,16 +165,26 @@ impl Process {
         let mut avail: size_t = 0;
 
         unsafe {
-            zx_cvt(zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
-                                      ZX_TIME_INFINITE, ptr::null_mut()))?;
-            zx_cvt(zx_object_get_info(self.handle.raw(), ZX_INFO_PROCESS,
-                                      &mut proc_info as *mut _ as *mut libc::c_void,
-                                      mem::size_of::<zx_info_process_t>(), &mut actual,
-                                      &mut avail))?;
+            zx_cvt(zx_object_wait_one(
+                self.handle.raw(),
+                ZX_TASK_TERMINATED,
+                ZX_TIME_INFINITE,
+                ptr::null_mut(),
+            ))?;
+            zx_cvt(zx_object_get_info(
+                self.handle.raw(),
+                ZX_INFO_PROCESS,
+                &mut proc_info as *mut _ as *mut libc::c_void,
+                mem::size_of::<zx_info_process_t>(),
+                &mut actual,
+                &mut avail,
+            ))?;
         }
         if actual != 1 {
-            return Err(io::Error::new(io::ErrorKind::InvalidData,
-                                      "Failed to get exit status of process"));
+            return Err(io::Error::new(
+                io::ErrorKind::InvalidData,
+                "Failed to get exit status of process",
+            ));
         }
         Ok(ExitStatus(proc_info.return_code))
     }
@@ -174,23 +198,31 @@ impl Process {
         let mut avail: size_t = 0;
 
         unsafe {
-            let status = zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
-                                            0, ptr::null_mut());
+            let status =
+                zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED, 0, ptr::null_mut());
             match status {
-                0 => { }, // Success
+                0 => {} // Success
                 x if x == ERR_TIMED_OUT => {
                     return Ok(None);
-                },
-                _ => { panic!("Failed to wait on process handle: {}", status); },
+                }
+                _ => {
+                    panic!("Failed to wait on process handle: {}", status);
+                }
             }
-            zx_cvt(zx_object_get_info(self.handle.raw(), ZX_INFO_PROCESS,
-                                      &mut proc_info as *mut _ as *mut libc::c_void,
-                                      mem::size_of::<zx_info_process_t>(), &mut actual,
-                                      &mut avail))?;
+            zx_cvt(zx_object_get_info(
+                self.handle.raw(),
+                ZX_INFO_PROCESS,
+                &mut proc_info as *mut _ as *mut libc::c_void,
+                mem::size_of::<zx_info_process_t>(),
+                &mut actual,
+                &mut avail,
+            ))?;
         }
         if actual != 1 {
-            return Err(io::Error::new(io::ErrorKind::InvalidData,
-                                      "Failed to get exit status of process"));
+            return Err(io::Error::new(
+                io::ErrorKind::InvalidData,
+                "Failed to get exit status of process",
+            ));
         }
         Ok(Some(ExitStatus(proc_info.return_code)))
     }
diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs
index 188a6b5f2da..750b8f0762a 100644
--- a/src/libstd/sys/unix/process/zircon.rs
+++ b/src/libstd/sys/unix/process/zircon.rs
@@ -1,8 +1,8 @@
 #![allow(non_camel_case_types, unused)]
 
 use crate::convert::TryInto;
-use crate::io;
 use crate::i64;
+use crate::io;
 use crate::mem::MaybeUninit;
 use crate::os::raw::c_char;
 
@@ -16,27 +16,26 @@ pub type zx_status_t = i32;
 pub const ZX_HANDLE_INVALID: zx_handle_t = 0;
 
 pub type zx_time_t = i64;
-pub const ZX_TIME_INFINITE : zx_time_t = i64::MAX;
+pub const ZX_TIME_INFINITE: zx_time_t = i64::MAX;
 
 pub type zx_signals_t = u32;
 
-pub const ZX_OBJECT_SIGNAL_3         : zx_signals_t = 1 << 3;
+pub const ZX_OBJECT_SIGNAL_3: zx_signals_t = 1 << 3;
 
-pub const ZX_TASK_TERMINATED        : zx_signals_t = ZX_OBJECT_SIGNAL_3;
+pub const ZX_TASK_TERMINATED: zx_signals_t = ZX_OBJECT_SIGNAL_3;
 
-pub const ZX_RIGHT_SAME_RIGHTS  : zx_rights_t = 1 << 31;
+pub const ZX_RIGHT_SAME_RIGHTS: zx_rights_t = 1 << 31;
 
 pub type zx_object_info_topic_t = u32;
 
-pub const ZX_INFO_PROCESS         : zx_object_info_topic_t = 3;
+pub const ZX_INFO_PROCESS: zx_object_info_topic_t = 3;
 
-pub fn zx_cvt<T>(t: T) -> io::Result<T> where T: TryInto<zx_status_t>+Copy {
+pub fn zx_cvt<T>(t: T) -> io::Result<T>
+where
+    T: TryInto<zx_status_t> + Copy,
+{
     if let Ok(status) = TryInto::try_into(t) {
-        if status < 0 {
-            Err(io::Error::from_raw_os_error(status))
-        } else {
-            Ok(t)
-        }
+        if status < 0 { Err(io::Error::from_raw_os_error(status)) } else { Ok(t) }
     } else {
         Err(io::Error::last_os_error())
     }
@@ -49,9 +48,7 @@ pub struct Handle {
 
 impl Handle {
     pub fn new(raw: zx_handle_t) -> Handle {
-        Handle {
-            raw,
-        }
+        Handle { raw }
     }
 
     pub fn raw(&self) -> zx_handle_t {
@@ -61,7 +58,9 @@ impl Handle {
 
 impl Drop for Handle {
     fn drop(&mut self) {
-        unsafe { zx_cvt(zx_handle_close(self.raw)).expect("Failed to close zx_handle_t"); }
+        unsafe {
+            zx_cvt(zx_handle_close(self.raw)).expect("Failed to close zx_handle_t");
+        }
     }
 }
 
@@ -75,22 +74,34 @@ pub struct zx_info_process_t {
     pub debugger_attached: bool,
 }
 
-extern {
+extern "C" {
     pub fn zx_job_default() -> zx_handle_t;
 
     pub fn zx_task_kill(handle: zx_handle_t) -> zx_status_t;
 
     pub fn zx_handle_close(handle: zx_handle_t) -> zx_status_t;
 
-    pub fn zx_handle_duplicate(handle: zx_handle_t, rights: zx_rights_t,
-                               out: *const zx_handle_t) -> zx_handle_t;
-
-    pub fn zx_object_wait_one(handle: zx_handle_t, signals: zx_signals_t, timeout: zx_time_t,
-                              pending: *mut zx_signals_t) -> zx_status_t;
-
-    pub fn zx_object_get_info(handle: zx_handle_t, topic: u32, buffer: *mut c_void,
-                              buffer_size: size_t, actual_size: *mut size_t,
-                              avail: *mut size_t) -> zx_status_t;
+    pub fn zx_handle_duplicate(
+        handle: zx_handle_t,
+        rights: zx_rights_t,
+        out: *const zx_handle_t,
+    ) -> zx_handle_t;
+
+    pub fn zx_object_wait_one(
+        handle: zx_handle_t,
+        signals: zx_signals_t,
+        timeout: zx_time_t,
+        pending: *mut zx_signals_t,
+    ) -> zx_status_t;
+
+    pub fn zx_object_get_info(
+        handle: zx_handle_t,
+        topic: u32,
+        buffer: *mut c_void,
+        buffer_size: size_t,
+        actual_size: *mut size_t,
+        avail: *mut size_t,
+    ) -> zx_status_t;
 }
 
 #[derive(Default)]
@@ -103,11 +114,18 @@ pub struct fdio_spawn_action_t {
     pub reserved1: u64,
 }
 
-extern {
-    pub fn fdio_spawn_etc(job: zx_handle_t, flags: u32, path: *const c_char,
-                          argv: *const *const c_char, envp: *const *const c_char,
-                          action_count: size_t, actions: *const fdio_spawn_action_t,
-                          process: *mut zx_handle_t, err_msg: *mut c_char) -> zx_status_t;
+extern "C" {
+    pub fn fdio_spawn_etc(
+        job: zx_handle_t,
+        flags: u32,
+        path: *const c_char,
+        argv: *const *const c_char,
+        envp: *const *const c_char,
+        action_count: size_t,
+        actions: *const fdio_spawn_action_t,
+        process: *mut zx_handle_t,
+        err_msg: *mut c_char,
+    ) -> zx_status_t;
 
     pub fn fdio_fd_clone(fd: c_int, out_handle: *mut zx_handle_t) -> zx_status_t;
     pub fn fdio_fd_create(handle: zx_handle_t, fd: *mut c_int) -> zx_status_t;
@@ -129,60 +147,74 @@ pub const FDIO_SPAWN_ACTION_TRANSFER_FD: u32 = 0x0002;
 
 // Errors
 
-#[allow(unused)] pub const ERR_INTERNAL: zx_status_t = -1;
+#[allow(unused)]
+pub const ERR_INTERNAL: zx_status_t = -1;
 
 // ERR_NOT_SUPPORTED: The operation is not implemented, supported,
 // or enabled.
-#[allow(unused)] pub const ERR_NOT_SUPPORTED: zx_status_t = -2;
+#[allow(unused)]
+pub const ERR_NOT_SUPPORTED: zx_status_t = -2;
 
 // ERR_NO_RESOURCES: The system was not able to allocate some resource
 // needed for the operation.
-#[allow(unused)] pub const ERR_NO_RESOURCES: zx_status_t = -3;
+#[allow(unused)]
+pub const ERR_NO_RESOURCES: zx_status_t = -3;
 
 // ERR_NO_MEMORY: The system was not able to allocate memory needed
 // for the operation.
-#[allow(unused)] pub const ERR_NO_MEMORY: zx_status_t = -4;
+#[allow(unused)]
+pub const ERR_NO_MEMORY: zx_status_t = -4;
 
 // ERR_CALL_FAILED: The second phase of zx_channel_call(; did not complete
 // successfully.
-#[allow(unused)] pub const ERR_CALL_FAILED: zx_status_t = -5;
+#[allow(unused)]
+pub const ERR_CALL_FAILED: zx_status_t = -5;
 
 // ERR_INTERRUPTED_RETRY: The system call was interrupted, but should be
 // retried.  This should not be seen outside of the VDSO.
-#[allow(unused)] pub const ERR_INTERRUPTED_RETRY: zx_status_t = -6;
+#[allow(unused)]
+pub const ERR_INTERRUPTED_RETRY: zx_status_t = -6;
 
 // ======= Parameter errors =======
 // ERR_INVALID_ARGS: an argument is invalid, ex. null pointer
-#[allow(unused)] pub const ERR_INVALID_ARGS: zx_status_t = -10;
+#[allow(unused)]
+pub const ERR_INVALID_ARGS: zx_status_t = -10;
 
 // ERR_BAD_HANDLE: A specified handle value does not refer to a handle.
-#[allow(unused)] pub const ERR_BAD_HANDLE: zx_status_t = -11;
+#[allow(unused)]
+pub const ERR_BAD_HANDLE: zx_status_t = -11;
 
 // ERR_WRONG_TYPE: The subject of the operation is the wrong type to
 // perform the operation.
 // Example: Attempting a message_read on a thread handle.
-#[allow(unused)] pub const ERR_WRONG_TYPE: zx_status_t = -12;
+#[allow(unused)]
+pub const ERR_WRONG_TYPE: zx_status_t = -12;
 
 // ERR_BAD_SYSCALL: The specified syscall number is invalid.
-#[allow(unused)] pub const ERR_BAD_SYSCALL: zx_status_t = -13;
+#[allow(unused)]
+pub const ERR_BAD_SYSCALL: zx_status_t = -13;
 
 // ERR_OUT_OF_RANGE: An argument is outside the valid range for this
 // operation.
-#[allow(unused)] pub const ERR_OUT_OF_RANGE: zx_status_t = -14;
+#[allow(unused)]
+pub const ERR_OUT_OF_RANGE: zx_status_t = -14;
 
 // ERR_BUFFER_TOO_SMALL: A caller provided buffer is too small for
 // this operation.
-#[allow(unused)] pub const ERR_BUFFER_TOO_SMALL: zx_status_t = -15;
+#[allow(unused)]
+pub const ERR_BUFFER_TOO_SMALL: zx_status_t = -15;
 
 // ======= Precondition or state errors =======
 // ERR_BAD_STATE: operation failed because the current state of the
 // object does not allow it, or a precondition of the operation is
 // not satisfied
-#[allow(unused)] pub const ERR_BAD_STATE: zx_status_t = -20;
+#[allow(unused)]
+pub const ERR_BAD_STATE: zx_status_t = -20;
 
 // ERR_TIMED_OUT: The time limit for the operation elapsed before
 // the operation completed.
-#[allow(unused)] pub const ERR_TIMED_OUT: zx_status_t = -21;
+#[allow(unused)]
+pub const ERR_TIMED_OUT: zx_status_t = -21;
 
 // ERR_SHOULD_WAIT: The operation cannot be performed currently but
 // potentially could succeed if the caller waits for a prerequisite
@@ -192,67 +224,84 @@ pub const FDIO_SPAWN_ACTION_TRANSFER_FD: u32 = 0x0002;
 // messages waiting but has an open remote will return ERR_SHOULD_WAIT.
 // Attempting to read from a message pipe that has no messages waiting
 // and has a closed remote end will return ERR_REMOTE_CLOSED.
-#[allow(unused)] pub const ERR_SHOULD_WAIT: zx_status_t = -22;
+#[allow(unused)]
+pub const ERR_SHOULD_WAIT: zx_status_t = -22;
 
 // ERR_CANCELED: The in-progress operation (e.g., a wait) has been
 // // canceled.
-#[allow(unused)] pub const ERR_CANCELED: zx_status_t = -23;
+#[allow(unused)]
+pub const ERR_CANCELED: zx_status_t = -23;
 
 // ERR_PEER_CLOSED: The operation failed because the remote end
 // of the subject of the operation was closed.
-#[allow(unused)] pub const ERR_PEER_CLOSED: zx_status_t = -24;
+#[allow(unused)]
+pub const ERR_PEER_CLOSED: zx_status_t = -24;
 
 // ERR_NOT_FOUND: The requested entity is not found.
-#[allow(unused)] pub const ERR_NOT_FOUND: zx_status_t = -25;
+#[allow(unused)]
+pub const ERR_NOT_FOUND: zx_status_t = -25;
 
 // ERR_ALREADY_EXISTS: An object with the specified identifier
 // already exists.
 // Example: Attempting to create a file when a file already exists
 // with that name.
-#[allow(unused)] pub const ERR_ALREADY_EXISTS: zx_status_t = -26;
+#[allow(unused)]
+pub const ERR_ALREADY_EXISTS: zx_status_t = -26;
 
 // ERR_ALREADY_BOUND: The operation failed because the named entity
 // is already owned or controlled by another entity. The operation
 // could succeed later if the current owner releases the entity.
-#[allow(unused)] pub const ERR_ALREADY_BOUND: zx_status_t = -27;
+#[allow(unused)]
+pub const ERR_ALREADY_BOUND: zx_status_t = -27;
 
 // ERR_UNAVAILABLE: The subject of the operation is currently unable
 // to perform the operation.
 // Note: This is used when there's no direct way for the caller to
 // observe when the subject will be able to perform the operation
 // and should thus retry.
-#[allow(unused)] pub const ERR_UNAVAILABLE: zx_status_t = -28;
+#[allow(unused)]
+pub const ERR_UNAVAILABLE: zx_status_t = -28;
 
 // ======= Permission check errors =======
 // ERR_ACCESS_DENIED: The caller did not have permission to perform
 // the specified operation.
-#[allow(unused)] pub const ERR_ACCESS_DENIED: zx_status_t = -30;
+#[allow(unused)]
+pub const ERR_ACCESS_DENIED: zx_status_t = -30;
 
 // ======= Input-output errors =======
 // ERR_IO: Otherwise unspecified error occurred during I/O.
-#[allow(unused)] pub const ERR_IO: zx_status_t = -40;
+#[allow(unused)]
+pub const ERR_IO: zx_status_t = -40;
 
 // ERR_REFUSED: The entity the I/O operation is being performed on
 // rejected the operation.
 // Example: an I2C device NAK'ing a transaction or a disk controller
 // rejecting an invalid command.
-#[allow(unused)] pub const ERR_IO_REFUSED: zx_status_t = -41;
+#[allow(unused)]
+pub const ERR_IO_REFUSED: zx_status_t = -41;
 
 // ERR_IO_DATA_INTEGRITY: The data in the operation failed an integrity
 // check and is possibly corrupted.
 // Example: CRC or Parity error.
-#[allow(unused)] pub const ERR_IO_DATA_INTEGRITY: zx_status_t = -42;
+#[allow(unused)]
+pub const ERR_IO_DATA_INTEGRITY: zx_status_t = -42;
 
 // ERR_IO_DATA_LOSS: The data in the operation is currently unavailable
 // and may be permanently lost.
 // Example: A disk block is irrecoverably damaged.
-#[allow(unused)] pub const ERR_IO_DATA_LOSS: zx_status_t = -43;
+#[allow(unused)]
+pub const ERR_IO_DATA_LOSS: zx_status_t = -43;
 
 // Filesystem specific errors
-#[allow(unused)] pub const ERR_BAD_PATH: zx_status_t = -50;
-#[allow(unused)] pub const ERR_NOT_DIR: zx_status_t = -51;
-#[allow(unused)] pub const ERR_NOT_FILE: zx_status_t = -52;
+#[allow(unused)]
+pub const ERR_BAD_PATH: zx_status_t = -50;
+#[allow(unused)]
+pub const ERR_NOT_DIR: zx_status_t = -51;
+#[allow(unused)]
+pub const ERR_NOT_FILE: zx_status_t = -52;
 // ERR_FILE_BIG: A file exceeds a filesystem-specific size limit.
-#[allow(unused)] pub const ERR_FILE_BIG: zx_status_t = -53;
+#[allow(unused)]
+pub const ERR_FILE_BIG: zx_status_t = -53;
 // ERR_NO_SPACE: Filesystem or device space is exhausted.
-#[allow(unused)] pub const ERR_NO_SPACE: zx_status_t = -54;
+#[allow(unused)]
+pub const ERR_NO_SPACE: zx_status_t = -54;
diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs
index bc387544c4c..9ce5f3d014c 100644
--- a/src/libstd/sys/unix/rand.rs
+++ b/src/libstd/sys/unix/rand.rs
@@ -4,20 +4,21 @@ use crate::slice;
 pub fn hashmap_random_keys() -> (u64, u64) {
     let mut v = (0, 0);
     unsafe {
-        let view = slice::from_raw_parts_mut(&mut v as *mut _ as *mut u8,
-                                             mem::size_of_val(&v));
+        let view = slice::from_raw_parts_mut(&mut v as *mut _ as *mut u8, mem::size_of_val(&v));
         imp::fill_bytes(view);
     }
     v
 }
 
-#[cfg(all(unix,
-          not(target_os = "ios"),
-          not(target_os = "openbsd"),
-          not(target_os = "freebsd"),
-          not(target_os = "netbsd"),
-          not(target_os = "fuchsia"),
-          not(target_os = "redox")))]
+#[cfg(all(
+    unix,
+    not(target_os = "ios"),
+    not(target_os = "openbsd"),
+    not(target_os = "freebsd"),
+    not(target_os = "netbsd"),
+    not(target_os = "fuchsia"),
+    not(target_os = "redox")
+))]
 mod imp {
     use crate::fs::File;
     use crate::io::Read;
@@ -30,7 +31,9 @@ mod imp {
     }
 
     #[cfg(not(any(target_os = "linux", target_os = "android")))]
-    fn getrandom_fill_bytes(_buf: &mut [u8]) -> bool { false }
+    fn getrandom_fill_bytes(_buf: &mut [u8]) -> bool {
+        false
+    }
 
     #[cfg(any(target_os = "linux", target_os = "android"))]
     fn getrandom_fill_bytes(v: &mut [u8]) -> bool {
@@ -96,9 +99,7 @@ mod imp {
     pub fn fill_bytes(v: &mut [u8]) {
         // getentropy(2) permits a maximum buffer size of 256 bytes
         for s in v.chunks_mut(256) {
-            let ret = unsafe {
-                libc::getentropy(s.as_mut_ptr() as *mut libc::c_void, s.len())
-            };
+            let ret = unsafe { libc::getentropy(s.as_mut_ptr() as *mut libc::c_void, s.len()) };
             if ret == -1 {
                 panic!("unexpected getentropy error: {}", errno());
             }
@@ -124,21 +125,14 @@ mod imp {
     #[allow(non_upper_case_globals)]
     const kSecRandomDefault: *const SecRandom = ptr::null();
 
-    extern {
-        fn SecRandomCopyBytes(rnd: *const SecRandom,
-                              count: size_t,
-                              bytes: *mut u8) -> c_int;
+    extern "C" {
+        fn SecRandomCopyBytes(rnd: *const SecRandom, count: size_t, bytes: *mut u8) -> c_int;
     }
 
     pub fn fill_bytes(v: &mut [u8]) {
-        let ret = unsafe {
-            SecRandomCopyBytes(kSecRandomDefault,
-                               v.len(),
-                               v.as_mut_ptr())
-        };
+        let ret = unsafe { SecRandomCopyBytes(kSecRandomDefault, v.len(), v.as_mut_ptr()) };
         if ret == -1 {
-            panic!("couldn't generate random bytes: {}",
-                   io::Error::last_os_error());
+            panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
         }
     }
 }
@@ -153,13 +147,22 @@ mod imp {
         for s in v.chunks_mut(256) {
             let mut s_len = s.len();
             let ret = unsafe {
-                libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint,
-                             s.as_mut_ptr() as *mut _, &mut s_len,
-                             ptr::null(), 0)
+                libc::sysctl(
+                    mib.as_ptr(),
+                    mib.len() as libc::c_uint,
+                    s.as_mut_ptr() as *mut _,
+                    &mut s_len,
+                    ptr::null(),
+                    0,
+                )
             };
             if ret == -1 || s_len != s.len() {
-                panic!("kern.arandom sysctl failed! (returned {}, s.len() {}, oldlenp {})",
-                       ret, s.len(), s_len);
+                panic!(
+                    "kern.arandom sysctl failed! (returned {}, s.len() {}, oldlenp {})",
+                    ret,
+                    s.len(),
+                    s_len
+                );
             }
         }
     }
@@ -168,7 +171,7 @@ mod imp {
 #[cfg(target_os = "fuchsia")]
 mod imp {
     #[link(name = "zircon")]
-    extern {
+    extern "C" {
         fn zx_cprng_draw(buffer: *mut u8, len: usize);
     }
 
diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs
index fe1095fa0c2..528fe321efb 100644
--- a/src/libstd/sys/unix/stack_overflow.rs
+++ b/src/libstd/sys/unix/stack_overflow.rs
@@ -1,12 +1,12 @@
 #![cfg_attr(test, allow(dead_code))]
 
-use self::imp::{make_handler, drop_handler};
+use self::imp::{drop_handler, make_handler};
 
 pub use self::imp::cleanup;
 pub use self::imp::init;
 
 pub struct Handler {
-    _data: *mut libc::c_void
+    _data: *mut libc::c_void,
 }
 
 impl Handler {
@@ -23,28 +23,28 @@ impl Drop for Handler {
     }
 }
 
-#[cfg(any(target_os = "linux",
-          target_os = "macos",
-          target_os = "dragonfly",
-          target_os = "freebsd",
-          target_os = "solaris",
-          all(target_os = "netbsd", not(target_vendor = "rumprun")),
-          target_os = "openbsd"))]
+#[cfg(any(
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "dragonfly",
+    target_os = "freebsd",
+    target_os = "solaris",
+    all(target_os = "netbsd", not(target_vendor = "rumprun")),
+    target_os = "openbsd"
+))]
 mod imp {
     use super::Handler;
     use crate::mem;
     use crate::ptr;
 
-    use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};
-    use libc::{sigaction, SIGBUS, SIG_DFL,
-               SA_SIGINFO, SA_ONSTACK, sighandler_t};
-    use libc::{mmap, munmap};
-    use libc::{SIGSEGV, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON};
     use libc::MAP_FAILED;
+    use libc::{mmap, munmap};
+    use libc::{sigaction, sighandler_t, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIG_DFL};
+    use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};
+    use libc::{MAP_ANON, MAP_PRIVATE, PROT_READ, PROT_WRITE, SIGSEGV};
 
     use crate::sys_common::thread_info;
 
-
     #[cfg(any(target_os = "linux", target_os = "android"))]
     unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize {
         #[repr(C)]
@@ -82,9 +82,11 @@ mod imp {
     // out many large systems and all implementations allow returning from a
     // signal handler to work. For a more detailed explanation see the
     // comments on #26458.
-    unsafe extern fn signal_handler(signum: libc::c_int,
-                                    info: *mut libc::siginfo_t,
-                                    _data: *mut libc::c_void) {
+    unsafe extern "C" fn signal_handler(
+        signum: libc::c_int,
+        info: *mut libc::siginfo_t,
+        _data: *mut libc::c_void,
+    ) {
         use crate::sys_common::util::report_overflow;
 
         let guard = thread_info::stack_guard().unwrap_or(0..0);
@@ -124,24 +126,22 @@ mod imp {
     }
 
     unsafe fn get_stackp() -> *mut libc::c_void {
-        let stackp = mmap(ptr::null_mut(),
-                          SIGSTKSZ,
-                          PROT_READ | PROT_WRITE,
-                          MAP_PRIVATE | MAP_ANON,
-                          -1,
-                          0);
+        let stackp =
+            mmap(ptr::null_mut(), SIGSTKSZ, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
         if stackp == MAP_FAILED {
             panic!("failed to allocate an alternative stack");
         }
         stackp
     }
 
-    #[cfg(any(target_os = "linux",
-              target_os = "macos",
-              target_os = "freebsd",
-              target_os = "netbsd",
-              target_os = "openbsd",
-              target_os = "solaris"))]
+    #[cfg(any(
+        target_os = "linux",
+        target_os = "macos",
+        target_os = "freebsd",
+        target_os = "netbsd",
+        target_os = "openbsd",
+        target_os = "solaris"
+    ))]
     unsafe fn get_stack() -> libc::stack_t {
         libc::stack_t { ss_sp: get_stackp(), ss_flags: 0, ss_size: SIGSTKSZ }
     }
@@ -166,7 +166,7 @@ mod imp {
 
     pub unsafe fn drop_handler(handler: &mut Handler) {
         if !handler._data.is_null() {
-            let stack =  libc::stack_t {
+            let stack = libc::stack_t {
                 ss_sp: ptr::null_mut(),
                 ss_flags: SS_DISABLE,
                 // Workaround for bug in macOS implementation of sigaltstack
@@ -181,26 +181,25 @@ mod imp {
     }
 }
 
-#[cfg(not(any(target_os = "linux",
-              target_os = "macos",
-              target_os = "dragonfly",
-              target_os = "freebsd",
-              target_os = "solaris",
-              all(target_os = "netbsd", not(target_vendor = "rumprun")),
-              target_os = "openbsd")))]
+#[cfg(not(any(
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "dragonfly",
+    target_os = "freebsd",
+    target_os = "solaris",
+    all(target_os = "netbsd", not(target_vendor = "rumprun")),
+    target_os = "openbsd"
+)))]
 mod imp {
     use crate::ptr;
 
-    pub unsafe fn init() {
-    }
+    pub unsafe fn init() {}
 
-    pub unsafe fn cleanup() {
-    }
+    pub unsafe fn cleanup() {}
 
     pub unsafe fn make_handler() -> super::Handler {
         super::Handler { _data: ptr::null_mut() }
     }
 
-    pub unsafe fn drop_handler(_handler: &mut super::Handler) {
-    }
+    pub unsafe fn drop_handler(_handler: &mut super::Handler) {}
 }
diff --git a/src/libstd/sys/unix/stdio.rs b/src/libstd/sys/unix/stdio.rs
index f9b017df240..b9c56963885 100644
--- a/src/libstd/sys/unix/stdio.rs
+++ b/src/libstd/sys/unix/stdio.rs
@@ -1,13 +1,15 @@
 use crate::io::{self, IoSlice, IoSliceMut};
-use crate::sys::fd::FileDesc;
 use crate::mem::ManuallyDrop;
+use crate::sys::fd::FileDesc;
 
 pub struct Stdin(());
 pub struct Stdout(());
 pub struct Stderr(());
 
 impl Stdin {
-    pub fn new() -> io::Result<Stdin> { Ok(Stdin(())) }
+    pub fn new() -> io::Result<Stdin> {
+        Ok(Stdin(()))
+    }
 }
 
 impl io::Read for Stdin {
@@ -21,7 +23,9 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> io::Result<Stdout> { Ok(Stdout(())) }
+    pub fn new() -> io::Result<Stdout> {
+        Ok(Stdout(()))
+    }
 }
 
 impl io::Write for Stdout {
@@ -39,7 +43,9 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> io::Result<Stderr> { Ok(Stderr(())) }
+    pub fn new() -> io::Result<Stderr> {
+        Ok(Stderr(()))
+    }
 }
 
 impl io::Write for Stderr {
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index 72b0ac493da..a5b34eeec28 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -25,21 +25,24 @@ unsafe impl Sync for Thread {}
 // The pthread_attr_setstacksize symbol doesn't exist in the emscripten libc,
 // so we have to not link to it to satisfy emcc's ERROR_ON_UNDEFINED_SYMBOLS.
 #[cfg(not(target_os = "emscripten"))]
-unsafe fn pthread_attr_setstacksize(attr: *mut libc::pthread_attr_t,
-                                    stack_size: libc::size_t) -> libc::c_int {
+unsafe fn pthread_attr_setstacksize(
+    attr: *mut libc::pthread_attr_t,
+    stack_size: libc::size_t,
+) -> libc::c_int {
     libc::pthread_attr_setstacksize(attr, stack_size)
 }
 
 #[cfg(target_os = "emscripten")]
-unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t,
-                                    _stack_size: libc::size_t) -> libc::c_int {
+unsafe fn pthread_attr_setstacksize(
+    _attr: *mut libc::pthread_attr_t,
+    _stack_size: libc::size_t,
+) -> libc::c_int {
     panic!()
 }
 
 impl Thread {
     // unsafe: see thread::Builder::spawn_unchecked for safety requirements
-    pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>)
-                          -> io::Result<Thread> {
+    pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
         let p = box p;
         let mut native: libc::pthread_t = mem::zeroed();
         let mut attr: libc::pthread_attr_t = mem::zeroed();
@@ -47,8 +50,7 @@ impl Thread {
 
         let stack_size = cmp::max(stack, min_stack_size(&attr));
 
-        match pthread_attr_setstacksize(&mut attr,
-                                        stack_size) {
+        match pthread_attr_setstacksize(&mut attr, stack_size) {
             0 => {}
             n => {
                 assert_eq!(n, libc::EINVAL);
@@ -57,15 +59,13 @@ impl Thread {
                 // >= PTHREAD_STACK_MIN, it must be an alignment issue.
                 // Round up to the nearest page and try again.
                 let page_size = os::page_size();
-                let stack_size = (stack_size + page_size - 1) &
-                                 (-(page_size as isize - 1) as usize - 1);
-                assert_eq!(libc::pthread_attr_setstacksize(&mut attr,
-                                                           stack_size), 0);
+                let stack_size =
+                    (stack_size + page_size - 1) & (-(page_size as isize - 1) as usize - 1);
+                assert_eq!(libc::pthread_attr_setstacksize(&mut attr, stack_size), 0);
             }
         };
 
-        let ret = libc::pthread_create(&mut native, &attr, thread_start,
-                                       &*p as *const _ as *mut _);
+        let ret = libc::pthread_create(&mut native, &attr, thread_start, &*p as *const _ as *mut _);
         assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
 
         return if ret != 0 {
@@ -75,8 +75,10 @@ impl Thread {
             Ok(Thread { id: native })
         };
 
-        extern fn thread_start(main: *mut libc::c_void) -> *mut libc::c_void {
-            unsafe { start_thread(main as *mut u8); }
+        extern "C" fn thread_start(main: *mut libc::c_void) -> *mut libc::c_void {
+            unsafe {
+                start_thread(main as *mut u8);
+            }
             ptr::null_mut()
         }
     }
@@ -86,8 +88,7 @@ impl Thread {
         debug_assert_eq!(ret, 0);
     }
 
-    #[cfg(any(target_os = "linux",
-              target_os = "android"))]
+    #[cfg(any(target_os = "linux", target_os = "android"))]
     pub fn set_name(name: &CStr) {
         const PR_SET_NAME: libc::c_int = 15;
         // pthread wrapper only appeared in glibc 2.12, so we use syscall
@@ -97,9 +98,7 @@ impl Thread {
         }
     }
 
-    #[cfg(any(target_os = "freebsd",
-              target_os = "dragonfly",
-              target_os = "openbsd"))]
+    #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
     pub fn set_name(name: &CStr) {
         unsafe {
             libc::pthread_set_name_np(libc::pthread_self(), name.as_ptr());
@@ -118,8 +117,11 @@ impl Thread {
         use crate::ffi::CString;
         let cname = CString::new(&b"%s"[..]).unwrap();
         unsafe {
-            libc::pthread_setname_np(libc::pthread_self(), cname.as_ptr(),
-                                     name.as_ptr() as *mut libc::c_void);
+            libc::pthread_setname_np(
+                libc::pthread_self(),
+                cname.as_ptr(),
+                name.as_ptr() as *mut libc::c_void,
+            );
         }
     }
 
@@ -132,15 +134,19 @@ impl Thread {
         }
 
         if let Some(f) = pthread_setname_np.get() {
-            unsafe { f(libc::pthread_self(), name.as_ptr()); }
+            unsafe {
+                f(libc::pthread_self(), name.as_ptr());
+            }
         }
     }
 
-    #[cfg(any(target_env = "newlib",
-              target_os = "haiku",
-              target_os = "l4re",
-              target_os = "emscripten",
-              target_os = "redox"))]
+    #[cfg(any(
+        target_env = "newlib",
+        target_os = "haiku",
+        target_os = "l4re",
+        target_os = "emscripten",
+        target_os = "redox"
+    ))]
     pub fn set_name(_name: &CStr) {
         // Newlib, Illumos, Haiku, and Emscripten have no way to set a thread name.
     }
@@ -177,12 +183,13 @@ impl Thread {
         unsafe {
             let ret = libc::pthread_join(self.id, ptr::null_mut());
             mem::forget(self);
-            assert!(ret == 0,
-                    "failed to join thread: {}", io::Error::from_raw_os_error(ret));
+            assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret));
         }
     }
 
-    pub fn id(&self) -> libc::pthread_t { self.id }
+    pub fn id(&self) -> libc::pthread_t {
+        self.id
+    }
 
     pub fn into_id(self) -> libc::pthread_t {
         let id = self.id;
@@ -198,31 +205,38 @@ impl Drop for Thread {
     }
 }
 
-#[cfg(all(not(all(target_os = "linux", not(target_env = "musl"))),
-          not(target_os = "freebsd"),
-          not(target_os = "macos"),
-          not(all(target_os = "netbsd", not(target_vendor = "rumprun"))),
-          not(target_os = "openbsd"),
-          not(target_os = "solaris")))]
+#[cfg(all(
+    not(all(target_os = "linux", not(target_env = "musl"))),
+    not(target_os = "freebsd"),
+    not(target_os = "macos"),
+    not(all(target_os = "netbsd", not(target_vendor = "rumprun"))),
+    not(target_os = "openbsd"),
+    not(target_os = "solaris")
+))]
 #[cfg_attr(test, allow(dead_code))]
 pub mod guard {
     use crate::ops::Range;
     pub type Guard = Range<usize>;
-    pub unsafe fn current() -> Option<Guard> { None }
-    pub unsafe fn init() -> Option<Guard> { None }
+    pub unsafe fn current() -> Option<Guard> {
+        None
+    }
+    pub unsafe fn init() -> Option<Guard> {
+        None
+    }
 }
 
-
-#[cfg(any(all(target_os = "linux", not(target_env = "musl")),
-          target_os = "freebsd",
-          target_os = "macos",
-          all(target_os = "netbsd", not(target_vendor = "rumprun")),
-          target_os = "openbsd",
-          target_os = "solaris"))]
+#[cfg(any(
+    all(target_os = "linux", not(target_env = "musl")),
+    target_os = "freebsd",
+    target_os = "macos",
+    all(target_os = "netbsd", not(target_vendor = "rumprun")),
+    target_os = "openbsd",
+    target_os = "solaris"
+))]
 #[cfg_attr(test, allow(dead_code))]
 pub mod guard {
     use libc::{mmap, mprotect};
-    use libc::{PROT_NONE, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED};
+    use libc::{MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE};
 
     use crate::ops::Range;
     use crate::sys::os;
@@ -241,16 +255,15 @@ pub mod guard {
 
     #[cfg(target_os = "macos")]
     unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
-        let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize -
-             libc::pthread_get_stacksize_np(libc::pthread_self());
+        let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize
+            - libc::pthread_get_stacksize_np(libc::pthread_self());
         Some(stackaddr as *mut libc::c_void)
     }
 
     #[cfg(target_os = "openbsd")]
     unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
         let mut current_stack: libc::stack_t = crate::mem::zeroed();
-        assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(),
-                                             &mut current_stack), 0);
+        assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(), &mut current_stack), 0);
 
         let stackaddr = if libc::pthread_main_np() == 1 {
             // main thread
@@ -262,21 +275,25 @@ pub mod guard {
         Some(stackaddr as *mut libc::c_void)
     }
 
-    #[cfg(any(target_os = "android", target_os = "freebsd",
-              target_os = "linux", target_os = "netbsd", target_os = "l4re"))]
+    #[cfg(any(
+        target_os = "android",
+        target_os = "freebsd",
+        target_os = "linux",
+        target_os = "netbsd",
+        target_os = "l4re"
+    ))]
     unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
         let mut ret = None;
         let mut attr: libc::pthread_attr_t = crate::mem::zeroed();
         assert_eq!(libc::pthread_attr_init(&mut attr), 0);
         #[cfg(target_os = "freebsd")]
-            let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
+        let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
         #[cfg(not(target_os = "freebsd"))]
-            let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
+        let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
         if e == 0 {
             let mut stackaddr = crate::ptr::null_mut();
             let mut stacksize = 0;
-            assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
-                                                   &mut stacksize), 0);
+            assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize), 0);
             ret = Some(stackaddr);
         }
         assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
@@ -329,8 +346,14 @@ pub mod guard {
             // than the initial mmap() used, so we mmap() here with
             // read/write permissions and only then mprotect() it to
             // no permissions at all. See issue #50313.
-            let result = mmap(stackaddr, PAGE_SIZE, PROT_READ | PROT_WRITE,
-                              MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
+            let result = mmap(
+                stackaddr,
+                PAGE_SIZE,
+                PROT_READ | PROT_WRITE,
+                MAP_PRIVATE | MAP_ANON | MAP_FIXED,
+                -1,
+                0,
+            );
             if result != stackaddr || result == MAP_FAILED {
                 panic!("failed to allocate a guard page");
             }
@@ -341,34 +364,33 @@ pub mod guard {
             }
 
             let guardaddr = stackaddr as usize;
-            let offset = if cfg!(target_os = "freebsd") {
-                2
-            } else {
-                1
-            };
+            let offset = if cfg!(target_os = "freebsd") { 2 } else { 1 };
 
             Some(guardaddr..guardaddr + offset * PAGE_SIZE)
         }
     }
 
-    #[cfg(any(target_os = "macos",
-              target_os = "openbsd",
-              target_os = "solaris"))]
+    #[cfg(any(target_os = "macos", target_os = "openbsd", target_os = "solaris"))]
     pub unsafe fn current() -> Option<Guard> {
         let stackaddr = get_stack_start()? as usize;
         Some(stackaddr - PAGE_SIZE..stackaddr)
     }
 
-    #[cfg(any(target_os = "android", target_os = "freebsd",
-              target_os = "linux", target_os = "netbsd", target_os = "l4re"))]
+    #[cfg(any(
+        target_os = "android",
+        target_os = "freebsd",
+        target_os = "linux",
+        target_os = "netbsd",
+        target_os = "l4re"
+    ))]
     pub unsafe fn current() -> Option<Guard> {
         let mut ret = None;
         let mut attr: libc::pthread_attr_t = crate::mem::zeroed();
         assert_eq!(libc::pthread_attr_init(&mut attr), 0);
         #[cfg(target_os = "freebsd")]
-            let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
+        let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
         #[cfg(not(target_os = "freebsd"))]
-            let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
+        let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
         if e == 0 {
             let mut guardsize = 0;
             assert_eq!(libc::pthread_attr_getguardsize(&attr, &mut guardsize), 0);
@@ -377,8 +399,7 @@ pub mod guard {
             }
             let mut stackaddr = crate::ptr::null_mut();
             let mut size = 0;
-            assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
-                                                   &mut size), 0);
+            assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut size), 0);
 
             let stackaddr = stackaddr as usize;
             ret = if cfg!(target_os = "freebsd") {
@@ -422,8 +443,7 @@ fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize {
 
 // No point in looking up __pthread_get_minstack() on non-glibc
 // platforms.
-#[cfg(all(not(target_os = "linux"),
-          not(target_os = "netbsd")))]
+#[cfg(all(not(target_os = "linux"), not(target_os = "netbsd")))]
 fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
     libc::PTHREAD_STACK_MIN
 }
diff --git a/src/libstd/sys/unix/thread_local.rs b/src/libstd/sys/unix/thread_local.rs
index ac615b76b36..2c5b94b1e61 100644
--- a/src/libstd/sys/unix/thread_local.rs
+++ b/src/libstd/sys/unix/thread_local.rs
@@ -5,7 +5,7 @@ use crate::mem;
 pub type Key = libc::pthread_key_t;
 
 #[inline]
-pub unsafe fn create(dtor: Option<unsafe extern fn(*mut u8)>) -> Key {
+pub unsafe fn create(dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
     let mut key = 0;
     assert_eq!(libc::pthread_key_create(&mut key, mem::transmute(dtor)), 0);
     key
diff --git a/src/libstd/sys/unix/weak.rs b/src/libstd/sys/unix/weak.rs
index 9a7691e54bc..08cbe596174 100644
--- a/src/libstd/sys/unix/weak.rs
+++ b/src/libstd/sys/unix/weak.rs
@@ -36,11 +36,7 @@ pub struct Weak<F> {
 
 impl<F> Weak<F> {
     pub const fn new(name: &'static str) -> Weak<F> {
-        Weak {
-            name,
-            addr: AtomicUsize::new(1),
-            _marker: marker::PhantomData,
-        }
+        Weak { name, addr: AtomicUsize::new(1), _marker: marker::PhantomData }
     }
 
     pub fn get(&self) -> Option<F> {