about summary refs log tree commit diff
path: root/src/libstd/sys/windows
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:04 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:47 -0500
commita06baa56b95674fc626b3c3fd680d6a65357fe60 (patch)
treecd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libstd/sys/windows
parent8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff)
downloadrust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz
rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip
Format the world
Diffstat (limited to 'src/libstd/sys/windows')
-rw-r--r--src/libstd/sys/windows/c.rs537
-rw-r--r--src/libstd/sys/windows/condvar.rs19
-rw-r--r--src/libstd/sys/windows/mod.rs102
-rw-r--r--src/libstd/sys/windows/mutex.rs24
-rw-r--r--src/libstd/sys/windows/net.rs205
-rw-r--r--src/libstd/sys/windows/process.rs159
-rw-r--r--src/libstd/sys/windows/rwlock.rs4
-rw-r--r--src/libstd/sys/windows/time.rs42
8 files changed, 548 insertions, 544 deletions
diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs
index 4cdac89a864..4d377341be3 100644
--- a/src/libstd/sys/windows/c.rs
+++ b/src/libstd/sys/windows/c.rs
@@ -4,13 +4,13 @@
 #![cfg_attr(test, allow(dead_code))]
 #![unstable(issue = "none", feature = "windows_c")]
 
-use crate::os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort, c_char};
+use crate::os::raw::{c_char, c_int, c_long, c_longlong, c_uint, c_ulong, c_ushort};
 use crate::ptr;
 
-use libc::{wchar_t, size_t, c_void};
+use libc::{c_void, size_t, wchar_t};
 
-pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
 pub use self::EXCEPTION_DISPOSITION::*;
+pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
 
 pub type DWORD = c_ulong;
 pub type HANDLE = LPVOID;
@@ -88,11 +88,12 @@ pub const SYNCHRONIZE: DWORD = 0x00100000;
 pub const GENERIC_READ: DWORD = 0x80000000;
 pub const GENERIC_WRITE: DWORD = 0x40000000;
 pub const STANDARD_RIGHTS_WRITE: DWORD = READ_CONTROL;
-pub const FILE_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |
-                                      FILE_WRITE_ATTRIBUTES |
-                                      FILE_WRITE_EA |
-                                      FILE_APPEND_DATA |
-                                      SYNCHRONIZE;
+pub const FILE_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE
+    | FILE_WRITE_DATA
+    | FILE_WRITE_ATTRIBUTES
+    | FILE_WRITE_EA
+    | FILE_APPEND_DATA
+    | SYNCHRONIZE;
 
 pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
 pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
@@ -115,7 +116,9 @@ pub struct WIN32_FIND_DATAW {
     pub cAlternateFileName: [wchar_t; 14],
 }
 impl Clone for WIN32_FIND_DATAW {
-    fn clone(&self) -> Self { *self }
+    fn clone(&self) -> Self {
+        *self
+    }
 }
 
 pub const WSA_FLAG_OVERLAPPED: DWORD = 0x01;
@@ -195,9 +198,7 @@ pub const INFINITE: DWORD = !0;
 
 pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002;
 
-pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE {
-    ptr: ptr::null_mut(),
-};
+pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE { ptr: ptr::null_mut() };
 pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { ptr: ptr::null_mut() };
 
 pub const DETACHED_PROCESS: DWORD = 0x00000008;
