]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_errors/lock.rs
Rollup merge of #67313 - oli-obk:document_all_the_t̶h̶i̶n̶g̶s̶dataflow, r=ecstatic...
[rust.git] / src / librustc_errors / lock.rs
index f731791efe6e16344c6d5f11d8acd825f4b753df..198a9c12406e52a23025c6ad2eeecc0a7c0bf175 100644 (file)
@@ -28,10 +28,11 @@ pub fn acquire_global_lock(name: &str) -> Box<dyn Any> {
     const WAIT_ABANDONED: DWORD = 0x00000080;
 
     extern "system" {
-        fn CreateMutexA(lpMutexAttributes: LPSECURITY_ATTRIBUTES,
-                        bInitialOwner: BOOL,
-                        lpName: LPCSTR)
-                        -> HANDLE;
+        fn CreateMutexA(
+            lpMutexAttributes: LPSECURITY_ATTRIBUTES,
+            bInitialOwner: BOOL,
+            lpName: LPCSTR,
+        ) -> HANDLE;
         fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD;
         fn ReleaseMutex(hMutex: HANDLE) -> BOOL;
         fn CloseHandle(hObject: HANDLE) -> BOOL;
@@ -64,11 +65,13 @@ fn drop(&mut self) {
         //
         // This will silently create one if it doesn't already exist, or it'll
         // open up a handle to one if it already exists.
-        let mutex = CreateMutexA(0 as *mut _, 0, cname.as_ptr() as *const u8);
+        let mutex = CreateMutexA(std::ptr::null_mut(), 0, cname.as_ptr() as *const u8);
         if mutex.is_null() {
-            panic!("failed to create global mutex named `{}`: {}",
-                   name,
-                   io::Error::last_os_error());
+            panic!(
+                "failed to create global mutex named `{}`: {}",
+                name,
+                io::Error::last_os_error()
+            );
         }
         let mutex = Handle(mutex);
 
@@ -86,11 +89,13 @@ fn drop(&mut self) {
         match WaitForSingleObject(mutex.0, INFINITE) {
             WAIT_OBJECT_0 | WAIT_ABANDONED => {}
             code => {
-                panic!("WaitForSingleObject failed on global mutex named \
+                panic!(
+                    "WaitForSingleObject failed on global mutex named \
                         `{}`: {} (ret={:x})",
-                       name,
-                       io::Error::last_os_error(),
-                       code);
+                    name,
+                    io::Error::last_os_error(),
+                    code
+                );
             }
         }