about summary refs log tree commit diff
path: root/src/libstd/sys/windows
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/windows
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/windows')
-rw-r--r--src/libstd/sys/windows/alloc.rs16
-rw-r--r--src/libstd/sys/windows/args.rs56
-rw-r--r--src/libstd/sys/windows/cmath.rs6
-rw-r--r--src/libstd/sys/windows/compat.rs3
-rw-r--r--src/libstd/sys/windows/ext/ffi.rs4
-rw-r--r--src/libstd/sys/windows/ext/fs.rs65
-rw-r--r--src/libstd/sys/windows/ext/io.rs6
-rw-r--r--src/libstd/sys/windows/ext/mod.rs23
-rw-r--r--src/libstd/sys/windows/ext/process.rs4
-rw-r--r--src/libstd/sys/windows/ext/raw.rs9
-rw-r--r--src/libstd/sys/windows/ext/thread.rs6
-rw-r--r--src/libstd/sys/windows/fs.rs361
-rw-r--r--src/libstd/sys/windows/handle.rs104
-rw-r--r--src/libstd/sys/windows/io.rs17
-rw-r--r--src/libstd/sys/windows/os.rs144
-rw-r--r--src/libstd/sys/windows/os_str.rs13
-rw-r--r--src/libstd/sys/windows/path.rs9
-rw-r--r--src/libstd/sys/windows/pipe.rs99
-rw-r--r--src/libstd/sys/windows/rand.rs23
-rw-r--r--src/libstd/sys/windows/stack_overflow.rs5
-rw-r--r--src/libstd/sys/windows/stdio.rs72
-rw-r--r--src/libstd/sys/windows/stdio_uwp.rs7
-rw-r--r--src/libstd/sys/windows/thread.rs54
-rw-r--r--src/libstd/sys/windows/thread_local.rs25
24 files changed, 613 insertions, 518 deletions
diff --git a/src/libstd/sys/windows/alloc.rs b/src/libstd/sys/windows/alloc.rs
index a33c4019a2e..99b4d6c72a0 100644
--- a/src/libstd/sys/windows/alloc.rs
+++ b/src/libstd/sys/windows/alloc.rs
@@ -1,6 +1,6 @@
 use crate::alloc::{GlobalAlloc, Layout, System};
 use crate::sys::c;
-use crate::sys_common::alloc::{MIN_ALIGN, realloc_fallback};
+use crate::sys_common::alloc::{realloc_fallback, MIN_ALIGN};
 
 #[repr(C)]
 struct Header(*mut u8);