@@ -338,28 +339,28 @@ pub struct WIN32_FILE_ATTRIBUTE_DATA {
 #[repr(C)]
 #[allow(dead_code)] // we only use some variants
 pub enum FILE_INFO_BY_HANDLE_CLASS {
-    FileBasicInfo                   = 0,
-    FileStandardInfo                = 1,
-    FileNameInfo                    = 2,
-    FileRenameInfo                  = 3,
-    FileDispositionInfo             = 4,
-    FileAllocationInfo              = 5,
-    FileEndOfFileInfo               = 6,
-    FileStreamInfo                  = 7,
-    FileCompressionInfo             = 8,
-    FileAttributeTagInfo            = 9,
-    FileIdBothDirectoryInfo         = 10, // 0xA
-    FileIdBothDirectoryRestartInfo  = 11, // 0xB
-    FileIoPriorityHintInfo          = 12, // 0xC
-    FileRemoteProtocolInfo          = 13, // 0xD
-    FileFullDirectoryInfo           = 14, // 0xE
-    FileFullDirectoryRestartInfo    = 15, // 0xF
-    FileStorageInfo                 = 16, // 0x10
-    FileAlignmentInfo               = 17, // 0x11
-    FileIdInfo                      = 18, // 0x12
-    FileIdExtdDirectoryInfo         = 19, // 0x13
-    FileIdExtdDirectoryRestartInfo  = 20, // 0x14
-    MaximumFileInfoByHandlesClass
+    FileBasicInfo = 0,
+    FileStandardInfo = 1,
+    FileNameInfo = 2,
+    FileRenameInfo = 3,
+    FileDispositionInfo = 4,
+    FileAllocationInfo = 5,
+    FileEndOfFileInfo = 6,
+    FileStreamInfo = 7,
+    FileCompressionInfo = 8,
+    FileAttributeTagInfo = 9,
+    FileIdBothDirectoryInfo = 10,        // 0xA
+    FileIdBothDirectoryRestartInfo = 11, // 0xB
+    FileIoPriorityHintInfo = 12,         // 0xC
+    FileRemoteProtocolInfo = 13,         // 0xD
+    FileFullDirectoryInfo = 14,          // 0xE
+    FileFullDirectoryRestartInfo = 15,   // 0xF
+    FileStorageInfo = 16,                // 0x10
+    FileAlignmentInfo = 17,              // 0x11
+    FileIdInfo = 18,                     // 0x12
+    FileIdExtdDirectoryInfo = 19,        // 0x13
+    FileIdExtdDirectoryRestartInfo = 20, // 0x14
+    MaximumFileInfoByHandlesClass,
 }
 
 #[repr(C)]
@@ -403,22 +404,28 @@ pub struct MOUNT_POINT_REPARSE_BUFFER {
     pub PathBuffer: WCHAR,
 }
 
-pub type LPPROGRESS_ROUTINE = crate::option::Option<unsafe extern "system" fn(
-    TotalFileSize: LARGE_INTEGER,
-    TotalBytesTransferred: LARGE_INTEGER,
-    StreamSize: LARGE_INTEGER,
-    StreamBytesTransferred: LARGE_INTEGER,
-    dwStreamNumber: DWORD,
-    dwCallbackReason: DWORD,
-    hSourceFile: HANDLE,
-    hDestinationFile: HANDLE,
-    lpData: LPVOID,
-) -> DWORD>;
+pub type LPPROGRESS_ROUTINE = crate::option::Option<
+    unsafe extern "system" fn(
+        TotalFileSize: LARGE_INTEGER,
+        TotalBytesTransferred: LARGE_INTEGER,
+        StreamSize: LARGE_INTEGER,
+        StreamBytesTransferred: LARGE_INTEGER,
+        dwStreamNumber: DWORD,
+        dwCallbackReason: DWORD,
+        hSourceFile: HANDLE,
+        hDestinationFile: HANDLE,
+        lpData: LPVOID,
+    ) -> DWORD,
+>;
 
 #[repr(C)]
-pub struct CONDITION_VARIABLE { pub ptr: LPVOID }
+pub struct CONDITION_VARIABLE {
+    pub ptr: LPVOID,
+}
 #[repr(C)]
-pub struct SRWLOCK { pub ptr: LPVOID }
+pub struct SRWLOCK {
+    pub ptr: LPVOID,
+}
 #[repr(C)]
 pub struct CRITICAL_SECTION {
     CriticalSectionDebug: LPVOID,
@@ -426,7 +433,7 @@ pub struct CRITICAL_SECTION {
     RecursionCount: LONG,
     OwningThread: HANDLE,
     LockSemaphore: HANDLE,
-    SpinCount: ULONG_PTR
+    SpinCount: ULONG_PTR,
 }
 
 #[repr(C)]
@@ -580,7 +587,7 @@ pub enum EXCEPTION_DISPOSITION {
     ExceptionContinueExecution,
     ExceptionContinueSearch,
     ExceptionNestedException,
-    ExceptionCollidedUnwind
+    ExceptionCollidedUnwind,
 }
 
 #[repr(C)]
@@ -732,37 +739,41 @@ if #[cfg(target_vendor = "uwp")] {
 
 // Shared between Desktop & UWP
 extern "system" {
-    pub fn WSAStartup(wVersionRequested: WORD,
-                      lpWSAData: LPWSADATA) -> c_int;
+    pub fn WSAStartup(wVersionRequested: WORD, lpWSAData: LPWSADATA) -> c_int;
     pub fn WSACleanup() -> c_int;
     pub fn WSAGetLastError() -> c_int;
-    pub fn WSADuplicateSocketW(s: SOCKET,
-                               dwProcessId: DWORD,
-                               lpProtocolInfo: LPWSAPROTOCOL_INFO)
-                               -> c_int;
-    pub fn WSASend(s: SOCKET,
-                   lpBuffers: LPWSABUF,
-                   dwBufferCount: DWORD,
-                   lpNumberOfBytesSent: LPDWORD,
-                   dwFlags: DWORD,
-                   lpOverlapped: LPWSAOVERLAPPED,
-                   lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE)
-                   -> c_int;
-    pub fn WSARecv(s: SOCKET,
-                   lpBuffers: LPWSABUF,
-                   dwBufferCount: DWORD,
-                   lpNumberOfBytesRecvd: LPDWORD,
-                   lpFlags: LPDWORD,
-                   lpOverlapped: LPWSAOVERLAPPED,
-                   lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE)
-                   -> c_int;
+    pub fn WSADuplicateSocketW(
+        s: SOCKET,
+        dwProcessId: DWORD,
+        lpProtocolInfo: LPWSAPROTOCOL_INFO,
+    ) -> c_int;
+    pub fn WSASend(
+        s: SOCKET,
+        lpBuffers: LPWSABUF,
+        dwBufferCount: DWORD,
+        lpNumberOfBytesSent: LPDWORD,
+        dwFlags: DWORD,
+        lpOverlapped: LPWSAOVERLAPPED,
+        lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
+    ) -> c_int;
+    pub fn WSARecv(
+        s: SOCKET,
+        lpBuffers: LPWSABUF,
+        dwBufferCount: DWORD,
+        lpNumberOfBytesRecvd: LPDWORD,
+        lpFlags: LPDWORD,
+        lpOverlapped: LPWSAOVERLAPPED,
+        lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
+    ) -> c_int;
     pub fn GetCurrentProcessId() -> DWORD;
-    pub fn WSASocketW(af: c_int,
-                      kind: c_int,
-                      protocol: c_int,
-                      lpProtocolInfo: LPWSAPROTOCOL_INFO,
-                      g: GROUP,
-                      dwFlags: DWORD) -> SOCKET;
+    pub fn WSASocketW(
+        af: c_int,
+        kind: c_int,
+        protocol: c_int,
+        lpProtocolInfo: LPWSAPROTOCOL_INFO,
+        g: GROUP,
+        dwFlags: DWORD,
+    ) -> SOCKET;
     pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int;
     pub fn InitializeCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
     pub fn EnterCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
@@ -771,227 +782,231 @@ extern "system" {
     pub fn DeleteCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
 
     pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
-    pub fn SetFileAttributesW(lpFileName: LPCWSTR,
-                              dwFileAttributes: DWORD) -> BOOL;
+    pub fn SetFileAttributesW(lpFileName: LPCWSTR, dwFileAttributes: DWORD) -> BOOL;
     pub fn SetLastError(dwErrCode: DWORD);
     pub fn GetCommandLineW() -> *mut LPCWSTR;
-    pub fn GetTempPathW(nBufferLength: DWORD,
-                        lpBuffer: LPCWSTR) -> DWORD;
+    pub fn GetTempPathW(nBufferLength: DWORD, lpBuffer: LPCWSTR) -> DWORD;
     pub fn GetCurrentProcess() -> HANDLE;
     pub fn GetCurrentThread() -> HANDLE;
     pub fn GetStdHandle(which: DWORD) -> HANDLE;
     pub fn ExitProcess(uExitCode: c_uint) -> !;
-    pub fn DeviceIoControl(hDevice: HANDLE,
-                           dwIoControlCode: DWORD,
-                           lpInBuffer: LPVOID,
-                           nInBufferSize: DWORD,
-                           lpOutBuffer: LPVOID,
-                           nOutBufferSize: DWORD,
-                           lpBytesReturned: LPDWORD,
-                           lpOverlapped: LPOVERLAPPED) -> BOOL;
-    pub fn CreateThread(lpThreadAttributes: LPSECURITY_ATTRIBUTES,
-                        dwStackSize: SIZE_T,
-                        lpStartAddress: extern "system" fn(*mut c_void)
-                                                           -> DWORD,
-                        lpParameter: LPVOID,
-                        dwCreationFlags: DWORD,
-                        lpThreadId: LPDWORD) -> HANDLE;
-    pub fn WaitForSingleObject(hHandle: HANDLE,
-                               dwMilliseconds: DWORD) -> DWORD;
+    pub fn DeviceIoControl(
+        hDevice: HANDLE,
+        dwIoControlCode: DWORD,
+        lpInBuffer: LPVOID,
+        nInBufferSize: DWORD,
+        lpOutBuffer: LPVOID,
+        nOutBufferSize: DWORD,
+        lpBytesReturned: LPDWORD,
+        lpOverlapped: LPOVERLAPPED,
+    ) -> BOOL;
+    pub fn CreateThread(
+        lpThreadAttributes: LPSECURITY_ATTRIBUTES,
+        dwStackSize: SIZE_T,
+        lpStartAddress: extern "system" fn(*mut c_void) -> DWORD,
+        lpParameter: LPVOID,
+        dwCreationFlags: DWORD,
+        lpThreadId: LPDWORD,
+    ) -> HANDLE;
+    pub fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD;
     pub fn SwitchToThread() -> BOOL;
     pub fn Sleep(dwMilliseconds: DWORD);
     pub fn GetProcessId(handle: HANDLE) -> DWORD;
-    pub fn CopyFileExW(lpExistingFileName: LPCWSTR,
-                       lpNewFileName: LPCWSTR,
-                       lpProgressRoutine: LPPROGRESS_ROUTINE,
-                       lpData: LPVOID,
-                       pbCancel: LPBOOL,
-                       dwCopyFlags: DWORD) -> BOOL;
-    pub fn FormatMessageW(flags: DWORD,
-                          lpSrc: LPVOID,
-                          msgId: DWORD,
-                          langId: DWORD,
-                          buf: LPWSTR,
-                          nsize: DWORD,
-                          args: *const c_void)
-                          -> DWORD;
+    pub fn CopyFileExW(
+        lpExistingFileName: LPCWSTR,
+        lpNewFileName: LPCWSTR,
+        lpProgressRoutine: LPPROGRESS_ROUTINE,
+        lpData: LPVOID,
+        pbCancel: LPBOOL,
+        dwCopyFlags: DWORD,
+    ) -> BOOL;
+    pub fn FormatMessageW(
+        flags: DWORD,
+        lpSrc: LPVOID,
+        msgId: DWORD,
+        langId: DWORD,
+        buf: LPWSTR,
+        nsize: DWORD,
+        args: *const c_void,
+    ) -> DWORD;
     pub fn TlsAlloc() -> DWORD;
     pub fn TlsGetValue(dwTlsIndex: DWORD) -> LPVOID;
     pub fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;
     pub fn GetLastError() -> DWORD;
     pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL;
-    pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER)
-                                   -> BOOL;
+    pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL;
     pub fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL;
     pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL;
-    pub fn CreateProcessW(lpApplicationName: LPCWSTR,
-                          lpCommandLine: LPWSTR,
-                          lpProcessAttributes: LPSECURITY_ATTRIBUTES,
-                          lpThreadAttributes: LPSECURITY_ATTRIBUTES,
-                          bInheritHandles: BOOL,
-                          dwCreationFlags: DWORD,
-                          lpEnvironment: LPVOID,
-                          lpCurrentDirectory: LPCWSTR,
-                          lpStartupInfo: LPSTARTUPINFO,
-                          lpProcessInformation: LPPROCESS_INFORMATION)
-                          -> BOOL;
+    pub fn CreateProcessW(
+        lpApplicationName: LPCWSTR,
+        lpCommandLine: LPWSTR,
+        lpProcessAttributes: LPSECURITY_ATTRIBUTES,
+        lpThreadAttributes: LPSECURITY_ATTRIBUTES,
+        bInheritHandles: BOOL,
+        dwCreationFlags: DWORD,
+        lpEnvironment: LPVOID,
+        lpCurrentDirectory: LPCWSTR,
+        lpStartupInfo: LPSTARTUPINFO,
+        lpProcessInformation: LPPROCESS_INFORMATION,
+    ) -> BOOL;
     pub fn GetEnvironmentVariableW(n: LPCWSTR, v: LPWSTR, nsize: DWORD) -> DWORD;
     pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) -> BOOL;
     pub fn GetEnvironmentStringsW() -> LPWCH;
     pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
-    pub fn GetModuleFileNameW(hModule: HMODULE,
-                              lpFilename: LPWSTR,
-                              nSize: DWORD)
-                              -> DWORD;
-    pub fn CreateDirectoryW(lpPathName: LPCWSTR,
-                            lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
-                            -> BOOL;
+    pub fn GetModuleFileNameW(hModule: HMODULE, lpFilename: LPWSTR, nSize: DWORD) -> DWORD;
+    pub fn CreateDirectoryW(
+        lpPathName: LPCWSTR,
+        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
+    ) -> BOOL;
     pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
     pub fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD;
     pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
-    pub fn WideCharToMultiByte(CodePage: UINT,
-                               dwFlags: DWORD,
-                               lpWideCharStr: LPCWSTR,
-                               cchWideChar: c_int,
-                               lpMultiByteStr: LPSTR,
-                               cbMultiByte: c_int,
-                               lpDefaultChar: LPCSTR,
-                               lpUsedDefaultChar: LPBOOL) -> c_int;
+    pub fn WideCharToMultiByte(
+        CodePage: UINT,
+        dwFlags: DWORD,
+        lpWideCharStr: LPCWSTR,
+        cchWideChar: c_int,
+        lpMultiByteStr: LPSTR,
+        cbMultiByte: c_int,
+        lpDefaultChar: LPCSTR,
+        lpUsedDefaultChar: LPBOOL,
+    ) -> c_int;
 
     pub fn closesocket(socket: SOCKET) -> c_int;
-    pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int,
-                flags: c_int) -> c_int;
-    pub fn send(socket: SOCKET, buf: *const c_void, len: c_int,
-                flags: c_int) -> c_int;
-    pub fn recvfrom(socket: SOCKET,
-                    buf: *mut c_void,
-                    len: c_int,
-                    flags: c_int,
-                    addr: *mut SOCKADDR,
-                    addrlen: *mut c_int)
-                    -> c_int;
-    pub fn sendto(socket: SOCKET,
-                  buf: *const c_void,
-                  len: c_int,
-                  flags: c_int,
-                  addr: *const SOCKADDR,
-                  addrlen: c_int)
-                  -> c_int;
+    pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, flags: c_int) -> c_int;
+    pub fn send(socket: SOCKET, buf: *const c_void, len: c_int, flags: c_int) -> c_int;
+    pub fn recvfrom(
+        socket: SOCKET,
+        buf: *mut c_void,
+        len: c_int,
+        flags: c_int,
+        addr: *mut SOCKADDR,
+        addrlen: *mut c_int,
+    ) -> c_int;
+    pub fn sendto(
+        socket: SOCKET,
+        buf: *const c_void,
+        len: c_int,
+        flags: c_int,
+        addr: *const SOCKADDR,
+        addrlen: c_int,
+    ) -> c_int;
     pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
-    pub fn accept(socket: SOCKET,
-                  address: *mut SOCKADDR,
-                  address_len: *mut c_int)
-                  -> SOCKET;
-    pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
-                           hSourceHandle: HANDLE,
-                           hTargetProcessHandle: HANDLE,
-                           lpTargetHandle: LPHANDLE,
-                           dwDesiredAccess: DWORD,
-                           bInheritHandle: BOOL,
-                           dwOptions: DWORD)
-                           -> BOOL;
-    pub fn ReadFile(hFile: HANDLE,
-                    lpBuffer: LPVOID,
-                    nNumberOfBytesToRead: DWORD,
-                    lpNumberOfBytesRead: LPDWORD,
-                    lpOverlapped: LPOVERLAPPED)
-                    -> BOOL;
-    pub fn WriteFile(hFile: HANDLE,
-                     lpBuffer: LPVOID,
-                     nNumberOfBytesToWrite: DWORD,
-                     lpNumberOfBytesWritten: LPDWORD,
-                     lpOverlapped: LPOVERLAPPED)
-                     -> BOOL;
+    pub fn accept(socket: SOCKET, address: *mut SOCKADDR, address_len: *mut c_int) -> SOCKET;
+    pub fn DuplicateHandle(
+        hSourceProcessHandle: HANDLE,
+        hSourceHandle: HANDLE,
+        hTargetProcessHandle: HANDLE,
+        lpTargetHandle: LPHANDLE,
+        dwDesiredAccess: DWORD,
+        bInheritHandle: BOOL,
+        dwOptions: DWORD,
+    ) -> BOOL;
+    pub fn ReadFile(
+        hFile: HANDLE,
+        lpBuffer: LPVOID,
+        nNumberOfBytesToRead: DWORD,
+        lpNumberOfBytesRead: LPDWORD,
+        lpOverlapped: LPOVERLAPPED,
+    ) -> BOOL;
+    pub fn WriteFile(
+        hFile: HANDLE,
+        lpBuffer: LPVOID,
+        nNumberOfBytesToWrite: DWORD,
+        lpNumberOfBytesWritten: LPDWORD,
+        lpOverlapped: LPOVERLAPPED,
+    ) -> BOOL;
     pub fn CloseHandle(hObject: HANDLE) -> BOOL;
-    pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
-                       lpNewFileName: LPCWSTR,
-                       dwFlags: DWORD)
-                       -> BOOL;
-    pub fn SetFilePointerEx(hFile: HANDLE,
-                            liDistanceToMove: LARGE_INTEGER,
-                            lpNewFilePointer: PLARGE_INTEGER,
-                            dwMoveMethod: DWORD)
-                            -> BOOL;
+    pub fn MoveFileExW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, dwFlags: DWORD)
+    -> BOOL;
+    pub fn SetFilePointerEx(
+        hFile: HANDLE,
+        liDistanceToMove: LARGE_INTEGER,
+        lpNewFilePointer: PLARGE_INTEGER,
+        dwMoveMethod: DWORD,
+    ) -> BOOL;
     pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
-    pub fn CreateFileW(lpFileName: LPCWSTR,
-                       dwDesiredAccess: DWORD,
-                       dwShareMode: DWORD,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                       dwCreationDisposition: DWORD,
-                       dwFlagsAndAttributes: DWORD,
-                       hTemplateFile: HANDLE)
-                       -> HANDLE;
-
-    pub fn FindFirstFileW(fileName: LPCWSTR,
-                          findFileData: LPWIN32_FIND_DATAW)
-                          -> HANDLE;
-    pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
-                         -> BOOL;
+    pub fn CreateFileW(
+        lpFileName: LPCWSTR,
+        dwDesiredAccess: DWORD,
+        dwShareMode: DWORD,
+        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
+        dwCreationDisposition: DWORD,
+        dwFlagsAndAttributes: DWORD,
+        hTemplateFile: HANDLE,
+    ) -> HANDLE;
+
+    pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) -> HANDLE;
+    pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) -> BOOL;
     pub fn FindClose(findFile: HANDLE) -> BOOL;
-    pub fn getsockopt(s: SOCKET,
-                      level: c_int,
-                      optname: c_int,
-                      optval: *mut c_char,
-                      optlen: *mut c_int)
-                      -> c_int;
-    pub fn setsockopt(s: SOCKET,
-                      level: c_int,
-                      optname: c_int,
-                      optval: *const c_void,
-                      optlen: c_int)
-                      -> c_int;
-    pub fn getsockname(socket: SOCKET,
-                       address: *mut SOCKADDR,
-                       address_len: *mut c_int)
-                       -> c_int;
-    pub fn getpeername(socket: SOCKET,
-                       address: *mut SOCKADDR,
-                       address_len: *mut c_int)
-                       -> c_int;
-    pub fn bind(socket: SOCKET, address: *const SOCKADDR,
-                address_len: socklen_t) -> c_int;
+    pub fn getsockopt(
+        s: SOCKET,
+        level: c_int,
+        optname: c_int,
+        optval: *mut c_char,
+        optlen: *mut c_int,
+    ) -> c_int;
+    pub fn setsockopt(
+        s: SOCKET,
+        level: c_int,
+        optname: c_int,
+        optval: *const c_void,
+        optlen: c_int,
+    ) -> c_int;
+    pub fn getsockname(socket: SOCKET, address: *mut SOCKADDR, address_len: *mut c_int) -> c_int;
+    pub fn getpeername(socket: SOCKET, address: *mut SOCKADDR, address_len: *mut c_int) -> c_int;
+    pub fn bind(socket: SOCKET, address: *const SOCKADDR, address_len: socklen_t) -> c_int;
     pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
-    pub fn connect(socket: SOCKET, address: *const SOCKADDR, len: c_int)
-                   -> c_int;
-    pub fn getaddrinfo(node: *const c_char, service: *const c_char,
-                       hints: *const ADDRINFOA,
-                       res: *mut *mut ADDRINFOA) -> c_int;
+    pub fn connect(socket: SOCKET, address: *const SOCKADDR, len: c_int) -> c_int;
+    pub fn getaddrinfo(
+        node: *const c_char,
+        service: *const c_char,
+        hints: *const ADDRINFOA,
+        res: *mut *mut ADDRINFOA,
+    ) -> c_int;
     pub fn freeaddrinfo(res: *mut ADDRINFOA);
 
-    pub fn GetProcAddress(handle: HMODULE,
-                          name: LPCSTR) -> *mut c_void;
+    pub fn GetProcAddress(handle: HMODULE, name: LPCSTR) -> *mut c_void;
     pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
 
     pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME);
 