@@ -18,16 +18,12 @@ unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 {
 #[inline]
 unsafe fn allocate_with_flags(layout: Layout, flags: c::DWORD) -> *mut u8 {
     if layout.align() <= MIN_ALIGN {
-        return c::HeapAlloc(c::GetProcessHeap(), flags, layout.size()) as *mut u8
+        return c::HeapAlloc(c::GetProcessHeap(), flags, layout.size()) as *mut u8;
     }
 
     let size = layout.size() + layout.align();
     let ptr = c::HeapAlloc(c::GetProcessHeap(), flags, size);
-    if ptr.is_null() {
-        ptr as *mut u8
-    } else {
-        align_ptr(ptr as *mut u8, layout.align())
-    }
+    if ptr.is_null() { ptr as *mut u8 } else { align_ptr(ptr as *mut u8, layout.align()) }
 }
 
 #[stable(feature = "alloc_system_type", since = "1.28.0")]
@@ -46,13 +42,11 @@ unsafe impl GlobalAlloc for System {
     unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
         if layout.align() <= MIN_ALIGN {
             let err = c::HeapFree(c::GetProcessHeap(), 0, ptr as c::LPVOID);
-            debug_assert!(err != 0, "Failed to free heap memory: {}",
-                          c::GetLastError());
+            debug_assert!(err != 0, "Failed to free heap memory: {}", c::GetLastError());
         } else {
             let header = get_header(ptr);
             let err = c::HeapFree(c::GetProcessHeap(), 0, header.0 as c::LPVOID);
-            debug_assert!(err != 0, "Failed to free heap memory: {}",
-                          c::GetLastError());
+            debug_assert!(err != 0, "Failed to free heap memory: {}", c::GetLastError());
         }
     }
 
diff --git a/src/libstd/sys/windows/args.rs b/src/libstd/sys/windows/args.rs
index b04bb484eed..5fbea2a2910 100644
--- a/src/libstd/sys/windows/args.rs
+++ b/src/libstd/sys/windows/args.rs
@@ -1,26 +1,26 @@
 #![allow(dead_code)] // runtime init functions not used during testing
 
-use crate::os::windows::prelude::*;
-use crate::sys::windows::os::current_exe;
-use crate::sys::c;
 use crate::ffi::OsString;
 use crate::fmt;
-use crate::vec;
-use crate::slice;
+use crate::os::windows::prelude::*;
 use crate::path::PathBuf;
+use crate::slice;
+use crate::sys::c;
+use crate::sys::windows::os::current_exe;
+use crate::vec;
 
 use core::iter;
 
-pub unsafe fn init(_argc: isize, _argv: *const *const u8) { }
+pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
 
-pub unsafe fn cleanup() { }
+pub unsafe fn cleanup() {}
 
 pub fn args() -> Args {
     unsafe {
         let lp_cmd_line = c::GetCommandLineW();
-        let parsed_args_list = parse_lp_cmd_line(
-            lp_cmd_line as *const u16,
-            || current_exe().map(PathBuf::into_os_string).unwrap_or_else(|_| OsString::new()));
+        let parsed_args_list = parse_lp_cmd_line(lp_cmd_line as *const u16, || {
+            current_exe().map(PathBuf::into_os_string).unwrap_or_else(|_| OsString::new())
+        });
 
         Args { parsed_args_list: parsed_args_list.into_iter() }
     }
@@ -40,8 +40,10 @@ pub fn args() -> Args {
 /// Windows 10 Pro v1803, using an exhaustive test suite available at
 /// <https://gist.github.com/notriddle/dde431930c392e428055b2dc22e638f5> or
 /// <https://paste.gg/p/anonymous/47d6ed5f5bd549168b1c69c799825223>.
-unsafe fn parse_lp_cmd_line<F: Fn() -> OsString>(lp_cmd_line: *const u16, exe_name: F)
-                                                 -> Vec<OsString> {
+unsafe fn parse_lp_cmd_line<F: Fn() -> OsString>(
+    lp_cmd_line: *const u16,
+    exe_name: F,
+) -> Vec<OsString> {
     const BACKSLASH: u16 = '\\' as u16;
     const QUOTE: u16 = '"' as u16;
     const TAB: u16 = '\t' as u16;
@@ -84,7 +86,7 @@ unsafe fn parse_lp_cmd_line<F: Fn() -> OsString>(lp_cmd_line: *const u16, exe_na
         0..=SPACE => {
             ret_val.push(OsString::new());
             &cmd_line[1..]
-        },
+        }
         // The executable name ends at the next whitespace,
         // no matter what.
         _ => {
@@ -112,7 +114,7 @@ unsafe fn parse_lp_cmd_line<F: Fn() -> OsString>(lp_cmd_line: *const u16, exe_na
             BACKSLASH => {
                 backslash_count += 1;
                 was_in_quotes = false;
-            },
+            }
             QUOTE if backslash_count % 2 == 0 => {
                 cur.extend(iter::repeat(b'\\' as u16).take(backslash_count / 2));
                 backslash_count = 0;
@@ -171,30 +173,36 @@ impl<'a> fmt::Debug for ArgsInnerDebug<'a> {
 
 impl Args {
     pub fn inner_debug(&self) -> ArgsInnerDebug<'_> {
-        ArgsInnerDebug {
-            args: self
-        }
+        ArgsInnerDebug { args: self }
     }
 }
 
 impl Iterator for Args {
     type Item = OsString;
-    fn next(&mut self) -> Option<OsString> { self.parsed_args_list.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.parsed_args_list.size_hint() }
+    fn next(&mut self) -> Option<OsString> {
+        self.parsed_args_list.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.parsed_args_list.size_hint()
+    }
 }
 
 impl DoubleEndedIterator for Args {
-    fn next_back(&mut self) -> Option<OsString> { self.parsed_args_list.next_back() }
+    fn next_back(&mut self) -> Option<OsString> {
+        self.parsed_args_list.next_back()
+    }
 }
 
 impl ExactSizeIterator for Args {
-    fn len(&self) -> usize { self.parsed_args_list.len() }
+    fn len(&self) -> usize {
+        self.parsed_args_list.len()
+    }
 }
 
 #[cfg(test)]
 mod tests {
-    use crate::sys::windows::args::*;
     use crate::ffi::OsString;
+    use crate::sys::windows::args::*;
 
     fn chk(string: &str, parts: &[&str]) {
         let mut wide: Vec<u16> = OsString::from(string).encode_wide().collect();
@@ -245,7 +253,7 @@ mod tests {
         chk(r#"EXE "" """"#, &["EXE", "", "\""]);
         chk(
             r#"EXE "this is """all""" in the same argument""#,
-            &["EXE", "this is \"all\" in the same argument"]
+            &["EXE", "this is \"all\" in the same argument"],
         );
         chk(r#"EXE "a"""#, &["EXE", "a\""]);
         chk(r#"EXE "a"" a"#, &["EXE", "a\"", "a"]);
@@ -253,6 +261,6 @@ mod tests {
         chk(r#""EXE" check"#, &["EXE", "check"]);
         chk(r#""EXE check""#, &["EXE check"]);
         chk(r#""EXE """for""" check"#, &["EXE ", r#"for""#, "check"]);
-        chk(r#""EXE \"for\" check"#, &[r#"EXE \"#, r#"for""#,  "check"]);
+        chk(r#""EXE \"for\" check"#, &[r#"EXE \"#, r#"for""#, "check"]);
     }
 }
diff --git a/src/libstd/sys/windows/cmath.rs b/src/libstd/sys/windows/cmath.rs
index e744cb219a8..7c5bfa1bd06 100644
--- a/src/libstd/sys/windows/cmath.rs
+++ b/src/libstd/sys/windows/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 asin(n: c_double) -> c_double;
     pub fn atan(n: c_double) -> c_double;
@@ -32,7 +32,7 @@ pub use self::shims::*;
 mod shims {
     use libc::c_float;
 
-    extern {
+    extern "C" {
         pub fn acosf(n: c_float) -> c_float;
         pub fn asinf(n: c_float) -> c_float;
         pub fn atan2f(a: c_float, b: c_float) -> c_float;
diff --git a/src/libstd/sys/windows/compat.rs b/src/libstd/sys/windows/compat.rs
index 544b2087f92..d6d433f9d08 100644
--- a/src/libstd/sys/windows/compat.rs
+++ b/src/libstd/sys/windows/compat.rs
@@ -28,8 +28,7 @@ pub fn lookup(module: &str, symbol: &str) -> Option<usize> {
     }
 }
 
-pub fn store_func(ptr: &AtomicUsize, module: &str, symbol: &str,
-                  fallback: usize) -> usize {
+pub fn store_func(ptr: &AtomicUsize, module: &str, symbol: &str, fallback: usize) -> usize {
     let value = lookup(module, symbol).unwrap_or(fallback);
     ptr.store(value, Ordering::SeqCst);
     value
diff --git a/src/libstd/sys/windows/ext/ffi.rs b/src/libstd/sys/windows/ext/ffi.rs
index 1381825806f..6e78119383f 100644
--- a/src/libstd/sys/windows/ext/ffi.rs
+++ b/src/libstd/sys/windows/ext/ffi.rs
@@ -59,10 +59,10 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use crate::ffi::{OsString, OsStr};
+use crate::ffi::{OsStr, OsString};
 use crate::sys::os_str::Buf;
 use crate::sys_common::wtf8::Wtf8Buf;
-use crate::sys_common::{FromInner, AsInner};
+use crate::sys_common::{AsInner, FromInner};
 
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use crate::sys_common::wtf8::EncodeWide;
diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs
index 23964dc5bd5..7eaff226a76 100644
--- a/src/libstd/sys/windows/ext/fs.rs
+++ b/src/libstd/sys/windows/ext/fs.rs
@@ -2,11 +2,11 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use crate::fs::{self, OpenOptions, Metadata};
+use crate::fs::{self, Metadata, OpenOptions};
 use crate::io;
 use crate::path::Path;
 use crate::sys;
-use crate::sys_common::{AsInnerMut, AsInner};
+use crate::sys_common::{AsInner, AsInnerMut};
 
 /// Windows-specific extensions to [`File`].
 ///
@@ -265,23 +265,28 @@ pub trait OpenOptionsExt {
 #[stable(feature = "open_options_ext", since = "1.10.0")]
 impl OpenOptionsExt for OpenOptions {
     fn access_mode(&mut self, access: u32) -> &mut OpenOptions {
-        self.as_inner_mut().access_mode(access); self
+        self.as_inner_mut().access_mode(access);
+        self
     }
 
     fn share_mode(&mut self, share: u32) -> &mut OpenOptions {
-        self.as_inner_mut().share_mode(share); self
+        self.as_inner_mut().share_mode(share);
+        self
     }
 
     fn custom_flags(&mut self, flags: u32) -> &mut OpenOptions {
-        self.as_inner_mut().custom_flags(flags); self
+        self.as_inner_mut().custom_flags(flags);
+        self
     }
 
     fn attributes(&mut self, attributes: u32) -> &mut OpenOptions {
-        self.as_inner_mut().attributes(attributes); self
+        self.as_inner_mut().attributes(attributes);
+        self
     }
 
     fn security_qos_flags(&mut self, flags: u32) -> &mut OpenOptions {
-        self.as_inner_mut().security_qos_flags(flags); self
+        self.as_inner_mut().security_qos_flags(flags);
+        self
     }
 }
 
@@ -468,14 +473,30 @@ pub trait MetadataExt {
 
 #[stable(feature = "metadata_ext", since = "1.1.0")]
 impl MetadataExt for Metadata {
-    fn file_attributes(&self) -> u32 { self.as_inner().attrs() }
-    fn creation_time(&self) -> u64 { self.as_inner().created_u64() }
-    fn last_access_time(&self) -> u64 { self.as_inner().accessed_u64() }
-    fn last_write_time(&self) -> u64 { self.as_inner().modified_u64() }
-    fn file_size(&self) -> u64 { self.as_inner().size() }
-    fn volume_serial_number(&self) -> Option<u32> { self.as_inner().volume_serial_number() }
-    fn number_of_links(&self) -> Option<u32> { self.as_inner().number_of_links() }
-    fn file_index(&self) -> Option<u64> { self.as_inner().file_index() }
+    fn file_attributes(&self) -> u32 {
+        self.as_inner().attrs()
+    }
+    fn creation_time(&self) -> u64 {
+        self.as_inner().created_u64()
+    }
+    fn last_access_time(&self) -> u64 {
+        self.as_inner().accessed_u64()
+    }
+    fn last_write_time(&self) -> u64 {
+        self.as_inner().modified_u64()
+    }
+    fn file_size(&self) -> u64 {
+        self.as_inner().size()
+    }
+    fn volume_serial_number(&self) -> Option<u32> {
+        self.as_inner().volume_serial_number()
+    }
+    fn number_of_links(&self) -> Option<u32> {
+        self.as_inner().number_of_links()
+    }
+    fn file_index(&self) -> Option<u64> {
+        self.as_inner().file_index()
+    }
 }
 
 /// Windows-specific extensions to [`FileType`].
@@ -495,8 +516,12 @@ pub trait FileTypeExt {
 
 #[unstable(feature = "windows_file_type_ext", issue = "0")]
 impl FileTypeExt for fs::FileType {
-    fn is_symlink_dir(&self) -> bool { self.as_inner().is_symlink_dir() }
-    fn is_symlink_file(&self) -> bool { self.as_inner().is_symlink_file() }
+    fn is_symlink_dir(&self) -> bool {
+        self.as_inner().is_symlink_dir()
+    }
+    fn is_symlink_file(&self) -> bool {
+        self.as_inner().is_symlink_file()
+    }
 }
 
 /// Creates a new file symbolic link on the filesystem.
@@ -515,8 +540,7 @@ impl FileTypeExt for fs::FileType {
 /// }
 /// ```
 #[stable(feature = "symlink", since = "1.1.0")]
-pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q)
-                                                    -> io::Result<()> {
+pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
     sys::fs::symlink_inner(src.as_ref(), dst.as_ref(), false)
 }
 
@@ -536,7 +560,6 @@ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q)
 /// }
 /// ```
 #[stable(feature = "symlink", since = "1.1.0")]
-pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q)
-                                                   -> io::Result<()> {
+pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
     sys::fs::symlink_inner(src.as_ref(), dst.as_ref(), true)
 }
diff --git a/src/libstd/sys/windows/ext/io.rs b/src/libstd/sys/windows/ext/io.rs
index ec47c2e9d5a..4573ee58932 100644
--- a/src/libstd/sys/windows/ext/io.rs
+++ b/src/libstd/sys/windows/ext/io.rs
@@ -1,12 +1,12 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 use crate::fs;
-use crate::os::windows::raw;
+use crate::io;
 use crate::net;
-use crate::sys_common::{self, AsInner, FromInner, IntoInner};
+use crate::os::windows::raw;
 use crate::sys;
 use crate::sys::c;
-use crate::io;
+use crate::sys_common::{self, AsInner, FromInner, IntoInner};
 
 /// Raw HANDLEs.
 #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/libstd/sys/windows/ext/mod.rs b/src/libstd/sys/windows/ext/mod.rs
index 0a6d435d329..613d3dc189a 100644
--- a/src/libstd/sys/windows/ext/mod.rs
+++ b/src/libstd/sys/windows/ext/mod.rs
@@ -13,8 +13,8 @@
 pub mod ffi;
 pub mod fs;
 pub mod io;
-pub mod raw;
 pub mod process;
+pub mod raw;
 pub mod thread;
 
 /// A prelude for conveniently writing platform-specific code.
@@ -22,14 +22,19 @@ pub mod thread;
 /// Includes all extension traits, and some important type definitions.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub mod prelude {
-    #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
-    pub use super::io::{RawSocket, RawHandle, AsRawSocket, AsRawHandle};
-    #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
-    pub use super::io::{FromRawSocket, FromRawHandle, IntoRawSocket, IntoRawHandle};
-    #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub use super::ffi::{OsStrExt, OsStringExt};
-    #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
-    pub use super::fs::{OpenOptionsExt, MetadataExt};
-    #[doc(no_inline)] #[stable(feature = "file_offset", since = "1.15.0")]
+    #[doc(no_inline)]
+    #[stable(feature = "file_offset", since = "1.15.0")]
     pub use super::fs::FileExt;
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub use super::fs::{MetadataExt, OpenOptionsExt};
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub use super::io::{AsRawHandle, AsRawSocket, RawHandle, RawSocket};
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub use super::io::{FromRawHandle, FromRawSocket, IntoRawHandle, IntoRawSocket};
 }
diff --git a/src/libstd/sys/windows/ext/process.rs b/src/libstd/sys/windows/ext/process.rs
index b2e6cdead4f..ed35c5ff194 100644
--- a/src/libstd/sys/windows/ext/process.rs
+++ b/src/libstd/sys/windows/ext/process.rs
@@ -2,10 +2,10 @@
 
 #![stable(feature = "process_extensions", since = "1.2.0")]
 
-use crate::os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle};
+use crate::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
 use crate::process;
 use crate::sys;
-use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
+use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
 
 #[stable(feature = "process_extensions", since = "1.2.0")]
 impl FromRawHandle for process::Stdio {
diff --git a/src/libstd/sys/windows/ext/raw.rs b/src/libstd/sys/windows/ext/raw.rs
index d2bab272036..7f2a2877828 100644
--- a/src/libstd/sys/windows/ext/raw.rs
+++ b/src/libstd/sys/windows/ext/raw.rs
@@ -4,8 +4,11 @@
 
 use crate::os::raw::c_void;
 
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type HANDLE = *mut c_void;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type HANDLE = *mut c_void;
 #[cfg(target_pointer_width = "32")]
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type SOCKET = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type SOCKET = u32;
 #[cfg(target_pointer_width = "64")]
-#[stable(feature = "raw_ext", since = "1.1.0")] pub type SOCKET = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub type SOCKET = u64;
diff --git a/src/libstd/sys/windows/ext/thread.rs b/src/libstd/sys/windows/ext/thread.rs
index fdc7e7fa32f..41c29f5b950 100644
--- a/src/libstd/sys/windows/ext/thread.rs
+++ b/src/libstd/sys/windows/ext/thread.rs
@@ -2,9 +2,9 @@
 
 #![stable(feature = "thread_extensions", since = "1.9.0")]
 
-use crate::os::windows::io::{RawHandle, AsRawHandle, IntoRawHandle};
-use crate::thread;
+use crate::os::windows::io::{AsRawHandle, IntoRawHandle, RawHandle};
 use crate::sys_common::{AsInner, IntoInner};
+use crate::thread;
 
 #[stable(feature = "thread_extensions", since = "1.9.0")]
 impl<T> AsRawHandle for thread::JoinHandle<T> {
@@ -14,7 +14,7 @@ impl<T> AsRawHandle for thread::JoinHandle<T> {
 }
 
 #[stable(feature = "thread_extensions", since = "1.9.0")]
-impl<T> IntoRawHandle for thread::JoinHandle<T>  {
+impl<T> IntoRawHandle for thread::JoinHandle<T> {
     fn into_raw_handle(self) -> RawHandle {
         self.into_inner().into_handle().into_raw() as *mut _
     }
diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs
index 4160123c9a2..e9c84c4e7c9 100644
--- a/src/libstd/sys/windows/fs.rs
+++ b/src/libstd/sys/windows/fs.rs
@@ -2,7 +2,7 @@ use crate::os::windows::prelude::*;
 
 use crate::ffi::OsString;
 use crate::fmt;
-use crate::io::{self, Error, SeekFrom, IoSlice, IoSliceMut};
+use crate::io::{self, Error, IoSlice, IoSliceMut, SeekFrom};
 use crate::mem;
 use crate::path::{Path, PathBuf};
 use crate::ptr;
@@ -15,7 +15,9 @@ use crate::sys_common::FromInner;
 
 use super::to_u16s;
 
-pub struct File { handle: Handle }
+pub struct File {
+    handle: Handle,
+}
 
 #[derive(Clone)]
 pub struct FileAttr {
@@ -71,7 +73,9 @@ pub struct OpenOptions {
 }
 
 #[derive(Clone, PartialEq, Eq, Debug)]
-pub struct FilePermissions { attrs: c::DWORD }
+pub struct FilePermissions {
+    attrs: c::DWORD,
+}
 
 #[derive(Debug)]
 pub struct DirBuilder;
@@ -97,13 +101,13 @@ impl Iterator for ReadDir {
             loop {
                 if c::FindNextFileW(self.handle.0, &mut wfd) == 0 {
                     if c::GetLastError() == c::ERROR_NO_MORE_FILES {
-                        return None
+                        return None;
                     } else {
-                        return Some(Err(Error::last_os_error()))
+                        return Some(Err(Error::last_os_error()));
                     }
                 }
                 if let Some(e) = DirEntry::new(&self.root, &wfd) {
-                    return Some(Ok(e))
+                    return Some(Ok(e));
                 }
             }
         }
@@ -121,15 +125,11 @@ impl DirEntry {
     fn new(root: &Arc<PathBuf>, wfd: &c::WIN32_FIND_DATAW) -> Option<DirEntry> {
         match &wfd.cFileName[0..3] {
             // check for '.' and '..'
-            &[46, 0, ..] |
-            &[46, 46, 0, ..] => return None,
+            &[46, 0, ..] | &[46, 46, 0, ..] => return None,
             _ => {}
         }
 
-        Some(DirEntry {
-            root: root.clone(),
-            data: *wfd,
-        })
+        Some(DirEntry { root: root.clone(), data: *wfd })
     }
 
     pub fn path(&self) -> PathBuf {
@@ -142,8 +142,10 @@ impl DirEntry {
     }
 
     pub fn file_type(&self) -> io::Result<FileType> {
-        Ok(FileType::new(self.data.dwFileAttributes,
-                         /* reparse_tag = */ self.data.dwReserved0))
+        Ok(FileType::new(
+            self.data.dwFileAttributes,
+            /* reparse_tag = */ self.data.dwReserved0,
+        ))
     }
 
     pub fn metadata(&self) -> io::Result<FileAttr> {
@@ -154,11 +156,11 @@ impl DirEntry {
             last_write_time: self.data.ftLastWriteTime,
             file_size: ((self.data.nFileSizeHigh as u64) << 32) | (self.data.nFileSizeLow as u64),
             reparse_tag: if self.data.dwFileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 {
-                    // reserved unless this is a reparse point
-                    self.data.dwReserved0
-                } else {
-                    0
-                },
+                // reserved unless this is a reparse point
+                self.data.dwReserved0
+            } else {
+                0
+            },
             volume_serial_number: None,
             number_of_links: None,
             file_index: None,
@@ -186,17 +188,37 @@ impl OpenOptions {
         }
     }
 
-    pub fn read(&mut self, read: bool) { self.read = read; }
-    pub fn write(&mut self, write: bool) { self.write = write; }
-    pub fn append(&mut self, append: bool) { self.append = append; }
-    pub fn truncate(&mut self, truncate: bool) { self.truncate = truncate; }
-    pub fn create(&mut self, create: bool) { self.create = create; }
-    pub fn create_new(&mut self, create_new: bool) { self.create_new = create_new; }
+    pub fn read(&mut self, read: bool) {
+        self.read = read;
+    }
+    pub fn write(&mut self, write: bool) {
+        self.write = write;
+    }
+    pub fn append(&mut self, append: bool) {
+        self.append = append;
+    }
+    pub fn truncate(&mut self, truncate: bool) {
+        self.truncate = truncate;
+    }
+    pub fn create(&mut self, create: bool) {
+        self.create = create;
+    }
+    pub fn create_new(&mut self, create_new: bool) {
+        self.create_new = create_new;
+    }
 
-    pub fn custom_flags(&mut self, flags: u32) { self.custom_flags = flags; }
-    pub fn access_mode(&mut self, access_mode: u32) { self.access_mode = Some(access_mode); }
-    pub fn share_mode(&mut self, share_mode: u32) { self.share_mode = share_mode; }
-    pub fn attributes(&mut self, attrs: u32) { self.attributes = attrs; }
+    pub fn custom_flags(&mut self, flags: u32) {
+        self.custom_flags = flags;
+    }
+    pub fn access_mode(&mut self, access_mode: u32) {
+        self.access_mode = Some(access_mode);
+    }
+    pub fn share_mode(&mut self, share_mode: u32) {
+        self.share_mode = share_mode;
+    }
+    pub fn attributes(&mut self, attrs: u32) {
+        self.attributes = attrs;
+    }
     pub fn security_qos_flags(&mut self, flags: u32) {
         // We have to set `SECURITY_SQOS_PRESENT` here, because one of the valid flags we can
         // receive is `SECURITY_ANONYMOUS = 0x0`, which we can't check for later on.
@@ -211,12 +233,13 @@ impl OpenOptions {
 
         match (self.read, self.write, self.append, self.access_mode) {
             (.., Some(mode)) => Ok(mode),
-            (true,  false, false, None) => Ok(c::GENERIC_READ),
-            (false, true,  false, None) => Ok(c::GENERIC_WRITE),
-            (true,  true,  false, None) => Ok(c::GENERIC_READ | c::GENERIC_WRITE),
-            (false, _,     true,  None) => Ok(c::FILE_GENERIC_WRITE & !c::FILE_WRITE_DATA),
-            (true,  _,     true,  None) => Ok(c::GENERIC_READ |
-                                              (c::FILE_GENERIC_WRITE & !c::FILE_WRITE_DATA)),
+            (true, false, false, None) => Ok(c::GENERIC_READ),
+            (false, true, false, None) => Ok(c::GENERIC_WRITE),
+            (true, true, false, None) => Ok(c::GENERIC_READ | c::GENERIC_WRITE),
+            (false, _, true, None) => Ok(c::FILE_GENERIC_WRITE & !c::FILE_WRITE_DATA),
+            (true, _, true, None) => {
+                Ok(c::GENERIC_READ | (c::FILE_GENERIC_WRITE & !c::FILE_WRITE_DATA))
+            }
             (false, false, false, None) => Err(Error::from_raw_os_error(ERROR_INVALID_PARAMETER)),
         }
     }
@@ -226,30 +249,32 @@ impl OpenOptions {
 
         match (self.write, self.append) {
             (true, false) => {}
-            (false, false) =>
+            (false, false) => {
                 if self.truncate || self.create || self.create_new {
                     return Err(Error::from_raw_os_error(ERROR_INVALID_PARAMETER));
-                },
-            (_, true) =>
+                }
+            }
+            (_, true) => {
                 if self.truncate && !self.create_new {
                     return Err(Error::from_raw_os_error(ERROR_INVALID_PARAMETER));
-                },
+                }
+            }
         }
 
         Ok(match (self.create, self.truncate, self.create_new) {
-                (false, false, false) => c::OPEN_EXISTING,
-                (true,  false, false) => c::OPEN_ALWAYS,
-                (false, true,  false) => c::TRUNCATE_EXISTING,
-                (true,  true,  false) => c::CREATE_ALWAYS,
-                (_,      _,    true)  => c::CREATE_NEW,
-           })
+            (false, false, false) => c::OPEN_EXISTING,
+            (true, false, false) => c::OPEN_ALWAYS,
+            (false, true, false) => c::TRUNCATE_EXISTING,
+            (true, true, false) => c::CREATE_ALWAYS,
+            (_, _, true) => c::CREATE_NEW,
+        })
     }
 
     fn get_flags_and_attributes(&self) -> c::DWORD {
-        self.custom_flags |
-        self.attributes |
-        self.security_qos_flags |
-        if self.create_new { c::FILE_FLAG_OPEN_REPARSE_POINT } else { 0 }
+        self.custom_flags
+            | self.attributes
+            | self.security_qos_flags
+            | if self.create_new { c::FILE_FLAG_OPEN_REPARSE_POINT } else { 0 }
     }
 }
 
@@ -257,13 +282,15 @@ impl File {
     pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
         let path = to_u16s(path)?;
         let handle = unsafe {
-            c::CreateFileW(path.as_ptr(),
-                           opts.get_access_mode()?,
-                           opts.share_mode,
-                           opts.security_attributes as *mut _,
-                           opts.get_creation_mode()?,
-                           opts.get_flags_and_attributes(),
-                           ptr::null_mut())
+            c::CreateFileW(
+                path.as_ptr(),
+                opts.get_access_mode()?,
+                opts.share_mode,
+                opts.security_attributes as *mut _,
+                opts.get_creation_mode()?,
+                opts.get_flags_and_attributes(),
+                ptr::null_mut(),
+            )
         };
         if handle == c::INVALID_HANDLE_VALUE {
             Err(Error::last_os_error())
@@ -277,18 +304,20 @@ impl File {
         Ok(())
     }
 
-    pub fn datasync(&self) -> io::Result<()> { self.fsync() }
+    pub fn datasync(&self) -> io::Result<()> {
+        self.fsync()
+    }
 
     pub fn truncate(&self, size: u64) -> io::Result<()> {
-        let mut info = c::FILE_END_OF_FILE_INFO {
-            EndOfFile: size as c::LARGE_INTEGER,
-        };
+        let mut info = c::FILE_END_OF_FILE_INFO { EndOfFile: size as c::LARGE_INTEGER };
         let size = mem::size_of_val(&info);
         cvt(unsafe {
-            c::SetFileInformationByHandle(self.handle.raw(),
-                                          c::FileEndOfFileInfo,
-                                          &mut info as *mut _ as *mut _,
-                                          size as c::DWORD)
+            c::SetFileInformationByHandle(
+                self.handle.raw(),
+                c::FileEndOfFileInfo,
+                &mut info as *mut _ as *mut _,
+                size as c::DWORD,
+            )
         })?;
         Ok(())
     }
@@ -314,8 +343,9 @@ impl File {
                 reparse_tag,
                 volume_serial_number: Some(info.dwVolumeSerialNumber),
                 number_of_links: Some(info.nNumberOfLinks),
-                file_index: Some((info.nFileIndexLow as u64) |
-                                 ((info.nFileIndexHigh as u64) << 32)),
+                file_index: Some(
+                    (info.nFileIndexLow as u64) | ((info.nFileIndexHigh as u64) << 32),
+                ),
             })
         }
     }
@@ -325,10 +355,12 @@ impl File {
         unsafe {
             let mut info: c::FILE_BASIC_INFO = mem::zeroed();
             let size = mem::size_of_val(&info);
-            cvt(c::GetFileInformationByHandleEx(self.handle.raw(),
-                                              c::FileBasicInfo,
-                                              &mut info as *mut _ as *mut libc::c_void,
-                                              size as c::DWORD))?;
+            cvt(c::GetFileInformationByHandleEx(
+                self.handle.raw(),
+                c::FileBasicInfo,
+                &mut info as *mut _ as *mut libc::c_void,
+                size as c::DWORD,
+            ))?;
             let mut attr = FileAttr {
                 attributes: info.FileAttributes,
                 creation_time: c::FILETIME {
@@ -351,10 +383,12 @@ impl File {
             };
             let mut info: c::FILE_STANDARD_INFO = mem::zeroed();
             let size = mem::size_of_val(&info);
-            cvt(c::GetFileInformationByHandleEx(self.handle.raw(),
-                                                c::FileStandardInfo,
-                                                &mut info as *mut _ as *mut libc::c_void,
-                                                size as c::DWORD))?;
+            cvt(c::GetFileInformationByHandleEx(
+                self.handle.raw(),
+                c::FileStandardInfo,
+                &mut info as *mut _ as *mut libc::c_void,
+                size as c::DWORD,
+            ))?;
             attr.file_size = info.AllocationSize as u64;
             attr.number_of_links = Some(info.NumberOfLinks);
             if attr.file_type().is_reparse_point() {
@@ -391,7 +425,9 @@ impl File {
         self.handle.write_at(buf, offset)
     }
 
-    pub fn flush(&self) -> io::Result<()> { Ok(()) }
+    pub fn flush(&self) -> io::Result<()> {
+        Ok(())
+    }
 
     pub fn seek(&self, pos: SeekFrom) -> io::Result<u64> {
         let (whence, pos) = match pos {
@@ -403,37 +439,39 @@ impl File {
         };
         let pos = pos as c::LARGE_INTEGER;
         let mut newpos = 0;
-        cvt(unsafe {
-            c::SetFilePointerEx(self.handle.raw(), pos,
-                                &mut newpos, whence)
-        })?;
+        cvt(unsafe { c::SetFilePointerEx(self.handle.raw(), pos, &mut newpos, whence) })?;
         Ok(newpos as u64)
     }
 
     pub fn duplicate(&self) -> io::Result<File> {
-        Ok(File {
-            handle: self.handle.duplicate(0, false, c::DUPLICATE_SAME_ACCESS)?,
-        })
+        Ok(File { handle: self.handle.duplicate(0, false, c::DUPLICATE_SAME_ACCESS)? })
     }
 
-    pub fn handle(&self) -> &Handle { &self.handle }
+    pub fn handle(&self) -> &Handle {
+        &self.handle
+    }
 
-    pub fn into_handle(self) -> Handle { self.handle }
+    pub fn into_handle(self) -> Handle {
+        self.handle
+    }
 
-    fn reparse_point<'a>(&self,
-                         space: &'a mut [u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE])
-                         -> io::Result<(c::DWORD, &'a c::REPARSE_DATA_BUFFER)> {
+    fn reparse_point<'a>(
+        &self,
+        space: &'a mut [u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE],
+    ) -> io::Result<(c::DWORD, &'a c::REPARSE_DATA_BUFFER)> {
         unsafe {
             let mut bytes = 0;
             cvt({
-                c::DeviceIoControl(self.handle.raw(),
-                                   c::FSCTL_GET_REPARSE_POINT,
-                                   ptr::null_mut(),
-                                   0,
-                                   space.as_mut_ptr() as *mut _,
-                                   space.len() as c::DWORD,
-                                   &mut bytes,
-                                   ptr::null_mut())
+                c::DeviceIoControl(
+                    self.handle.raw(),
+                    c::FSCTL_GET_REPARSE_POINT,
+                    ptr::null_mut(),
+                    0,
+                    space.as_mut_ptr() as *mut _,
+                    space.len() as c::DWORD,
+                    &mut bytes,
+                    ptr::null_mut(),
+                )
             })?;
             Ok((bytes, &*(space.as_ptr() as *const c::REPARSE_DATA_BUFFER)))
         }
@@ -447,21 +485,29 @@ impl File {
                 c::IO_REPARSE_TAG_SYMLINK => {
                     let info: *const c::SYMBOLIC_LINK_REPARSE_BUFFER =
                         &buf.rest as *const _ as *const _;
-                    (&(*info).PathBuffer as *const _ as *const u16,
-                     (*info).SubstituteNameOffset / 2,
-                     (*info).SubstituteNameLength / 2,
-                     (*info).Flags & c::SYMLINK_FLAG_RELATIVE != 0)
-                },
+                    (
+                        &(*info).PathBuffer as *const _ as *const u16,
+                        (*info).SubstituteNameOffset / 2,
+                        (*info).SubstituteNameLength / 2,
+                        (*info).Flags & c::SYMLINK_FLAG_RELATIVE != 0,
+                    )
+                }
                 c::IO_REPARSE_TAG_MOUNT_POINT => {
                     let info: *const c::MOUNT_POINT_REPARSE_BUFFER =
                         &buf.rest as *const _ as *const _;
-                    (&(*info).PathBuffer as *const _ as *const u16,
-                     (*info).SubstituteNameOffset / 2,
-                     (*info).SubstituteNameLength / 2,
-                     false)
-                },
-                _ => return Err(io::Error::new(io::ErrorKind::Other,
-                                               "Unsupported reparse point type"))
+                    (
+                        &(*info).PathBuffer as *const _ as *const u16,
+                        (*info).SubstituteNameOffset / 2,
+                        (*info).SubstituteNameLength / 2,
+                        false,
+                    )
+                }
+                _ => {
+                    return Err(io::Error::new(
+                        io::ErrorKind::Other,
+                        "Unsupported reparse point type",
+                    ));
+                }
             };
             let subst_ptr = path_buffer.offset(subst_off as isize);
             let mut subst = slice::from_raw_parts(subst_ptr, subst_len as usize);
@@ -484,10 +530,12 @@ impl File {
         };
         let size = mem::size_of_val(&info);
         cvt(unsafe {
-            c::SetFileInformationByHandle(self.handle.raw(),
-                                          c::FileBasicInfo,
-                                          &mut info as *mut _ as *mut _,
-                                          size as c::DWORD)
+            c::SetFileInformationByHandle(
+                self.handle.raw(),
+                c::FileBasicInfo,
+                &mut info as *mut _ as *mut _,
+                size as c::DWORD,
+            )
         })?;
         Ok(())
     }
@@ -585,10 +633,7 @@ impl FilePermissions {
 
 impl FileType {
     fn new(attrs: c::DWORD, reparse_tag: c::DWORD) -> FileType {
-        FileType {
-            attributes: attrs,
-            reparse_tag: reparse_tag,
-        }
+        FileType { attributes: attrs, reparse_tag: reparse_tag }
     }
     pub fn is_dir(&self) -> bool {
         !self.is_symlink() && self.is_directory()
@@ -617,13 +662,13 @@ impl FileType {
 }
 
 impl DirBuilder {
-    pub fn new() -> DirBuilder { DirBuilder }
+    pub fn new() -> DirBuilder {
+        DirBuilder
+    }
 
     pub fn mkdir(&self, p: &Path) -> io::Result<()> {
         let p = to_u16s(p)?;
-        cvt(unsafe {
-            c::CreateDirectoryW(p.as_ptr(), ptr::null_mut())
-        })?;
+        cvt(unsafe { c::CreateDirectoryW(p.as_ptr(), ptr::null_mut()) })?;
         Ok(())
     }
 }
@@ -657,9 +702,7 @@ pub fn unlink(p: &Path) -> io::Result<()> {
 pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
     let old = to_u16s(old)?;
     let new = to_u16s(new)?;
-    cvt(unsafe {
-        c::MoveFileExW(old.as_ptr(), new.as_ptr(), c::MOVEFILE_REPLACE_EXISTING)
-    })?;
+    cvt(unsafe { c::MoveFileExW(old.as_ptr(), new.as_ptr(), c::MOVEFILE_REPLACE_EXISTING) })?;
     Ok(())
 }
 
@@ -701,8 +744,7 @@ pub fn readlink(path: &Path) -> io::Result<PathBuf> {
     // this is needed for a common case.
     let mut opts = OpenOptions::new();
     opts.access_mode(0);
-    opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT |
-                      c::FILE_FLAG_BACKUP_SEMANTICS);
+    opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT | c::FILE_FLAG_BACKUP_SEMANTICS);
     let file = File::open(&path, &opts)?;
     file.readlink()
 }
@@ -720,16 +762,17 @@ pub fn symlink_inner(src: &Path, dst: &Path, dir: bool) -> io::Result<()> {
     // computer is in Developer Mode, but SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE must be
     // added to dwFlags to opt into this behaviour.
     let result = cvt(unsafe {
-        c::CreateSymbolicLinkW(dst.as_ptr(), src.as_ptr(),
-                               flags | c::SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) as c::BOOL
+        c::CreateSymbolicLinkW(
+            dst.as_ptr(),
+            src.as_ptr(),
+            flags | c::SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE,
+        ) as c::BOOL
     });
     if let Err(err) = result {
         if err.raw_os_error() == Some(c::ERROR_INVALID_PARAMETER as i32) {
             // Older Windows objects to SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE,
             // so if we encounter ERROR_INVALID_PARAMETER, retry without that flag.
-            cvt(unsafe {
-                c::CreateSymbolicLinkW(dst.as_ptr(), src.as_ptr(), flags) as c::BOOL
-            })?;
+            cvt(unsafe { c::CreateSymbolicLinkW(dst.as_ptr(), src.as_ptr(), flags) as c::BOOL })?;
         } else {
             return Err(err);
         }
@@ -741,16 +784,13 @@ pub fn symlink_inner(src: &Path, dst: &Path, dir: bool) -> io::Result<()> {
 pub fn link(src: &Path, dst: &Path) -> io::Result<()> {
     let src = to_u16s(src)?;
     let dst = to_u16s(dst)?;
-    cvt(unsafe {
-        c::CreateHardLinkW(dst.as_ptr(), src.as_ptr(), ptr::null_mut())
-    })?;
+    cvt(unsafe { c::CreateHardLinkW(dst.as_ptr(), src.as_ptr(), ptr::null_mut()) })?;
     Ok(())
 }
 
 #[cfg(target_vendor = "uwp")]
 pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> {
-    return Err(io::Error::new(io::ErrorKind::Other,
-                            "hard link are not supported on UWP"));
+    return Err(io::Error::new(io::ErrorKind::Other, "hard link are not supported on UWP"));
 }
 
 pub fn stat(path: &Path) -> io::Result<FileAttr> {
@@ -781,12 +821,12 @@ pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
 }
 
 fn get_path(f: &File) -> io::Result<PathBuf> {
-    super::fill_utf16_buf(|buf, sz| unsafe {
-        c::GetFinalPathNameByHandleW(f.handle.raw(), buf, sz,
-                                     c::VOLUME_NAME_DOS)
-    }, |buf| {
-        PathBuf::from(OsString::from_wide(buf))
-    })
+    super::fill_utf16_buf(
+        |buf, sz| unsafe {
+            c::GetFinalPathNameByHandleW(f.handle.raw(), buf, sz, c::VOLUME_NAME_DOS)
+        },
+        |buf| PathBuf::from(OsString::from_wide(buf)),
+    )
 }
 
 pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
@@ -811,15 +851,23 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
         _hDestinationFile: c::HANDLE,
         lpData: c::LPVOID,
     ) -> c::DWORD {
-        if dwStreamNumber == 1 {*(lpData as *mut i64) = StreamBytesTransferred;}
+        if dwStreamNumber == 1 {
+            *(lpData as *mut i64) = StreamBytesTransferred;
+        }
         c::PROGRESS_CONTINUE
     }
     let pfrom = to_u16s(from)?;
     let pto = to_u16s(to)?;
     let mut size = 0i64;
     cvt(unsafe {
-        c::CopyFileExW(pfrom.as_ptr(), pto.as_ptr(), Some(callback),
-                       &mut size as *mut _ as *mut _, ptr::null_mut(), 0)
+        c::CopyFileExW(
+            pfrom.as_ptr(),
+            pto.as_ptr(),
+            Some(callback),
+            &mut size as *mut _ as *mut _,
+            ptr::null_mut(),
+            0,
+        )
     })?;
     Ok(size as u64)
 }
@@ -841,15 +889,13 @@ fn symlink_junction_inner(target: &Path, junction: &Path) -> io::Result<()> {
 
     let mut opts = OpenOptions::new();
     opts.write(true);
-    opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT |
-                      c::FILE_FLAG_BACKUP_SEMANTICS);
+    opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT | c::FILE_FLAG_BACKUP_SEMANTICS);
     let f = File::open(junction, &opts)?;
     let h = f.handle().raw();
 
     unsafe {
         let mut data = [0u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
-        let db = data.as_mut_ptr()
-                    as *mut c::REPARSE_MOUNTPOINT_DATA_BUFFER;
+        let db = data.as_mut_ptr() as *mut c::REPARSE_MOUNTPOINT_DATA_BUFFER;
         let buf = &mut (*db).ReparseTarget as *mut c::WCHAR;
         let mut i = 0;
         // FIXME: this conversion is very hacky
@@ -864,16 +910,19 @@ fn symlink_junction_inner(target: &Path, junction: &Path) -> io::Result<()> {
         (*db).ReparseTag = c::IO_REPARSE_TAG_MOUNT_POINT;
         (*db).ReparseTargetMaximumLength = (i * 2) as c::WORD;
         (*db).ReparseTargetLength = ((i - 1) * 2) as c::WORD;
-        (*db).ReparseDataLength =
-                (*db).ReparseTargetLength as c::DWORD + 12;
+        (*db).ReparseDataLength = (*db).ReparseTargetLength as c::DWORD + 12;
 
         let mut ret = 0;
-        cvt(c::DeviceIoControl(h as *mut _,
-                               c::FSCTL_SET_REPARSE_POINT,
-                               data.as_ptr() as *mut _,
-                               (*db).ReparseDataLength + 8,
-                               ptr::null_mut(), 0,
-                               &mut ret,
-                               ptr::null_mut())).map(|_| ())
+        cvt(c::DeviceIoControl(
+            h as *mut _,
+            c::FSCTL_SET_REPARSE_POINT,
+            data.as_ptr() as *mut _,
+            (*db).ReparseDataLength + 8,
+            ptr::null_mut(),
+            0,
+            &mut ret,
+            ptr::null_mut(),
+        ))
+        .map(|_| ())
     }
 }
diff --git a/src/libstd/sys/windows/handle.rs b/src/libstd/sys/windows/handle.rs
index 3986cda1a50..ebaa0783d60 100644
--- a/src/libstd/sys/windows/handle.rs
+++ b/src/libstd/sys/windows/handle.rs
@@ -1,7 +1,7 @@
 #![unstable(issue = "0", feature = "windows_handle")]
 
 use crate::cmp;
-use crate::io::{self, ErrorKind, Read, IoSlice, IoSliceMut};
+use crate::io::{self, ErrorKind, IoSlice, IoSliceMut, Read};
 use crate::mem;
 use crate::ops::Deref;
 use crate::ptr;
@@ -31,15 +31,9 @@ impl Handle {
 
     pub fn new_event(manual: bool, init: bool) -> io::Result<Handle> {
         unsafe {
-            let event = c::CreateEventW(ptr::null_mut(),
-                                        manual as c::BOOL,
-                                        init as c::BOOL,
-                                        ptr::null());
-            if event.is_null() {
-                Err(io::Error::last_os_error())
-            } else {
-                Ok(Handle::new(event))
-            }
+            let event =
+                c::CreateEventW(ptr::null_mut(), manual as c::BOOL, init as c::BOOL, ptr::null());
+            if event.is_null() { Err(io::Error::last_os_error()) } else { Ok(Handle::new(event)) }
         }
     }
 
@@ -52,12 +46,16 @@ impl Handle {
 
 impl Deref for Handle {
     type Target = RawHandle;
-    fn deref(&self) -> &RawHandle { &self.0 }
+    fn deref(&self) -> &RawHandle {
+        &self.0
+    }
 }
 
 impl Drop for Handle {
     fn drop(&mut self) {
-        unsafe { let _ = c::CloseHandle(self.raw()); }
+        unsafe {
+            let _ = c::CloseHandle(self.raw());
+        }
     }
 }
 
@@ -66,14 +64,15 @@ impl RawHandle {
         RawHandle(handle)
     }
 
-    pub fn raw(&self) -> c::HANDLE { self.0 }
+    pub fn raw(&self) -> c::HANDLE {
+        self.0
+    }
 
     pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
         let mut read = 0;
         let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
         let res = cvt(unsafe {
-            c::ReadFile(self.0, buf.as_mut_ptr() as c::LPVOID,
-                        len, &mut read, ptr::null_mut())
+            c::ReadFile(self.0, buf.as_mut_ptr() as c::LPVOID, len, &mut read, ptr::null_mut())
         });
 
         match res {
@@ -85,7 +84,7 @@ impl RawHandle {
             // EOF on the pipe.
             Err(ref e) if e.kind() == ErrorKind::BrokenPipe => Ok(0),
 
-            Err(e) => Err(e)
+            Err(e) => Err(e),
         }
     }
 
@@ -100,8 +99,7 @@ impl RawHandle {
             let mut overlapped: c::OVERLAPPED = mem::zeroed();
             overlapped.Offset = offset as u32;
             overlapped.OffsetHigh = (offset >> 32) as u32;
-            cvt(c::ReadFile(self.0, buf.as_mut_ptr() as c::LPVOID,
-                            len, &mut read, &mut overlapped))
+            cvt(c::ReadFile(self.0, buf.as_mut_ptr() as c::LPVOID, len, &mut read, &mut overlapped))
         };
         match res {
             Ok(_) => Ok(read as usize),
@@ -110,16 +108,15 @@ impl RawHandle {
         }
     }
 
-    pub unsafe fn read_overlapped(&self,
-                                  buf: &mut [u8],
-                                  overlapped: *mut c::OVERLAPPED)
-                                  -> io::Result<Option<usize>> {
+    pub unsafe fn read_overlapped(
+        &self,
+        buf: &mut [u8],
+        overlapped: *mut c::OVERLAPPED,
+    ) -> io::Result<Option<usize>> {
         let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
         let mut amt = 0;
-        let res = cvt({
-            c::ReadFile(self.0, buf.as_ptr() as c::LPVOID,
-                        len, &mut amt, overlapped)
-        });
+        let res =
+            cvt({ c::ReadFile(self.0, buf.as_ptr() as c::LPVOID, len, &mut amt, overlapped) });
         match res {
             Ok(_) => Ok(Some(amt as usize)),
             Err(e) => {
@@ -134,20 +131,21 @@ impl RawHandle {
         }
     }
 
-    pub fn overlapped_result(&self,
-                             overlapped: *mut c::OVERLAPPED,
-                             wait: bool) -> io::Result<usize> {
+    pub fn overlapped_result(
+        &self,
+        overlapped: *mut c::OVERLAPPED,
+        wait: bool,
+    ) -> io::Result<usize> {
         unsafe {
             let mut bytes = 0;
-            let wait = if wait {c::TRUE} else {c::FALSE};
-            let res = cvt({
-                c::GetOverlappedResult(self.raw(), overlapped, &mut bytes, wait)
-            });
+            let wait = if wait { c::TRUE } else { c::FALSE };
+            let res = cvt({ c::GetOverlappedResult(self.raw(), overlapped, &mut bytes, wait) });
             match res {
                 Ok(_) => Ok(bytes as usize),
                 Err(e) => {
-                    if e.raw_os_error() == Some(c::ERROR_HANDLE_EOF as i32) ||
-                       e.raw_os_error() == Some(c::ERROR_BROKEN_PIPE as i32) {
+                    if e.raw_os_error() == Some(c::ERROR_HANDLE_EOF as i32)
+                        || e.raw_os_error() == Some(c::ERROR_BROKEN_PIPE as i32)
+                    {
                         Ok(0)
                     } else {
                         Err(e)
@@ -158,17 +156,14 @@ impl RawHandle {
     }
 
     pub fn cancel_io(&self) -> io::Result<()> {
-        unsafe {
-            cvt(c::CancelIo(self.raw())).map(|_| ())
-        }
+        unsafe { cvt(c::CancelIo(self.raw())).map(|_| ()) }
     }
 
     pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
         let mut amt = 0;
         let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
         cvt(unsafe {
-            c::WriteFile(self.0, buf.as_ptr() as c::LPVOID,
-                         len, &mut amt, ptr::null_mut())
+            c::WriteFile(self.0, buf.as_ptr() as c::LPVOID, len, &mut amt, ptr::null_mut())
         })?;
         Ok(amt as usize)
     }
@@ -184,20 +179,35 @@ impl RawHandle {
             let mut overlapped: c::OVERLAPPED = mem::zeroed();
             overlapped.Offset = offset as u32;
             overlapped.OffsetHigh = (offset >> 32) as u32;
-            cvt(c::WriteFile(self.0, buf.as_ptr() as c::LPVOID,
-                             len, &mut written, &mut overlapped))?;
+            cvt(c::WriteFile(
+                self.0,
+                buf.as_ptr() as c::LPVOID,
+                len,
+                &mut written,
+                &mut overlapped,
+            ))?;
         }
         Ok(written as usize)
     }
 
-    pub fn duplicate(&self, access: c::DWORD, inherit: bool,
-                     options: c::DWORD) -> io::Result<Handle> {
+    pub fn duplicate(
+        &self,
+        access: c::DWORD,
+        inherit: bool,
+        options: c::DWORD,
+    ) -> io::Result<Handle> {
         let mut ret = 0 as c::HANDLE;
         cvt(unsafe {
             let cur_proc = c::GetCurrentProcess();
-            c::DuplicateHandle(cur_proc, self.0, cur_proc, &mut ret,
-                            access, inherit as c::BOOL,
-                            options)
+            c::DuplicateHandle(
+                cur_proc,
+                self.0,
+                cur_proc,
+                &mut ret,
+                access,
+                inherit as c::BOOL,
+                options,
+            )
         })?;
         Ok(Handle::new(ret))
     }
diff --git a/src/libstd/sys/windows/io.rs b/src/libstd/sys/windows/io.rs
index e44dcbe164d..9d8018fd5e8 100644
--- a/src/libstd/sys/windows/io.rs
+++ b/src/libstd/sys/windows/io.rs
@@ -35,9 +35,7 @@ impl<'a> IoSlice<'a> {
 
     #[inline]
     pub fn as_slice(&self) -> &[u8] {
-        unsafe {
-            slice::from_raw_parts(self.vec.buf as *mut u8, self.vec.len as usize)
-        }
+        unsafe { slice::from_raw_parts(self.vec.buf as *mut u8, self.vec.len as usize) }
     }
 }
 
@@ -52,10 +50,7 @@ impl<'a> IoSliceMut<'a> {
     pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> {
         assert!(buf.len() <= c::ULONG::max_value() as usize);
         IoSliceMut {
-            vec: c::WSABUF {
-                len: buf.len() as c::ULONG,
-                buf: buf.as_mut_ptr() as *mut c::CHAR,
-            },
+            vec: c::WSABUF { len: buf.len() as c::ULONG, buf: buf.as_mut_ptr() as *mut c::CHAR },
             _p: PhantomData,
         }
     }
@@ -74,15 +69,11 @@ impl<'a> IoSliceMut<'a> {
 
     #[inline]
     pub fn as_slice(&self) -> &[u8] {
-        unsafe {
-            slice::from_raw_parts(self.vec.buf as *mut u8, self.vec.len as usize)
-        }
+        unsafe { slice::from_raw_parts(self.vec.buf as *mut u8, self.vec.len as usize) }
     }
 
     #[inline]
     pub fn as_mut_slice(&mut self) -> &mut [u8] {
-        unsafe {
-            slice::from_raw_parts_mut(self.vec.buf as *mut u8, self.vec.len as usize)
-        }
+        unsafe { slice::from_raw_parts_mut(self.vec.buf as *mut u8, self.vec.len as usize) }
     }
 }
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 7c400dce686..8631e50cf38 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -5,7 +5,7 @@
 use crate::os::windows::prelude::*;
 
 use crate::error::Error as StdError;
-use crate::ffi::{OsString, OsStr};
+use crate::ffi::{OsStr, OsString};
 use crate::fmt;
 use crate::io;
 use crate::os::windows::ffi::EncodeWide;
@@ -37,8 +37,10 @@ pub fn error_string(mut errnum: i32) -> String {
         // `[MS-ERREF]`: https://msdn.microsoft.com/en-us/library/cc231198.aspx
         if (errnum & c::FACILITY_NT_BIT as i32) != 0 {
             // format according to https://support.microsoft.com/en-us/help/259693
-            const NTDLL_DLL: &[u16] = &['N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _,
-                                        '.' as _, 'D' as _, 'L' as _, 'L' as _, 0];
+            const NTDLL_DLL: &[u16] = &[
+                'N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _, '.' as _, 'D' as _, 'L' as _,
+                'L' as _, 0,
+            ];
             module = c::GetModuleHandleW(NTDLL_DLL.as_ptr());
 
             if module != ptr::null_mut() {
@@ -47,19 +49,19 @@ pub fn error_string(mut errnum: i32) -> String {
             }
         }
 
-        let res = c::FormatMessageW(flags | c::FORMAT_MESSAGE_FROM_SYSTEM |
-                                        c::FORMAT_MESSAGE_IGNORE_INSERTS,
-                                    module,
-                                    errnum as c::DWORD,
-                                    langId,
-                                    buf.as_mut_ptr(),
-                                    buf.len() as c::DWORD,
-                                    ptr::null()) as usize;
+        let res = c::FormatMessageW(
+            flags | c::FORMAT_MESSAGE_FROM_SYSTEM | c::FORMAT_MESSAGE_IGNORE_INSERTS,
+            module,
+            errnum as c::DWORD,
+            langId,
+            buf.as_mut_ptr(),
+            buf.len() as c::DWORD,
+            ptr::null(),
+        ) as usize;
         if res == 0 {
             // Sometimes FormatMessageW can fail e.g., system doesn't like langId,
             let fm_err = errno();
-            return format!("OS Error {} (FormatMessageW() returned error {})",
-                           errnum, fm_err);
+            return format!("OS Error {} (FormatMessageW() returned error {})", errnum, fm_err);
         }
 
         match String::from_utf16(&buf[..res]) {
@@ -68,9 +70,12 @@ pub fn error_string(mut errnum: i32) -> String {
                 let len = msg.trim_end().len();
                 msg.truncate(len);
                 msg
-            },
-            Err(..) => format!("OS Error {} (FormatMessageW() returned \
-                                invalid UTF-16)", errnum),
+            }
+            Err(..) => format!(
+                "OS Error {} (FormatMessageW() returned \
+                 invalid UTF-16)",
+                errnum
+            ),
         }
     }
 }
@@ -86,7 +91,9 @@ impl Iterator for Env {
     fn next(&mut self) -> Option<(OsString, OsString)> {
         loop {
             unsafe {
-                if *self.cur == 0 { return None }
+                if *self.cur == 0 {
+                    return None;
+                }
                 let p = &*self.cur as *const u16;
                 let mut len = 0;
                 while *p.offset(len) != 0 {
@@ -106,8 +113,8 @@ impl Iterator for Env {
                 };
                 return Some((
                     OsStringExt::from_wide(&s[..pos]),
-                    OsStringExt::from_wide(&s[pos+1..]),
-                ))
+                    OsStringExt::from_wide(&s[pos + 1..]),
+                ));
             }
         }
     }
@@ -115,7 +122,9 @@ impl Iterator for Env {
 
 impl Drop for Env {
     fn drop(&mut self) {
-        unsafe { c::FreeEnvironmentStringsW(self.base); }
+        unsafe {
+            c::FreeEnvironmentStringsW(self.base);
+        }
     }
 }
 
@@ -123,8 +132,7 @@ pub fn env() -> Env {
     unsafe {
         let ch = c::GetEnvironmentStringsW();
         if ch as usize == 0 {
-            panic!("failure getting env string from OS: {}",
-                   io::Error::last_os_error());
+            panic!("failure getting env string from OS: {}", io::Error::last_os_error());
         }
         Env { base: ch, cur: ch }
     }
@@ -136,10 +144,7 @@ pub struct SplitPaths<'a> {
 }
 
 pub fn split_paths(unparsed: &OsStr) -> SplitPaths<'_> {
-    SplitPaths {
-        data: unparsed.encode_wide(),
-        must_yield: true,
-    }
+    SplitPaths { data: unparsed.encode_wide(), must_yield: true }
 }
 
 impl<'a> Iterator for SplitPaths<'a> {
@@ -158,7 +163,6 @@ impl<'a> Iterator for SplitPaths<'a> {
         // (The above is based on testing; there is no clear reference available
         // for the grammar.)
 
-
         let must_yield = self.must_yield;
         self.must_yield = false;
 
@@ -169,7 +173,7 @@ impl<'a> Iterator for SplitPaths<'a> {
                 in_quote = !in_quote;
             } else if b == ';' as u16 && !in_quote {
                 self.must_yield = true;
-                break
+                break;
             } else {
                 in_progress.push(b)
             }
@@ -187,17 +191,21 @@ impl<'a> Iterator for SplitPaths<'a> {
 pub struct JoinPathsError;
 
 pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
-    where I: Iterator<Item=T>, T: AsRef<OsStr>
+where
+    I: Iterator<Item = T>,
+    T: AsRef<OsStr>,
 {
     let mut joined = Vec::new();
     let sep = b';' as u16;
 
     for (i, path) in paths.enumerate() {
         let path = path.as_ref();
-        if i > 0 { joined.push(sep) }
+        if i > 0 {
+            joined.push(sep)
+        }
         let v = path.encode_wide().collect::<Vec<u16>>();
         if v.contains(&(b'"' as u16)) {
-            return Err(JoinPathsError)
+            return Err(JoinPathsError);
         } else if v.contains(&sep) {
             joined.push(b'"' as u16);
             joined.extend_from_slice(&v[..]);
@@ -217,19 +225,20 @@ impl fmt::Display for JoinPathsError {
 }
 
 impl StdError for JoinPathsError {
-    fn description(&self) -> &str { "failed to join paths" }
+    fn description(&self) -> &str {
+        "failed to join paths"
+    }
 }
 
 pub fn current_exe() -> io::Result<PathBuf> {
-    super::fill_utf16_buf(|buf, sz| unsafe {
-        c::GetModuleFileNameW(ptr::null_mut(), buf, sz)
-    }, super::os2path)
+    super::fill_utf16_buf(
+        |buf, sz| unsafe { c::GetModuleFileNameW(ptr::null_mut(), buf, sz) },
+        super::os2path,
+    )
 }
 
 pub fn getcwd() -> io::Result<PathBuf> {
-    super::fill_utf16_buf(|buf, sz| unsafe {
-        c::GetCurrentDirectoryW(sz, buf)
-    }, super::os2path)
+    super::fill_utf16_buf(|buf, sz| unsafe { c::GetCurrentDirectoryW(sz, buf) }, super::os2path)
 }
 
 pub fn chdir(p: &path::Path) -> io::Result<()> {
@@ -237,18 +246,15 @@ pub fn chdir(p: &path::Path) -> io::Result<()> {
     let mut p = p.encode_wide().collect::<Vec<_>>();
     p.push(0);
 
-    cvt(unsafe {
-        c::SetCurrentDirectoryW(p.as_ptr())
-    }).map(|_| ())
+    cvt(unsafe { c::SetCurrentDirectoryW(p.as_ptr()) }).map(|_| ())
 }
 
 pub fn getenv(k: &OsStr) -> io::Result<Option<OsString>> {
     let k = to_u16s(k)?;
-    let res = super::fill_utf16_buf(|buf, sz| unsafe {
-        c::GetEnvironmentVariableW(k.as_ptr(), buf, sz)
-    }, |buf| {
-        OsStringExt::from_wide(buf)
-    });
+    let res = super::fill_utf16_buf(
+        |buf, sz| unsafe { c::GetEnvironmentVariableW(k.as_ptr(), buf, sz) },
+        |buf| OsStringExt::from_wide(buf),
+    );
     match res {
         Ok(value) => Ok(Some(value)),
         Err(e) => {
@@ -265,22 +271,16 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
     let k = to_u16s(k)?;
     let v = to_u16s(v)?;
 
-    cvt(unsafe {
-        c::SetEnvironmentVariableW(k.as_ptr(), v.as_ptr())
-    }).map(|_| ())
+    cvt(unsafe { c::SetEnvironmentVariableW(k.as_ptr(), v.as_ptr()) }).map(|_| ())
 }
 
 pub fn unsetenv(n: &OsStr) -> io::Result<()> {
     let v = to_u16s(n)?;
-    cvt(unsafe {
-        c::SetEnvironmentVariableW(v.as_ptr(), ptr::null())
-    }).map(|_| ())
+    cvt(unsafe { c::SetEnvironmentVariableW(v.as_ptr(), ptr::null()) }).map(|_| ())
 }
 
 pub fn temp_dir() -> PathBuf {
-    super::fill_utf16_buf(|buf, sz| unsafe {
-        c::GetTempPathW(sz, buf)
-    }, super::os2path).unwrap()
+    super::fill_utf16_buf(|buf, sz| unsafe { c::GetTempPathW(sz, buf) }, super::os2path).unwrap()
 }
 
 #[cfg(not(target_vendor = "uwp"))]
@@ -291,16 +291,20 @@ fn home_dir_crt() -> Option<PathBuf> {
         let me = c::GetCurrentProcess();
         let mut token = ptr::null_mut();
         if c::OpenProcessToken(me, c::TOKEN_READ, &mut token) == 0 {
-            return None
+            return None;
         }
         let _handle = Handle::new(token);
-        super::fill_utf16_buf(|buf, mut sz| {
-            match c::GetUserProfileDirectoryW(token, buf, &mut sz) {
-                0 if c::GetLastError() != c::ERROR_INSUFFICIENT_BUFFER => 0,
-                0 => sz,
-                _ => sz - 1, // sz includes the null terminator
-            }
-        }, super::os2path).ok()
+        super::fill_utf16_buf(
+            |buf, mut sz| {
+                match c::GetUserProfileDirectoryW(token, buf, &mut sz) {
+                    0 if c::GetLastError() != c::ERROR_INSUFFICIENT_BUFFER => 0,
+                    0 => sz,
+                    _ => sz - 1, // sz includes the null terminator
+                }
+            },
+            super::os2path,
+        )
+        .ok()
     }
 }
 
@@ -310,9 +314,10 @@ fn home_dir_crt() -> Option<PathBuf> {
 }
 
 pub fn home_dir() -> Option<PathBuf> {
-    crate::env::var_os("HOME").or_else(|| {
-        crate::env::var_os("USERPROFILE")
-    }).map(PathBuf::from).or_else(|| home_dir_crt())
+    crate::env::var_os("HOME")
+        .or_else(|| crate::env::var_os("USERPROFILE"))
+        .map(PathBuf::from)
+        .or_else(|| home_dir_crt())
 }
 
 pub fn exit(code: i32) -> ! {
@@ -332,7 +337,10 @@ mod tests {
     #[test]
     fn ntstatus_error() {
         const STATUS_UNSUCCESSFUL: u32 = 0xc000_0001;
-        assert!(!Error::from_raw_os_error((STATUS_UNSUCCESSFUL | c::FACILITY_NT_BIT) as _)
-            .to_string().contains("FormatMessageW() returned error"));
+        assert!(
+            !Error::from_raw_os_error((STATUS_UNSUCCESSFUL | c::FACILITY_NT_BIT) as _)
+                .to_string()
+                .contains("FormatMessageW() returned error")
+        );
     }
 }
diff --git a/src/libstd/sys/windows/os_str.rs b/src/libstd/sys/windows/os_str.rs
index c7a82e09252..e451e0cfb5b 100644
--- a/src/libstd/sys/windows/os_str.rs
+++ b/src/libstd/sys/windows/os_str.rs
@@ -1,17 +1,16 @@
 /// The underlying OsString/OsStr implementation on Windows is a
 /// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
-
 use crate::borrow::Cow;
 use crate::fmt;
-use crate::sys_common::wtf8::{Wtf8, Wtf8Buf};
 use crate::mem;
 use crate::rc::Rc;
 use crate::sync::Arc;
-use crate::sys_common::{AsInner, IntoInner, FromInner};
+use crate::sys_common::wtf8::{Wtf8, Wtf8Buf};
+use crate::sys_common::{AsInner, FromInner, IntoInner};
 
 #[derive(Clone, Hash)]
 pub struct Buf {
-    pub inner: Wtf8Buf
+    pub inner: Wtf8Buf,
 }
 
 impl IntoInner<Wtf8Buf> for Buf {
@@ -45,7 +44,7 @@ impl fmt::Display for Buf {
 }
 
 pub struct Slice {
-    pub inner: Wtf8
+    pub inner: Wtf8,
 }
 
 impl fmt::Debug for Slice {
@@ -62,9 +61,7 @@ impl fmt::Display for Slice {
 
 impl Buf {
     pub fn with_capacity(capacity: usize) -> Buf {
-        Buf {
-            inner: Wtf8Buf::with_capacity(capacity)
-        }
+        Buf { inner: Wtf8Buf::with_capacity(capacity) }
     }
 
     pub fn clear(&mut self) {
diff --git a/src/libstd/sys/windows/path.rs b/src/libstd/sys/windows/path.rs
index 7eae28cb14f..524f21f889b 100644
--- a/src/libstd/sys/windows/path.rs
+++ b/src/libstd/sys/windows/path.rs
@@ -1,6 +1,6 @@
-use crate::path::Prefix;
 use crate::ffi::OsStr;
 use crate::mem;
+use crate::path::Prefix;
 
 fn os_str_as_u8_slice(s: &OsStr) -> &[u8] {
     unsafe { mem::transmute(s) }
@@ -38,8 +38,9 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
                     // \\?\UNC\server\share
                     path = &path[4..];
                     let (server, share) = match parse_two_comps(path, is_verbatim_sep) {
-                        Some((server, share)) =>
-                            (u8_slice_as_os_str(server), u8_slice_as_os_str(share)),
+                        Some((server, share)) => {
+                            (u8_slice_as_os_str(server), u8_slice_as_os_str(share))
+                        }
                         None => (u8_slice_as_os_str(path), u8_slice_as_os_str(&[])),
                     };
                     return Some(VerbatimUNC(server, share));
@@ -70,7 +71,7 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
                 }
                 _ => (),
             }
-        } else if path.get(1) == Some(& b':') {
+        } else if path.get(1) == Some(&b':') {
             // C:
             let c = path[0];
             if c.is_ascii() && (c as char).is_alphabetic() {
diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs
index 041d5385eb6..992e634dea5 100644
--- a/src/libstd/sys/windows/pipe.rs
+++ b/src/libstd/sys/windows/pipe.rs
@@ -6,8 +6,8 @@ use crate::mem;
 use crate::path::Path;
 use crate::ptr;
 use crate::slice;
-use crate::sync::atomic::Ordering::SeqCst;
 use crate::sync::atomic::AtomicUsize;
+use crate::sync::atomic::Ordering::SeqCst;
 use crate::sys::c;
 use crate::sys::fs::{File, OpenOptions};
 use crate::sys::handle::Handle;
@@ -63,32 +63,32 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
         let mut reject_remote_clients_flag = c::PIPE_REJECT_REMOTE_CLIENTS;
         loop {
             tries += 1;
-            name = format!(r"\\.\pipe\__rust_anonymous_pipe1__.{}.{}",
-                           c::GetCurrentProcessId(),
-                           random_number());
-            let wide_name = OsStr::new(&name)
-                                  .encode_wide()
-                                  .chain(Some(0))
-                                  .collect::<Vec<_>>();
-            let mut flags = c::FILE_FLAG_FIRST_PIPE_INSTANCE |
-                c::FILE_FLAG_OVERLAPPED;
+            name = format!(
+                r"\\.\pipe\__rust_anonymous_pipe1__.{}.{}",
+                c::GetCurrentProcessId(),
+                random_number()
+            );
+            let wide_name = OsStr::new(&name).encode_wide().chain(Some(0)).collect::<Vec<_>>();
+            let mut flags = c::FILE_FLAG_FIRST_PIPE_INSTANCE | c::FILE_FLAG_OVERLAPPED;
             if ours_readable {
                 flags |= c::PIPE_ACCESS_INBOUND;
             } else {
                 flags |= c::PIPE_ACCESS_OUTBOUND;
             }
 
-            let handle = c::CreateNamedPipeW(wide_name.as_ptr(),
-                                             flags,
-                                             c::PIPE_TYPE_BYTE |
-                                             c::PIPE_READMODE_BYTE |
-                                             c::PIPE_WAIT |
-                                             reject_remote_clients_flag,
-                                             1,
-                                             4096,
-                                             4096,
-                                             0,
-                                             ptr::null_mut());
+            let handle = c::CreateNamedPipeW(
+                wide_name.as_ptr(),
+                flags,
+                c::PIPE_TYPE_BYTE
+                    | c::PIPE_READMODE_BYTE
+                    | c::PIPE_WAIT
+                    | reject_remote_clients_flag,
+                1,
+                4096,
+                4096,
+                0,
+                ptr::null_mut(),
+            );
 
             // We pass the `FILE_FLAG_FIRST_PIPE_INSTANCE` flag above, and we're
             // also just doing a best effort at selecting a unique name. If
@@ -112,18 +112,19 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
                 let raw_os_err = err.raw_os_error();
                 if tries < 10 {
                     if raw_os_err == Some(c::ERROR_ACCESS_DENIED as i32) {
-                        continue
-                    } else if reject_remote_clients_flag != 0 &&
-                        raw_os_err == Some(c::ERROR_INVALID_PARAMETER as i32) {
+                        continue;
+                    } else if reject_remote_clients_flag != 0
+                        && raw_os_err == Some(c::ERROR_INVALID_PARAMETER as i32)
+                    {
                         reject_remote_clients_flag = 0;
                         tries -= 1;
-                        continue
+                        continue;
                     }
                 }
-                return Err(err)
+                return Err(err);
             }
             ours = Handle::new(handle);
-            break
+            break;
         }
 
         // Connect to the named pipe we just created. This handle is going to be
@@ -158,7 +159,7 @@ fn random_number() -> usize {
     static N: AtomicUsize = AtomicUsize::new(0);
     loop {
         if N.load(SeqCst) != 0 {
-            return N.fetch_add(1, SeqCst)
+            return N.fetch_add(1, SeqCst);
         }
 
         N.store(hashmap_random_keys().0 as usize, SeqCst);
@@ -166,8 +167,12 @@ fn random_number() -> usize {
 }
 
 impl AnonPipe {
-    pub fn handle(&self) -> &Handle { &self.inner }
-    pub fn into_handle(self) -> Handle { self.inner }
+    pub fn handle(&self) -> &Handle {
+        &self.inner
+    }
+    pub fn into_handle(self) -> Handle {
+        self.inner
+    }
 
     pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
         self.inner.read(buf)
@@ -186,10 +191,7 @@ impl AnonPipe {
     }
 }
 
-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<()> {
     let p1 = p1.into_handle();
     let p2 = p2.into_handle();
 
@@ -206,19 +208,17 @@ pub fn read2(p1: AnonPipe,
     // duration of the I/O operation (where tons of operations can also fail).
     // The destructor for `AsyncPipe` ends up taking care of most of this.
     loop {
-        let res = unsafe {
-            c::WaitForMultipleObjects(2, objs.as_ptr(), c::FALSE, c::INFINITE)
-        };
+        let res = unsafe { c::WaitForMultipleObjects(2, objs.as_ptr(), c::FALSE, c::INFINITE) };
         if res == c::WAIT_OBJECT_0 {
             if !p1.result()? || !p1.schedule_read()? {
-                return p2.finish()
+                return p2.finish();
             }
         } else if res == c::WAIT_OBJECT_0 + 1 {
             if !p2.result()? || !p2.schedule_read()? {
-                return p1.finish()
+                return p1.finish();
             }
         } else {
-            return Err(io::Error::last_os_error())
+            return Err(io::Error::last_os_error());
         }
     }
 }
@@ -251,17 +251,9 @@ impl<'a> AsyncPipe<'a> {
         // and the only time an even will go back to "unset" will be once an
         // I/O operation is successfully scheduled (what we want).
         let event = Handle::new_event(true, true)?;
-        let mut overlapped: Box<c::OVERLAPPED> = unsafe {
-            Box::new(mem::zeroed())
-        };
+        let mut overlapped: Box<c::OVERLAPPED> = unsafe { Box::new(mem::zeroed()) };
         overlapped.hEvent = event.raw();
-        Ok(AsyncPipe {
-            pipe,
-            overlapped,
-            event,
-            dst,
-            state: State::NotReading,
-        })
+        Ok(AsyncPipe { pipe, overlapped, event, dst, state: State::NotReading })
     }
 
     /// Executes an overlapped read operation.
@@ -306,9 +298,7 @@ impl<'a> AsyncPipe<'a> {
     fn result(&mut self) -> io::Result<bool> {
         let amt = match self.state {
             State::NotReading => return Ok(true),
-            State::Reading => {
-                self.pipe.overlapped_result(&mut *self.overlapped, true)?
-            }
+            State::Reading => self.pipe.overlapped_result(&mut *self.overlapped, true)?,
             State::Read(amt) => amt,
         };
         self.state = State::NotReading;
@@ -364,6 +354,5 @@ unsafe fn slice_to_end(v: &mut Vec<u8>) -> &mut [u8] {
     if v.capacity() == v.len() {
         v.reserve(1);
     }
-    slice::from_raw_parts_mut(v.as_mut_ptr().add(v.len()),
-                              v.capacity() - v.len())
+    slice::from_raw_parts_mut(v.as_mut_ptr().add(v.len()), v.capacity() - v.len())
 }
diff --git a/src/libstd/sys/windows/rand.rs b/src/libstd/sys/windows/rand.rs
index 993831bec18..87ea416bf67 100644
--- a/src/libstd/sys/windows/rand.rs
+++ b/src/libstd/sys/windows/rand.rs
@@ -5,13 +5,10 @@ use crate::sys::c;
 #[cfg(not(target_vendor = "uwp"))]
 pub fn hashmap_random_keys() -> (u64, u64) {
     let mut v = (0, 0);
-    let ret = unsafe {
-        c::RtlGenRandom(&mut v as *mut _ as *mut u8,
-                        mem::size_of_val(&v) as c::ULONG)
-    };
+    let ret =
+        unsafe { c::RtlGenRandom(&mut v as *mut _ as *mut u8, mem::size_of_val(&v) as c::ULONG) };
     if ret == 0 {
-        panic!("couldn't generate random bytes: {}",
-               io::Error::last_os_error());
+        panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
     }
     v
 }
@@ -22,13 +19,15 @@ pub fn hashmap_random_keys() -> (u64, u64) {
 
     let mut v = (0, 0);
     let ret = unsafe {
-        c::BCryptGenRandom(ptr::null_mut(), &mut v as *mut _ as *mut u8,
-                           mem::size_of_val(&v) as c::ULONG,
-                           c::BCRYPT_USE_SYSTEM_PREFERRED_RNG)
+        c::BCryptGenRandom(
+            ptr::null_mut(),
+            &mut v as *mut _ as *mut u8,
+            mem::size_of_val(&v) as c::ULONG,
+            c::BCRYPT_USE_SYSTEM_PREFERRED_RNG,
+        )
     };
     if ret != 0 {
-        panic!("couldn't generate random bytes: {}",
-               io::Error::last_os_error());
+        panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
     }
-    return v
+    return v;
 }
diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs
index d5b7765f9ff..187ad4e66c3 100644
--- a/src/libstd/sys/windows/stack_overflow.rs
+++ b/src/libstd/sys/windows/stack_overflow.rs
@@ -1,7 +1,7 @@
 #![cfg_attr(test, allow(dead_code))]
 
-use crate::sys_common::util::report_overflow;
 use crate::sys::c;
+use crate::sys_common::util::report_overflow;
 
 pub struct Handler;
 
@@ -18,8 +18,7 @@ impl Handler {
     }
 }
 
-extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS)
-                                    -> c::LONG {
+extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS) -> c::LONG {
     unsafe {
         let rec = &(*(*ExceptionInfo).ExceptionRecord);
         let code = rec.ExceptionCode;
diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs
index b1e76b3b755..f322c2b1d96 100644
--- a/src/libstd/sys/windows/stdio.rs
+++ b/src/libstd/sys/windows/stdio.rs
@@ -68,9 +68,11 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
     let utf8 = match str::from_utf8(&data[..len]) {
         Ok(s) => s,
         Err(ref e) if e.valid_up_to() == 0 => {
-            return Err(io::Error::new(io::ErrorKind::InvalidData,
-                "Windows stdio in console mode does not support writing non-UTF-8 byte sequences"))
-        },
+            return Err(io::Error::new(
+                io::ErrorKind::InvalidData,
+                "Windows stdio in console mode does not support writing non-UTF-8 byte sequences",
+            ));
+        }
         Err(e) => str::from_utf8(&data[..e.valid_up_to()]).unwrap(),
     };
     let mut utf16 = [0u16; MAX_BUFFER_SIZE / 2];
@@ -93,18 +95,19 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
         // write the missing surrogate out now.
         // Buffering it would mean we have to lie about the number of bytes written.
         let first_char_remaining = utf16[written];
-        if first_char_remaining >= 0xDCEE && first_char_remaining <= 0xDFFF { // low surrogate
+        if first_char_remaining >= 0xDCEE && first_char_remaining <= 0xDFFF {
+            // low surrogate
             // We just hope this works, and give up otherwise
-            let _ = write_u16s(handle, &utf16[written..written+1]);
+            let _ = write_u16s(handle, &utf16[written..written + 1]);
             written += 1;
         }
         // Calculate the number of bytes of `utf8` that were actually written.
         let mut count = 0;
         for ch in utf16[..written].iter() {
             count += match ch {
-                0x0000 ..= 0x007F => 1,
-                0x0080 ..= 0x07FF => 2,
-                0xDCEE ..= 0xDFFF => 1, // Low surrogate. We already counted 3 bytes for the other.
+                0x0000..=0x007F => 1,
+                0x0080..=0x07FF => 2,
+                0xDCEE..=0xDFFF => 1, // Low surrogate. We already counted 3 bytes for the other.
                 _ => 3,
             };
         }
@@ -116,11 +119,13 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
 fn write_u16s(handle: c::HANDLE, data: &[u16]) -> io::Result<usize> {
     let mut written = 0;
     cvt(unsafe {
-        c::WriteConsoleW(handle,
-                         data.as_ptr() as c::LPCVOID,
-                         data.len() as u32,
-                         &mut written,
-                         ptr::null_mut())
+        c::WriteConsoleW(
+            handle,
+            data.as_ptr() as c::LPCVOID,
+            data.len() as u32,
+            &mut written,
+            ptr::null_mut(),
+        )
     })?;
     Ok(written as usize)
 }
@@ -144,9 +149,11 @@ impl io::Read for Stdin {
         if buf.len() == 0 {
             return Ok(0);
         } else if buf.len() < 4 {
-            return Err(io::Error::new(io::ErrorKind::InvalidInput,
-                        "Windows stdin in console mode does not support a buffer too small to \
-                        guarantee holding one arbitrary UTF-8 character (4 bytes)"))
+            return Err(io::Error::new(
+                io::ErrorKind::InvalidInput,
+                "Windows stdin in console mode does not support a buffer too small to \
+                 guarantee holding one arbitrary UTF-8 character (4 bytes)",
+            ));
         }
 
         let mut utf16_buf = [0u16; MAX_BUFFER_SIZE / 2];
@@ -160,15 +167,15 @@ impl io::Read for Stdin {
     }
 }
 
-
 // We assume that if the last `u16` is an unpaired surrogate they got sliced apart by our
 // buffer size, and keep it around for the next read hoping to put them together.
 // This is a best effort, and may not work if we are not the only reader on Stdin.
-fn read_u16s_fixup_surrogates(handle: c::HANDLE,
-                              buf: &mut [u16],
-                              mut amount: usize,
-                              surrogate: &mut u16) -> io::Result<usize>
-{
+fn read_u16s_fixup_surrogates(
+    handle: c::HANDLE,
+    buf: &mut [u16],
+    mut amount: usize,
+    surrogate: &mut u16,
+) -> io::Result<usize> {
     // Insert possibly remaining unpaired surrogate from last read.
     let mut start = 0;
     if *surrogate != 0 {
@@ -186,7 +193,8 @@ fn read_u16s_fixup_surrogates(handle: c::HANDLE,
 
     if amount > 0 {
         let last_char = buf[amount - 1];
-        if last_char >= 0xD800 && last_char <= 0xDBFF { // high surrogate
+        if last_char >= 0xD800 && last_char <= 0xDBFF {
+            // high surrogate
             *surrogate = last_char;
             amount -= 1;
         }
@@ -209,11 +217,13 @@ fn read_u16s(handle: c::HANDLE, buf: &mut [u16]) -> io::Result<usize> {
 
     let mut amount = 0;
     cvt(unsafe {
-        c::ReadConsoleW(handle,
-                        buf.as_mut_ptr() as c::LPVOID,
-                        buf.len() as u32,
-                        &mut amount,
-                        &mut input_control as c::PCONSOLE_READCONSOLE_CONTROL)
+        c::ReadConsoleW(
+            handle,
+            buf.as_mut_ptr() as c::LPVOID,
+            buf.len() as u32,
+            &mut amount,
+            &mut input_control as c::PCONSOLE_READCONSOLE_CONTROL,
+        )
     })?;
 
     if amount > 0 && buf[amount as usize - 1] == CTRL_Z {
@@ -233,9 +243,11 @@ fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result<usize> {
             }
             Err(_) => {
                 // We can't really do any better than forget all data and return an error.
-                return Err(io::Error::new(io::ErrorKind::InvalidData,
+                return Err(io::Error::new(
+                    io::ErrorKind::InvalidData,
                     "Windows stdin in console mode does not support non-UTF-16 input; \
-                    encountered unpaired surrogate"))
+                     encountered unpaired surrogate",
+                ));
             }
         }
     }
diff --git a/src/libstd/sys/windows/stdio_uwp.rs b/src/libstd/sys/windows/stdio_uwp.rs
index 489d3df2860..0f2178f7353 100644
--- a/src/libstd/sys/windows/stdio_uwp.rs
+++ b/src/libstd/sys/windows/stdio_uwp.rs
@@ -1,12 +1,11 @@
 #![unstable(issue = "0", feature = "windows_stdio")]
 
 use crate::io;
+use crate::mem::ManuallyDrop;
 use crate::sys::c;
 use crate::sys::handle::Handle;
-use crate::mem::ManuallyDrop;
 
-pub struct Stdin {
-}
+pub struct Stdin {}
 pub struct Stdout;
 pub struct Stderr;
 
@@ -32,7 +31,7 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
 
 impl Stdin {
     pub fn new() -> io::Result<Stdin> {
-        Ok(Stdin { })
+        Ok(Stdin {})
     }
 }
 
diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs
index ebdf3612e06..c828243a59b 100644
--- a/src/libstd/sys/windows/thread.rs
+++ b/src/libstd/sys/windows/thread.rs
@@ -1,5 +1,5 @@
-use crate::io;
 use crate::ffi::CStr;
+use crate::io;
 use crate::mem;
 use crate::ptr;
 use crate::sys::c;
@@ -14,13 +14,12 @@ use super::to_u16s;
 pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
 
 pub struct Thread {
-    handle: Handle
+    handle: Handle,
 }
 
 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;
 
         // FIXME On UNIX, we guard against stack sizes that are too small but
@@ -31,10 +30,14 @@ impl Thread {
         // Round up to the next 64 kB because that's what the NT kernel does,
         // might as well make it explicit.
         let stack_size = (stack + 0xfffe) & (!0xfffe);
-        let ret = c::CreateThread(ptr::null_mut(), stack_size,
-                                  thread_start, &*p as *const _ as *mut _,
-                                  c::STACK_SIZE_PARAM_IS_A_RESERVATION,
-                                  ptr::null_mut());
+        let ret = c::CreateThread(
+            ptr::null_mut(),
+            stack_size,
+            thread_start,
+            &*p as *const _ as *mut _,
+            c::STACK_SIZE_PARAM_IS_A_RESERVATION,
+            ptr::null_mut(),
+        );
 
         return if ret as usize == 0 {
             Err(io::Error::last_os_error())
@@ -44,7 +47,9 @@ impl Thread {
         };
 
         extern "system" fn thread_start(main: *mut c_void) -> c::DWORD {
-            unsafe { start_thread(main as *mut u8); }
+            unsafe {
+                start_thread(main as *mut u8);
+            }
             0
         }
     }
@@ -52,7 +57,9 @@ impl Thread {
     pub fn set_name(name: &CStr) {
         if let Ok(utf8) = name.to_str() {
             if let Ok(utf16) = to_u16s(utf8) {
-                unsafe { c::SetThreadDescription(c::GetCurrentThread(), utf16.as_ptr()); };
+                unsafe {
+                    c::SetThreadDescription(c::GetCurrentThread(), utf16.as_ptr());
+                };
             };
         };
     }
@@ -60,8 +67,7 @@ impl Thread {
     pub fn join(self) {
         let rc = unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE) };
         if rc == c::WAIT_FAILED {
-            panic!("failed to join on thread: {}",
-                   io::Error::last_os_error());
+            panic!("failed to join on thread: {}", io::Error::last_os_error());
         }
     }
 
@@ -69,23 +75,31 @@ impl Thread {
         // This function will return 0 if there are no other threads to execute,
         // but this also means that the yield was useless so this isn't really a
         // case that needs to be worried about.
-        unsafe { c::SwitchToThread(); }
+        unsafe {
+            c::SwitchToThread();
+        }
     }
 
     pub fn sleep(dur: Duration) {
-        unsafe {
-            c::Sleep(super::dur2timeout(dur))
-        }
+        unsafe { c::Sleep(super::dur2timeout(dur)) }
     }
 
-    pub fn handle(&self) -> &Handle { &self.handle }
+    pub fn handle(&self) -> &Handle {
+        &self.handle
+    }
 
-    pub fn into_handle(self) -> Handle { self.handle }
+    pub fn into_handle(self) -> Handle {
+        self.handle
+    }
 }
 
 #[cfg_attr(test, allow(dead_code))]
 pub mod guard {
     pub type Guard = !;
-    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
+    }
 }
diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs
index 728257cdd4b..e0bb102b3af 100644
--- a/src/libstd/sys/windows/thread_local.rs
+++ b/src/libstd/sys/windows/thread_local.rs
@@ -5,7 +5,7 @@ use crate::sync::atomic::Ordering::SeqCst;
 use crate::sys::c;
 
 pub type Key = c::DWORD;
-pub type Dtor = unsafe extern fn(*mut u8);
+pub type Dtor = unsafe extern "C" fn(*mut u8);
 
 // Turns out, like pretty much everything, Windows is pretty close the
 // functionality that Unix provides, but slightly different! In the case of
@@ -111,11 +111,7 @@ struct Node {
 }
 
 unsafe fn register_dtor(key: Key, dtor: Dtor) {
-    let mut node = Box::new(Node {
-        key,
-        dtor,
-        next: ptr::null_mut(),
-    });
+    let mut node = Box::new(Node { key, dtor, next: ptr::null_mut() });
 
     let mut head = DTORS.load(SeqCst);
     loop {
@@ -192,15 +188,12 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) {
 #[link_section = ".CRT$XLB"]
 #[allow(dead_code, unused_variables)]
 #[used] // we don't want LLVM eliminating this symbol for any reason, and
-        // when the symbol makes it to the linker the linker will take over
-pub static p_thread_callback: unsafe extern "system" fn(c::LPVOID, c::DWORD,
-                                                        c::LPVOID) =
-        on_tls_callback;
+// when the symbol makes it to the linker the linker will take over
+pub static p_thread_callback: unsafe extern "system" fn(c::LPVOID, c::DWORD, c::LPVOID) =
+    on_tls_callback;
 
 #[allow(dead_code, unused_variables)]
-unsafe extern "system" fn on_tls_callback(h: c::LPVOID,
-                                          dwReason: c::DWORD,
-                                          pv: c::LPVOID) {
+unsafe extern "system" fn on_tls_callback(h: c::LPVOID, dwReason: c::DWORD, pv: c::LPVOID) {
     if dwReason == c::DLL_THREAD_DETACH || dwReason == c::DLL_PROCESS_DETACH {
         run_dtors();
     }
@@ -210,7 +203,9 @@ unsafe extern "system" fn on_tls_callback(h: c::LPVOID,
     reference_tls_used();
     #[cfg(target_env = "msvc")]
     unsafe fn reference_tls_used() {
-        extern { static _tls_used: u8; }
+        extern "C" {
+            static _tls_used: u8;
+        }
         crate::intrinsics::volatile_load(&_tls_used);
     }
     #[cfg(not(target_env = "msvc"))]
@@ -222,7 +217,7 @@ unsafe fn run_dtors() {
     let mut any_run = true;
     for _ in 0..5 {
         if !any_run {
-            break
+            break;
         }
         any_run = false;
         let mut cur = DTORS.load(SeqCst);