-    pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES,
-                        bManualReset: BOOL,
-                        bInitialState: BOOL,
-                        lpName: LPCWSTR) -> HANDLE;
-    pub fn WaitForMultipleObjects(nCount: DWORD,
-                                  lpHandles: *const HANDLE,
-                                  bWaitAll: BOOL,
-                                  dwMilliseconds: DWORD) -> DWORD;
-    pub fn CreateNamedPipeW(lpName: LPCWSTR,
-                            dwOpenMode: DWORD,
-                            dwPipeMode: DWORD,
-                            nMaxInstances: DWORD,
-                            nOutBufferSize: DWORD,
-                            nInBufferSize: DWORD,
-                            nDefaultTimeOut: DWORD,
-                            lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
-                            -> HANDLE;
+    pub fn CreateEventW(
+        lpEventAttributes: LPSECURITY_ATTRIBUTES,
+        bManualReset: BOOL,
+        bInitialState: BOOL,
+        lpName: LPCWSTR,
+    ) -> HANDLE;
+    pub fn WaitForMultipleObjects(
+        nCount: DWORD,
+        lpHandles: *const HANDLE,
+        bWaitAll: BOOL,
+        dwMilliseconds: DWORD,
+    ) -> DWORD;
+    pub fn CreateNamedPipeW(
+        lpName: LPCWSTR,
+        dwOpenMode: DWORD,
+        dwPipeMode: DWORD,
+        nMaxInstances: DWORD,
+        nOutBufferSize: DWORD,
+        nInBufferSize: DWORD,
+        nDefaultTimeOut: DWORD,
+        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
+    ) -> HANDLE;
     pub fn CancelIo(handle: HANDLE) -> BOOL;
-    pub fn GetOverlappedResult(hFile: HANDLE,
-                               lpOverlapped: LPOVERLAPPED,
-                               lpNumberOfBytesTransferred: LPDWORD,
-                               bWait: BOOL) -> BOOL;
-    pub fn select(nfds: c_int,
-                  readfds: *mut fd_set,
-                  writefds: *mut fd_set,
-                  exceptfds: *mut fd_set,
-                  timeout: *const timeval) -> c_int;
-
+    pub fn GetOverlappedResult(
+        hFile: HANDLE,
+        lpOverlapped: LPOVERLAPPED,
+        lpNumberOfBytesTransferred: LPDWORD,
+        bWait: BOOL,
+    ) -> BOOL;
+    pub fn select(
+        nfds: c_int,
+        readfds: *mut fd_set,
+        writefds: *mut fd_set,
+        exceptfds: *mut fd_set,
+        timeout: *const timeval,
+    ) -> c_int;
 
     pub fn GetProcessHeap() -> HANDLE;
     pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
diff --git a/src/libstd/sys/windows/condvar.rs b/src/libstd/sys/windows/condvar.rs
index 62835ea7c94..8f7f6854cc2 100644
--- a/src/libstd/sys/windows/condvar.rs
+++ b/src/libstd/sys/windows/condvar.rs
@@ -4,7 +4,9 @@ use crate::sys::mutex::{self, Mutex};
 use crate::sys::os;
 use crate::time::Duration;
 
-pub struct Condvar { inner: UnsafeCell<c::CONDITION_VARIABLE> }
+pub struct Condvar {
+    inner: UnsafeCell<c::CONDITION_VARIABLE>,
+}
 
 unsafe impl Send for Condvar {}
 unsafe impl Sync for Condvar {}
@@ -19,18 +21,17 @@ impl Condvar {
 
     #[inline]
     pub unsafe fn wait(&self, mutex: &Mutex) {
-        let r = c::SleepConditionVariableSRW(self.inner.get(),
-                                             mutex::raw(mutex),
-                                             c::INFINITE,
-                                             0);
+        let r = c::SleepConditionVariableSRW(self.inner.get(), mutex::raw(mutex), c::INFINITE, 0);
         debug_assert!(r != 0);
     }
 
     pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
-        let r = c::SleepConditionVariableSRW(self.inner.get(),
-                                             mutex::raw(mutex),
-                                             super::dur2timeout(dur),
-                                             0);
+        let r = c::SleepConditionVariableSRW(
+            self.inner.get(),
+            mutex::raw(mutex),
+            super::dur2timeout(dur),
+            0,
+        );
         if r == 0 {
             debug_assert_eq!(os::errno() as usize, c::ERROR_TIMEOUT as usize);
             false
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index d59ac5959a6..a515b382ab0 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -1,16 +1,17 @@
 #![allow(missing_docs, nonstandard_style)]
 
-use crate::ptr;
 use crate::ffi::{OsStr, OsString};
 use crate::io::ErrorKind;
 use crate::os::windows::ffi::{OsStrExt, OsStringExt};
 use crate::path::PathBuf;
+use crate::ptr;
 use crate::time::Duration;
 
-pub use libc::strlen;
 pub use self::rand::hashmap_random_keys;
+pub use libc::strlen;
 
-#[macro_use] pub mod compat;
+#[macro_use]
+pub mod compat;
 
 pub mod alloc;
 pub mod args;
@@ -49,8 +50,7 @@ cfg_if::cfg_if! {
 }
 
 #[cfg(not(test))]
-pub fn init() {
-}
+pub fn init() {}
 
 pub fn decode_error_kind(errno: i32) -> ErrorKind {
     match errno as c::DWORD {
@@ -85,8 +85,10 @@ pub fn to_u16s<S: AsRef<OsStr>>(s: S) -> crate::io::Result<Vec<u16>> {
     fn inner(s: &OsStr) -> crate::io::Result<Vec<u16>> {
         let mut maybe_result: Vec<u16> = s.encode_wide().collect();
         if maybe_result.iter().any(|&u| u == 0) {
-            return Err(crate::io::Error::new(ErrorKind::InvalidInput,
-                                        "strings passed to WinAPI cannot contain NULs"));
+            return Err(crate::io::Error::new(
+                ErrorKind::InvalidInput,
+                "strings passed to WinAPI cannot contain NULs",
+            ));
         }
         maybe_result.push(0);
         Ok(maybe_result)
@@ -109,8 +111,9 @@ pub fn to_u16s<S: AsRef<OsStr>>(s: S) -> crate::io::Result<Vec<u16>> {
 // yielded the data which has been read from the syscall. The return value
 // from this closure is then the return value of the function.
 fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> crate::io::Result<T>
-    where F1: FnMut(*mut u16, c::DWORD) -> c::DWORD,
-          F2: FnOnce(&[u16]) -> T
+where
+    F1: FnMut(*mut u16, c::DWORD) -> c::DWORD,
+    F2: FnOnce(&[u16]) -> T,
 {
     // Start off with a stack buf but then spill over to the heap if we end up
     // needing more space.
@@ -148,7 +151,7 @@ fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> crate::io::Result<T>
             } else if k >= n {
                 n = k;
             } else {
-                return Ok(f2(&buf[..k]))
+                return Ok(f2(&buf[..k]));
             }
         }
     }
@@ -159,20 +162,23 @@ fn os2path(s: &[u16]) -> PathBuf {
 }
 
 #[allow(dead_code)] // Only used in backtrace::gnu::get_executable_filename()
-fn wide_char_to_multi_byte(code_page: u32,
-                           flags: u32,
-                           s: &[u16],
-                           no_default_char: bool)
-                           -> crate::io::Result<Vec<i8>> {
+fn wide_char_to_multi_byte(
+    code_page: u32,
+    flags: u32,
+    s: &[u16],
+    no_default_char: bool,
+) -> crate::io::Result<Vec<i8>> {
     unsafe {
-        let mut size = c::WideCharToMultiByte(code_page,
-                                              flags,
-                                              s.as_ptr(),
-                                              s.len() as i32,
-                                              ptr::null_mut(),
-                                              0,
-                                              ptr::null(),
-                                              ptr::null_mut());
+        let mut size = c::WideCharToMultiByte(
+            code_page,
+            flags,
+            s.as_ptr(),
+            s.len() as i32,
+            ptr::null_mut(),
+            0,
+            ptr::null(),
+            ptr::null_mut(),
+        );
         if size == 0 {
             return Err(crate::io::Error::last_os_error());
         }
@@ -181,21 +187,24 @@ fn wide_char_to_multi_byte(code_page: u32,
         buf.set_len(size as usize);
 
         let mut used_default_char = c::FALSE;
-        size = c::WideCharToMultiByte(code_page,
-                                      flags,
-                                      s.as_ptr(),
-                                      s.len() as i32,
-                                      buf.as_mut_ptr(),
-                                      buf.len() as i32,
-                                      ptr::null(),
-                                      if no_default_char { &mut used_default_char }
-                                      else { ptr::null_mut() });
+        size = c::WideCharToMultiByte(
+            code_page,
+            flags,
+            s.as_ptr(),
+            s.len() as i32,
+            buf.as_mut_ptr(),
+            buf.len() as i32,
+            ptr::null(),
+            if no_default_char { &mut used_default_char } else { ptr::null_mut() },
+        );
         if size == 0 {
             return Err(crate::io::Error::last_os_error());
         }
         if no_default_char && used_default_char == c::TRUE {
-            return Err(crate::io::Error::new(crate::io::ErrorKind::InvalidData,
-                                      "string cannot be converted to requested code page"));
+            return Err(crate::io::Error::new(
+                crate::io::ErrorKind::InvalidData,
+                "string cannot be converted to requested code page",
+            ));
         }
 
         buf.set_len(size as usize);
@@ -208,7 +217,7 @@ pub fn truncate_utf16_at_nul(v: &[u16]) -> &[u16] {
     match v.iter().position(|c| *c == 0) {
         // don't include the 0
         Some(i) => &v[..i],
-        None => v
+        None => v,
     }
 }
 
@@ -227,11 +236,7 @@ macro_rules! impl_is_zero {
 impl_is_zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
 
 pub fn cvt<I: IsZero>(i: I) -> crate::io::Result<I> {
-    if i.is_zero() {
-        Err(crate::io::Error::last_os_error())
-    } else {
-        Ok(i)
-    }
+    if i.is_zero() { Err(crate::io::Error::last_os_error()) } else { Ok(i) }
 }
 
 pub fn dur2timeout(dur: Duration) -> c::DWORD {
@@ -242,17 +247,12 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
     // * Nanosecond precision is rounded up
     // * Greater than u32::MAX milliseconds (50 days) is rounded up to INFINITE
     //   (never time out).
-    dur.as_secs().checked_mul(1000).and_then(|ms| {
-        ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000)
-    }).and_then(|ms| {
-        ms.checked_add(if dur.subsec_nanos() % 1_000_000 > 0 {1} else {0})
-    }).map(|ms| {
-        if ms > <c::DWORD>::max_value() as u64 {
-            c::INFINITE
-        } else {
-            ms as c::DWORD
-        }
-    }).unwrap_or(c::INFINITE)
+    dur.as_secs()
+        .checked_mul(1000)
+        .and_then(|ms| ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000))
+        .and_then(|ms| ms.checked_add(if dur.subsec_nanos() % 1_000_000 > 0 { 1 } else { 0 }))
+        .map(|ms| if ms > <c::DWORD>::max_value() as u64 { c::INFINITE } else { ms as c::DWORD })
+        .unwrap_or(c::INFINITE)
 }
 
 // On Windows, use the processor-specific __fastfail mechanism.  In Windows 8
diff --git a/src/libstd/sys/windows/mutex.rs b/src/libstd/sys/windows/mutex.rs
index 79dec1adf4b..281eb294c65 100644
--- a/src/libstd/sys/windows/mutex.rs
+++ b/src/libstd/sys/windows/mutex.rs
@@ -95,12 +95,12 @@ impl Mutex {
     pub unsafe fn destroy(&self) {
         match kind() {
             Kind::SRWLock => {}
-            Kind::CriticalSection => {
-                match self.lock.load(Ordering::SeqCst) {
-                    0 => {}
-                    n => { Box::from_raw(n as *mut ReentrantMutex).destroy(); }
+            Kind::CriticalSection => match self.lock.load(Ordering::SeqCst) {
+                0 => {}
+                n => {
+                    Box::from_raw(n as *mut ReentrantMutex).destroy();
                 }
-            }
+            },
         }
     }
 
@@ -114,7 +114,10 @@ impl Mutex {
         let re = Box::into_raw(re);
         match self.lock.compare_and_swap(0, re as usize, Ordering::SeqCst) {
             0 => re,
-            n => { Box::from_raw(re).destroy(); n as *mut _ }
+            n => {
+                Box::from_raw(re).destroy();
+                n as *mut _
+            }
         }
     }
 
@@ -125,7 +128,6 @@ impl Mutex {
             *self.held.get() = true;
             true
         }
-
     }
 }
 
@@ -134,9 +136,9 @@ fn kind() -> Kind {
 
     let val = KIND.load(Ordering::SeqCst);
     if val == Kind::SRWLock as usize {
-        return Kind::SRWLock
+        return Kind::SRWLock;
     } else if val == Kind::CriticalSection as usize {
-        return Kind::CriticalSection
+        return Kind::CriticalSection;
     }
 
     let ret = match compat::lookup("kernel32", "AcquireSRWLockExclusive") {
@@ -147,7 +149,9 @@ fn kind() -> Kind {
     ret
 }
 
-pub struct ReentrantMutex { inner: UnsafeCell<MaybeUninit<c::CRITICAL_SECTION>> }
+pub struct ReentrantMutex {
+    inner: UnsafeCell<MaybeUninit<c::CRITICAL_SECTION>>,
+}
 
 unsafe impl Send for ReentrantMutex {}
 unsafe impl Sync for ReentrantMutex {}
diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs
index 53e08d50004..58574f5723b 100644
--- a/src/libstd/sys/windows/net.rs
+++ b/src/libstd/sys/windows/net.rs
@@ -1,27 +1,27 @@
 #![unstable(issue = "none", feature = "windows_net")]
 
 use crate::cmp;
-use crate::io::{self, Read, IoSlice, IoSliceMut};
+use crate::io::{self, IoSlice, IoSliceMut, Read};
 use crate::mem;
-use crate::net::{SocketAddr, Shutdown};
+use crate::net::{Shutdown, SocketAddr};
 use crate::ptr;
 use crate::sync::Once;
-use crate::sys::c;
 use crate::sys;
-use crate::sys_common::{self, AsInner, FromInner, IntoInner};
+use crate::sys::c;
 use crate::sys_common::net;
+use crate::sys_common::{self, AsInner, FromInner, IntoInner};
 use crate::time::Duration;
 
-use libc::{c_int, c_void, c_ulong, c_long};
+use libc::{c_int, c_long, c_ulong, c_void};
 
 pub type wrlen_t = i32;
 
 pub mod netc {
-    pub use crate::sys::c::*;
+    pub use crate::sys::c::ADDRESS_FAMILY as sa_family_t;
+    pub use crate::sys::c::ADDRINFOA as addrinfo;
     pub use crate::sys::c::SOCKADDR as sockaddr;
     pub use crate::sys::c::SOCKADDR_STORAGE_LH as sockaddr_storage;
-    pub use crate::sys::c::ADDRINFOA as addrinfo;
-    pub use crate::sys::c::ADDRESS_FAMILY as sa_family_t;
+    pub use crate::sys::c::*;
 }
 
 pub struct Socket(c::SOCKET);
@@ -33,11 +33,15 @@ pub fn init() {
 
     START.call_once(|| unsafe {
         let mut data: c::WSADATA = mem::zeroed();
-        let ret = c::WSAStartup(0x202, // version 2.2
-                                &mut data);
+        let ret = c::WSAStartup(
+            0x202, // version 2.2
+            &mut data,
+        );
         assert_eq!(ret, 0);
 
-        let _ = sys_common::at_exit(|| { c::WSACleanup(); });
+        let _ = sys_common::at_exit(|| {
+            c::WSACleanup();
+        });
     });
 }
 
@@ -65,26 +69,19 @@ impl_is_minus_one! { i8 i16 i32 i64 isize }
 /// and if so, returns the last error from the Windows socket interface. This
 /// function must be called before another call to the socket API is made.
 pub fn cvt<T: IsMinusOne>(t: T) -> io::Result<T> {
-    if t.is_minus_one() {
-        Err(last_error())
-    } else {
-        Ok(t)
-    }
+    if t.is_minus_one() { Err(last_error()) } else { Ok(t) }
 }
 
 /// A variant of `cvt` for `getaddrinfo` which return 0 for a success.
 pub fn cvt_gai(err: c_int) -> io::Result<()> {
-    if err == 0 {
-        Ok(())
-    } else {
-        Err(last_error())
-    }
+    if err == 0 { Ok(()) } else { Err(last_error()) }
 }
 
 /// Just to provide the same interface as sys/unix/net.rs
 pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
-    where T: IsMinusOne,
-          F: FnMut() -> T
+where
+    T: IsMinusOne,
+    F: FnMut() -> T,
 {
     cvt(f())
 }
@@ -96,23 +93,27 @@ impl Socket {
             SocketAddr::V6(..) => c::AF_INET6,
         };
         let socket = unsafe {
-            match c::WSASocketW(fam, ty, 0, ptr::null_mut(), 0,
-                                c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT) {
-                c::INVALID_SOCKET => {
-                    match c::WSAGetLastError() {
-                        c::WSAEPROTOTYPE | c::WSAEINVAL => {
-                            match c::WSASocketW(fam, ty, 0, ptr::null_mut(), 0,
-                                                c::WSA_FLAG_OVERLAPPED) {
-                                c::INVALID_SOCKET => Err(last_error()),
-                                n => {
-                                    let s = Socket(n);
-                                    s.set_no_inherit()?;
-                                    Ok(s)
-                                },
+            match c::WSASocketW(
+                fam,
+                ty,
+                0,
+                ptr::null_mut(),
+                0,
+                c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT,
+            ) {
+                c::INVALID_SOCKET => match c::WSAGetLastError() {
+                    c::WSAEPROTOTYPE | c::WSAEINVAL => {
+                        match c::WSASocketW(fam, ty, 0, ptr::null_mut(), 0, c::WSA_FLAG_OVERLAPPED)
+                        {
+                            c::INVALID_SOCKET => Err(last_error()),
+                            n => {
+                                let s = Socket(n);
+                                s.set_no_inherit()?;
+                                Ok(s)
                             }
-                        },
-                        n => Err(io::Error::from_raw_os_error(n)),
+                        }
                     }
+                    n => Err(io::Error::from_raw_os_error(n)),
                 },
                 n => Ok(Socket(n)),
             }
@@ -135,8 +136,10 @@ impl Socket {
         }
 
         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 mut timeout = c::timeval {
@@ -157,9 +160,8 @@ impl Socket {
         let mut writefds = fds;
         let mut errorfds = fds;
 
-        let n = unsafe {
-            cvt(c::select(1, ptr::null_mut(), &mut writefds, &mut errorfds, &timeout))?
-        };
+        let n =
+            unsafe { cvt(c::select(1, ptr::null_mut(), &mut writefds, &mut errorfds, &timeout))? };
 
         match n {
             0 => Err(io::Error::new(io::ErrorKind::TimedOut, "connection timed out")),
@@ -174,8 +176,7 @@ impl Socket {
         }
     }
 
-    pub fn accept(&self, storage: *mut c::SOCKADDR,
-                  len: *mut c_int) -> io::Result<Socket> {
+    pub fn accept(&self, storage: *mut c::SOCKADDR, len: *mut c_int) -> io::Result<Socket> {
         let socket = unsafe {
             match c::accept(self.0, storage, len) {
                 c::INVALID_SOCKET => Err(last_error()),
@@ -188,33 +189,35 @@ impl Socket {
     pub fn duplicate(&self) -> io::Result<Socket> {
         let socket = unsafe {
             let mut info: c::WSAPROTOCOL_INFO = mem::zeroed();
-            cvt(c::WSADuplicateSocketW(self.0,
-                                            c::GetCurrentProcessId(),
-                                            &mut info))?;
-
-            match c::WSASocketW(info.iAddressFamily,
-                                info.iSocketType,
-                                info.iProtocol,
-                                &mut info, 0,
-                                c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT) {
-                c::INVALID_SOCKET => {
-                    match c::WSAGetLastError() {
-                        c::WSAEPROTOTYPE | c::WSAEINVAL => {
-                            match c::WSASocketW(info.iAddressFamily,
-                                                info.iSocketType,
-                                                info.iProtocol,
-                                                &mut info, 0,
-                                                c::WSA_FLAG_OVERLAPPED) {
-                                c::INVALID_SOCKET => Err(last_error()),
-                                n => {
-                                    let s = Socket(n);
-                                    s.set_no_inherit()?;
-                                    Ok(s)
-                                },
+            cvt(c::WSADuplicateSocketW(self.0, c::GetCurrentProcessId(), &mut info))?;
+
+            match c::WSASocketW(
+                info.iAddressFamily,
+                info.iSocketType,
+                info.iProtocol,
+                &mut info,
+                0,
+                c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT,
+            ) {
+                c::INVALID_SOCKET => match c::WSAGetLastError() {
+                    c::WSAEPROTOTYPE | c::WSAEINVAL => {
+                        match c::WSASocketW(
+                            info.iAddressFamily,
+                            info.iSocketType,
+                            info.iProtocol,
+                            &mut info,
+                            0,
+                            c::WSA_FLAG_OVERLAPPED,
+                        ) {
+                            c::INVALID_SOCKET => Err(last_error()),
+                            n => {
+                                let s = Socket(n);
+                                s.set_no_inherit()?;
+                                Ok(s)
                             }
-                        },
-                        n => Err(io::Error::from_raw_os_error(n)),
+                        }
                     }
+                    n => Err(io::Error::from_raw_os_error(n)),
                 },
                 n => Ok(Socket(n)),
             }
@@ -230,7 +233,7 @@ impl Socket {
             match c::recv(self.0, buf.as_mut_ptr() as *mut c_void, len, flags) {
                 -1 if c::WSAGetLastError() == c::WSAESHUTDOWN => Ok(0),
                 -1 => Err(last_error()),
-                n => Ok(n as usize)
+                n => Ok(n as usize),
             }
         }
     }
@@ -267,8 +270,11 @@ impl Socket {
         self.recv_with_flags(buf, c::MSG_PEEK)
     }
 
-    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: c::SOCKADDR_STORAGE_LH = unsafe { mem::zeroed() };
         let mut addrlen = mem::size_of_val(&storage) as c::socklen_t;
         let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t;
@@ -276,15 +282,17 @@ impl Socket {
         // On unix when a socket is shut down all further reads return 0, so we
         // do the same on windows to map a shut down socket to returning EOF.
         unsafe {
-            match c::recvfrom(self.0,
-                              buf.as_mut_ptr() as *mut c_void,
-                              len,
-                              flags,
-                              &mut storage as *mut _ as *mut _,
-                              &mut addrlen) {
+            match c::recvfrom(
+                self.0,
+                buf.as_mut_ptr() as *mut c_void,
+                len,
+                flags,
+                &mut storage as *mut _ as *mut _,
+                &mut addrlen,
+            ) {
                 -1 if c::WSAGetLastError() == c::WSAESHUTDOWN => {
                     Ok((0, net::sockaddr_to_addr(&storage, addrlen as usize)?))
-                },
+                }
                 -1 => Err(last_error()),
                 n => Ok((n as usize, net::sockaddr_to_addr(&storage, addrlen as usize)?)),
             }
@@ -316,18 +324,19 @@ impl Socket {
         Ok(nwritten as usize)
     }
 
-    pub fn set_timeout(&self, dur: Option<Duration>,
-                       kind: c_int) -> io::Result<()> {
+    pub fn set_timeout(&self, dur: Option<Duration>, kind: c_int) -> io::Result<()> {
         let timeout = match dur {
             Some(dur) => {
                 let timeout = sys::dur2timeout(dur);
                 if timeout == 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",
+                    ));
                 }
                 timeout
             }
-            None => 0
+            None => 0,
         };
         net::setsockopt(self, c::SOL_SOCKET, kind, timeout)
     }
@@ -345,10 +354,8 @@ impl Socket {
 
     #[cfg(not(target_vendor = "uwp"))]
     fn set_no_inherit(&self) -> io::Result<()> {
-        sys::cvt(unsafe {
-            c::SetHandleInformation(self.0 as c::HANDLE,
-                                    c::HANDLE_FLAG_INHERIT, 0)
-        }).map(|_| ())
+        sys::cvt(unsafe { c::SetHandleInformation(self.0 as c::HANDLE, c::HANDLE_FLAG_INHERIT, 0) })
+            .map(|_| ())
     }
 
     #[cfg(target_vendor = "uwp")]
@@ -369,11 +376,7 @@ impl Socket {
     pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
         let mut nonblocking = nonblocking as c_ulong;
         let r = unsafe { c::ioctlsocket(self.0, c::FIONBIO as c_int, &mut nonblocking) };
-        if r == 0 {
-            Ok(())
-        } else {
-            Err(io::Error::last_os_error())
-        }
+        if r == 0 { Ok(()) } else { Err(io::Error::last_os_error()) }
     }
 
     pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
@@ -387,11 +390,7 @@ impl Socket {
 
     pub fn take_error(&self) -> io::Result<Option<io::Error>> {
         let raw: c_int = net::getsockopt(self, c::SOL_SOCKET, c::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))) }
     }
 }
 
@@ -409,11 +408,15 @@ impl Drop for Socket {
 }
 
 impl AsInner<c::SOCKET> for Socket {
-    fn as_inner(&self) -> &c::SOCKET { &self.0 }
+    fn as_inner(&self) -> &c::SOCKET {
+        &self.0
+    }
 }
 
 impl FromInner<c::SOCKET> for Socket {
-    fn from_inner(sock: c::SOCKET) -> Socket { Socket(sock) }
+    fn from_inner(sock: c::SOCKET) -> Socket {
+        Socket(sock)
+    }
 }
 
 impl IntoInner<c::SOCKET> for Socket {
diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs
index 060997be97d..a62a637393e 100644
--- a/src/libstd/sys/windows/process.rs
+++ b/src/libstd/sys/windows/process.rs
@@ -1,9 +1,10 @@
 #![unstable(feature = "process_internals", issue = "none")]
 
+use crate::borrow::Borrow;
 use crate::collections::BTreeMap;
-use crate::env::split_paths;
 use crate::env;
-use crate::ffi::{OsString, OsStr};
+use crate::env::split_paths;
+use crate::ffi::{OsStr, OsString};
 use crate::fmt;
 use crate::fs;
 use crate::io::{self, Error, ErrorKind};
@@ -11,18 +12,17 @@ use crate::mem;
 use crate::os::windows::ffi::OsStrExt;
 use crate::path::Path;
 use crate::ptr;
-use crate::sys::mutex::Mutex;
 use crate::sys::c;
-use crate::sys::fs::{OpenOptions, File};
+use crate::sys::cvt;
+use crate::sys::fs::{File, OpenOptions};
 use crate::sys::handle::Handle;
+use crate::sys::mutex::Mutex;
 use crate::sys::pipe::{self, AnonPipe};
 use crate::sys::stdio;
-use crate::sys::cvt;
-use crate::sys_common::{AsInner, FromInner, IntoInner};
 use crate::sys_common::process::CommandEnv;
-use crate::borrow::Borrow;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
 
-use libc::{c_void, EXIT_SUCCESS, EXIT_FAILURE};
+use libc::{c_void, EXIT_FAILURE, EXIT_SUCCESS};
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
@@ -41,18 +41,23 @@ impl From<OsString> for EnvKey {
 }
 
 impl From<EnvKey> for OsString {
-    fn from(k: EnvKey) -> Self { k.0 }
+    fn from(k: EnvKey) -> Self {
+        k.0
+    }
 }
 
 impl Borrow<OsStr> for EnvKey {
-    fn borrow(&self) -> &OsStr { &self.0 }
+    fn borrow(&self) -> &OsStr {
+        &self.0
+    }
 }
 
 impl AsRef<OsStr> for EnvKey {
-    fn as_ref(&self) -> &OsStr { &self.0 }
+    fn as_ref(&self) -> &OsStr {
+        &self.0
+    }
 }
 
-
 fn ensure_no_nuls<T: AsRef<OsStr>>(str: T) -> io::Result<T> {
     if str.as_ref().encode_wide().any(|b| b == 0) {
         Err(io::Error::new(ErrorKind::InvalidInput, "nul byte found in provided data"))
@@ -127,8 +132,11 @@ impl Command {
         self.flags = flags;
     }
 
-    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 maybe_env = self.env.capture_if_changed();
         // To have the spawning semantics of unix/windows stay the same, we need
         // to read the *child's* PATH if one is provided. See #15149 for more
@@ -138,10 +146,11 @@ impl Command {
                 // Split the value and test each path to see if the
                 // program exists.
                 for path in split_paths(&v) {
-                    let path = path.join(self.program.to_str().unwrap())
-                                   .with_extension(env::consts::EXE_EXTENSION);
+                    let path = path
+                        .join(self.program.to_str().unwrap())
+                        .with_extension(env::consts::EXE_EXTENSION);
                     if fs::metadata(&path).is_ok() {
-                        return Some(path.into_os_string())
+                        return Some(path.into_os_string());
                     }
                 }
             }
@@ -178,32 +187,32 @@ impl Command {
         static CREATE_PROCESS_LOCK: Mutex = Mutex::new();
         let _guard = DropGuard::new(&CREATE_PROCESS_LOCK);
 
-        let mut pipes = StdioPipes {
-            stdin: None,
-            stdout: None,
-            stderr: None,
-        };
+        let mut pipes = StdioPipes { stdin: None, stdout: None, stderr: None };
         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 stdin = stdin.to_handle(c::STD_INPUT_HANDLE, &mut pipes.stdin)?;
-        let stdout = stdout.to_handle(c::STD_OUTPUT_HANDLE,
-                                      &mut pipes.stdout)?;
-        let stderr = stderr.to_handle(c::STD_ERROR_HANDLE,
-                                      &mut pipes.stderr)?;
+        let stdout = stdout.to_handle(c::STD_OUTPUT_HANDLE, &mut pipes.stdout)?;
+        let stderr = stderr.to_handle(c::STD_ERROR_HANDLE, &mut pipes.stderr)?;
         si.hStdInput = stdin.raw();
         si.hStdOutput = stdout.raw();
         si.hStdError = stderr.raw();
 
         unsafe {
-            cvt(c::CreateProcessW(ptr::null(),
-                                  cmd_str.as_mut_ptr(),
-                                  ptr::null_mut(),
-                                  ptr::null_mut(),
-                                  c::TRUE, flags, envp, dirp,
-                                  &mut si, &mut pi))
+            cvt(c::CreateProcessW(
+                ptr::null(),
+                cmd_str.as_mut_ptr(),
+                ptr::null_mut(),
+                ptr::null_mut(),
+                c::TRUE,
+                flags,
+                envp,
+                dirp,
+                &mut si,
+                &mut pi,
+            ))
         }?;
 
         // We close the thread handle because we don't care about keeping
@@ -213,7 +222,6 @@ impl Command {
 
         Ok((Process { handle: Handle::new(pi.hProcess) }, pipes))
     }
-
 }
 
 impl fmt::Debug for Command {
@@ -244,24 +252,20 @@ impl<'a> Drop for DropGuard<'a> {
 }
 
 impl Stdio {
-    fn to_handle(&self, stdio_id: c::DWORD, pipe: &mut Option<AnonPipe>)
-                 -> io::Result<Handle> {
+    fn to_handle(&self, stdio_id: c::DWORD, pipe: &mut Option<AnonPipe>) -> io::Result<Handle> {
         match *self {
             // If no stdio handle is available, then inherit means that it
             // should still be unavailable so propagate the
             // INVALID_HANDLE_VALUE.
-            Stdio::Inherit => {
-                match stdio::get_handle(stdio_id) {
-                    Ok(io) => {
-                        let io = Handle::new(io);
-                        let ret = io.duplicate(0, true,
-                                               c::DUPLICATE_SAME_ACCESS);
-                        io.into_raw();
-                        ret
-                    }
-                    Err(..) => Ok(Handle::new(c::INVALID_HANDLE_VALUE)),
+            Stdio::Inherit => match stdio::get_handle(stdio_id) {
+                Ok(io) => {
+                    let io = Handle::new(io);
+                    let ret = io.duplicate(0, true, c::DUPLICATE_SAME_ACCESS);
+                    io.into_raw();
+                    ret
                 }
-            }
+                Err(..) => Ok(Handle::new(c::INVALID_HANDLE_VALUE)),
+            },
 
             Stdio::MakePipe => {
                 let ours_readable = stdio_id != c::STD_INPUT_HANDLE;
@@ -270,9 +274,7 @@ impl Stdio {
                 Ok(pipes.theirs.into_handle())
             }
 
-            Stdio::Handle(ref handle) => {
-                handle.duplicate(0, true, c::DUPLICATE_SAME_ACCESS)
-            }
+            Stdio::Handle(ref handle) => handle.duplicate(0, true, c::DUPLICATE_SAME_ACCESS),
 
             // Open up a reference to NUL with appropriate read/write
             // permissions as well as the ability to be inherited to child
@@ -288,9 +290,7 @@ impl Stdio {
                 opts.read(stdio_id == c::STD_INPUT_HANDLE);
                 opts.write(stdio_id != c::STD_INPUT_HANDLE);
                 opts.security_attributes(&mut sa);
-                File::open(Path::new("NUL"), &opts).map(|file| {
-                    file.into_handle()
-                })
+                File::open(Path::new("NUL"), &opts).map(|file| file.into_handle())
             }
         }
     }
@@ -323,23 +323,19 @@ pub struct Process {
 
 impl Process {
     pub fn kill(&mut self) -> io::Result<()> {
-        cvt(unsafe {
-            c::TerminateProcess(self.handle.raw(), 1)
-        })?;
+        cvt(unsafe { c::TerminateProcess(self.handle.raw(), 1) })?;
         Ok(())
     }
 
     pub fn id(&self) -> u32 {
-        unsafe {
-            c::GetProcessId(self.handle.raw()) as u32
-        }
+        unsafe { c::GetProcessId(self.handle.raw()) as u32 }
     }
 
     pub fn wait(&mut self) -> io::Result<ExitStatus> {
         unsafe {
             let res = c::WaitForSingleObject(self.handle.raw(), c::INFINITE);
             if res != c::WAIT_OBJECT_0 {
-                return Err(Error::last_os_error())
+                return Err(Error::last_os_error());
             }
             let mut status = 0;
             cvt(c::GetExitCodeProcess(self.handle.raw(), &mut status))?;
@@ -362,9 +358,13 @@ impl Process {
         }
     }
 
-    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
+    }
 }
 
 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
@@ -441,7 +441,7 @@ fn zeroed_process_information() -> c::PROCESS_INFORMATION {
         hProcess: ptr::null_mut(),
         hThread: ptr::null_mut(),
         dwProcessId: 0,
-        dwThreadId: 0
+        dwThreadId: 0,
     }
 }
 
@@ -466,7 +466,8 @@ fn make_command_line(prog: &OsStr, args: &[OsString]) -> io::Result<Vec<u16>> {
         // it will be dropped entirely when parsed on the other end.
         ensure_no_nuls(arg)?;
         let arg_bytes = &arg.as_inner().inner.as_inner();
-        let quote = force_quotes || arg_bytes.iter().any(|c| *c == b' ' || *c == b'\t')
+        let quote = force_quotes
+            || arg_bytes.iter().any(|c| *c == b' ' || *c == b'\t')
             || arg_bytes.is_empty();
         if quote {
             cmd.push('"' as u16);
@@ -495,8 +496,7 @@ fn make_command_line(prog: &OsStr, args: &[OsString]) -> io::Result<Vec<u16>> {
     }
 }
 
-fn make_envp(maybe_env: Option<BTreeMap<EnvKey, OsString>>)
-             -> io::Result<(*mut c_void, Vec<u16>)> {
+fn make_envp(maybe_env: Option<BTreeMap<EnvKey, OsString>>) -> io::Result<(*mut c_void, Vec<u16>)> {
     // On Windows we pass an "environment block" which is not a char**, but
     // rather a concatenation of null-terminated k=v\0 sequences, with a final
     // \0 to terminate.
@@ -517,37 +517,33 @@ fn make_envp(maybe_env: Option<BTreeMap<EnvKey, OsString>>)
 }
 
 fn make_dirp(d: Option<&OsString>) -> io::Result<(*const u16, Vec<u16>)> {
-
     match d {
         Some(dir) => {
             let mut dir_str: Vec<u16> = ensure_no_nuls(dir)?.encode_wide().collect();
             dir_str.push(0);
             Ok((dir_str.as_ptr(), dir_str))
-        },
-        None => Ok((ptr::null(), Vec::new()))
+        }
+        None => Ok((ptr::null(), Vec::new())),
     }
 }
 
 #[cfg(test)]
 mod tests {
-    use crate::ffi::{OsStr, OsString};
     use super::make_command_line;
+    use crate::ffi::{OsStr, OsString};
 
     #[test]
     fn test_make_command_line() {
         fn test_wrapper(prog: &str, args: &[&str]) -> String {
-            let command_line = &make_command_line(OsStr::new(prog),
-                                                  &args.iter()
-                                                       .map(|a| OsString::from(a))
-                                                       .collect::<Vec<OsString>>())
-                                    .unwrap();
+            let command_line = &make_command_line(
+                OsStr::new(prog),
+                &args.iter().map(|a| OsString::from(a)).collect::<Vec<OsString>>(),
+            )
+            .unwrap();
             String::from_utf16(command_line).unwrap()
         }
 
-        assert_eq!(
-            test_wrapper("prog", &["aaa", "bbb", "ccc"]),
-            "\"prog\" aaa bbb ccc"
-        );
+        assert_eq!(test_wrapper("prog", &["aaa", "bbb", "ccc"]), "\"prog\" aaa bbb ccc");
 
         assert_eq!(
             test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa"]),
@@ -557,10 +553,7 @@ mod tests {
             test_wrapper("C:\\Program Files\\test", &["aa\"bb"]),
             "\"C:\\Program Files\\test\" aa\\\"bb"
         );
-        assert_eq!(
-            test_wrapper("echo", &["a b c"]),
-            "\"echo\" \"a b c\""
-        );
+        assert_eq!(test_wrapper("echo", &["a b c"]), "\"echo\" \"a b c\"");
         assert_eq!(
             test_wrapper("echo", &["\" \\\" \\", "\\"]),
             "\"echo\" \"\\\" \\\\\\\" \\\\\" \\"
diff --git a/src/libstd/sys/windows/rwlock.rs b/src/libstd/sys/windows/rwlock.rs
index ef57562fc3a..a769326352c 100644
--- a/src/libstd/sys/windows/rwlock.rs
+++ b/src/libstd/sys/windows/rwlock.rs
@@ -1,7 +1,9 @@
 use crate::cell::UnsafeCell;
 use crate::sys::c;
 
-pub struct RWLock { inner: UnsafeCell<c::SRWLOCK> }
+pub struct RWLock {
+    inner: UnsafeCell<c::SRWLOCK>,
+}
 
 unsafe impl Send for RWLock {}
 unsafe impl Sync for RWLock {}
diff --git a/src/libstd/sys/windows/time.rs b/src/libstd/sys/windows/time.rs
index bd533c93d43..86667ca7ab2 100644
--- a/src/libstd/sys/windows/time.rs
+++ b/src/libstd/sys/windows/time.rs
@@ -1,9 +1,9 @@
 use crate::cmp::Ordering;
+use crate::convert::TryInto;
 use crate::fmt;
 use crate::mem;
 use crate::sys::c;
 use crate::time::Duration;
-use crate::convert::TryInto;
 
 use core::hash::{Hash, Hasher};
 
@@ -53,8 +53,7 @@ impl Instant {
         // On windows there's a threshold below which we consider two timestamps
         // equivalent due to measurement error. For more details + doc link,
         // check the docs on epsilon.
-        let epsilon =
-            perf_counter::PerformanceCounterInstant::epsilon();
+        let epsilon = perf_counter::PerformanceCounterInstant::epsilon();
         if other.t > self.t && other.t - self.t <= epsilon {
             Some(Duration::new(0, 0))
         } else {
@@ -63,15 +62,11 @@ impl Instant {
     }
 
     pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
-        Some(Instant {
-            t: self.t.checked_add(*other)?
-        })
+        Some(Instant { t: self.t.checked_add(*other)? })
     }
 
     pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
-        Some(Instant {
-            t: self.t.checked_sub(*other)?
-        })
+        Some(Instant { t: self.t.checked_sub(*other)? })
     }
 }
 
@@ -89,7 +84,7 @@ impl SystemTime {
             t: c::FILETIME {
                 dwLowDateTime: intervals as c::DWORD,
                 dwHighDateTime: (intervals >> 32) as c::DWORD,
-            }
+            },
         }
     }
 
@@ -140,9 +135,7 @@ impl Ord for SystemTime {
 
 impl fmt::Debug for SystemTime {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("SystemTime")
-         .field("intervals", &self.intervals())
-         .finish()
+        f.debug_struct("SystemTime").field("intervals", &self.intervals()).finish()
     }
 }
 
@@ -153,7 +146,7 @@ impl From<c::FILETIME> for SystemTime {
 }
 
 impl Hash for SystemTime {
-    fn hash<H : Hasher>(&self, state: &mut H) {
+    fn hash<H: Hasher>(&self, state: &mut H) {
         self.intervals().hash(state)
     }
 }
@@ -167,26 +160,23 @@ fn checked_dur2intervals(dur: &Duration) -> Option<i64> {
 }
 
 fn intervals2dur(intervals: u64) -> Duration {
-    Duration::new(intervals / INTERVALS_PER_SEC,
-                  ((intervals % INTERVALS_PER_SEC) * 100) as u32)
+    Duration::new(intervals / INTERVALS_PER_SEC, ((intervals % INTERVALS_PER_SEC) * 100) as u32)
 }
 
 mod perf_counter {
-    use super::{NANOS_PER_SEC};
+    use super::NANOS_PER_SEC;
     use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
-    use crate::sys_common::mul_div_u64;
     use crate::sys::c;
     use crate::sys::cvt;
+    use crate::sys_common::mul_div_u64;
     use crate::time::Duration;
 
     pub struct PerformanceCounterInstant {
-        ts: c::LARGE_INTEGER
+        ts: c::LARGE_INTEGER,
     }
     impl PerformanceCounterInstant {
         pub fn now() -> Self {
-            Self {
-                ts: query()
-            }
+            Self { ts: query() }
         }
 
         // Per microsoft docs, the margin of error for cross-thread time comparisons
@@ -202,9 +192,7 @@ mod perf_counter {
         fn from(other: PerformanceCounterInstant) -> Self {
             let freq = frequency() as u64;
             let instant_nsec = mul_div_u64(other.ts as u64, NANOS_PER_SEC, freq);
-            Self {
-                t: Duration::from_nanos(instant_nsec)
-            }
+            Self { t: Duration::from_nanos(instant_nsec) }
         }
     }
 
@@ -234,9 +222,7 @@ mod perf_counter {
 
     fn query() -> c::LARGE_INTEGER {
         let mut qpc_value: c::LARGE_INTEGER = 0;
-        cvt(unsafe {
-            c::QueryPerformanceCounter(&mut qpc_value)
-        }).unwrap();
+        cvt(unsafe { c::QueryPerformanceCounter(&mut qpc_value) }).unwrap();
         qpc_value
     }
 }