Repository: sharkdp/hyperfine (language: rust)

Issue:
'cargo install hyperfine' fails on Windows
```
error[E0432]: unresolved import `winapi::um::handleapi`
 --> ....cargo\registry\src\github.com-1ecc6299db9ec823\hyperfine-1.15.0\src\timer\windows_timer.rs:9:9
  |
9 |         handleapi::CloseHandle,
  |         ^^^^^^^^^ could not find `handleapi` in `um`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `hyperfine` due to previous error
error: failed to compile `hyperfine v1.15.0`, intermediate artifacts can be found at `...AppData\Local\Temp\cargo-installRqHcG9`
```


Discussion / hints:
```
cargo install --locked hyperfine
```
Succeeds, so I presume its a incompat in a semver-compatible change to winapi.
See https://github.com/sharkdp/hyperfine/issues/595. This should be fixed on `master`? (https://github.com/sharkdp/hyperfine/pull/596)
@sharkdp I am still getting these build failures as of `1.16.1` on win11 / rust `1.68.2`.  Do you want me to open a new issue?  `install --locked` got me through.

```log
error[E0308]: mismatched types
   --> C:\Users\maximilian\.cargo\registry\src\github.com-1ecc6299db9ec823\hyperfine-1.16.1\src\timer\windows_timer.rs:56:65
    |
56  | ... { AssignProcessToJobObject(job_object, child.as_raw_handle()) };
    |       ------------------------             ^^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
    |       |
    |       arguments to this function are incorrect
    |
    = note: enum `std::ffi::c_void` and enum `winapi::ctypes::c_void` have similar names, but are actually distinct types
note: enum `std::ffi::c_void` is defined in crate `core`
   --> C:\Users\maximilian\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\ffi\mod.rs:203:1
    |
203 | pub enum c_void {
    | ^^^^^^^^^^^^^^^
note: enum `winapi::ctypes::c_void` is defined in crate `winapi`
   --> C:\Users\maximilian\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-0.3.9\src\lib.rs:38:5
    |
38  |     pub enum c_void {}
    |     ^^^^^^^^^^^^^^^
note: function defined here
   --> C:\Users\maximilian\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-0.3.9\src\um\jobapi2.rs:32:12
    |
32  |     pub fn AssignProcessToJobObject(
    |            ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> C:\Users\maximilian\.cargo\registry\src\github.com-1ecc6299db9ec823\hyperfine-1.16.1\src\timer\windows_timer.rs:73:48
    |
73  |             let ret = unsafe { NtResumeProcess(child.as_raw_handle()) };
    |                                --------------- ^^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
    |                                |
    |                                arguments to this function are incorrect
    |
    = note: enum `std::ffi::c_void` and enum `winapi::ctypes::c_void` have similar names, but are actually distinct types
note: enum `std::ffi::c_void` is defined in crate `core`
   --> C:\Users\maximilian\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\ffi\mod.rs:203:1
    |
203 | pub enum c_void {
    | ^^^^^^^^^^^^^^^
note: enum `winapi::ctypes::c_void` is defined in crate `winapi`
   --> C:\Users\maximilian\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-0.3.9\src\lib.rs:38:5
    |
38  |     pub enum c_void {}
    |     ^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `hyperfine` due to 2 previous errors
error: failed to compile `hyperfine v1.16.1`, intermediate artifacts can be found at `C:\Users\MAXIMI~1\AppData\Local\Temp\cargo-installvG1EFr`
```
Thank you for reporting this. It's another issue, but we can just reopen this one.

Maybe @clemenswasser has an idea what's going on here?

Fix patch:
diff --git a/src/timer/windows_timer.rs b/src/timer/windows_timer.rs
index 97e12f382..84ffac58e 100644
--- a/src/timer/windows_timer.rs
+++ b/src/timer/windows_timer.rs
@@ -48,12 +48,14 @@ pub struct CPUTimer {
 
 impl CPUTimer {
     pub unsafe fn start_suspended_process(child: &process::Child) -> Self {
+        let child_handle = child.as_raw_handle().cast();
+
         // SAFETY: Creating a new job object is safe
         let job_object = unsafe { CreateJobObjectW(ptr::null_mut(), ptr::null_mut()) };
         assert!(!job_object.is_null(), "CreateJobObjectW failed");
 
         // SAFETY: The job object handle is valid
-        let ret = unsafe { AssignProcessToJobObject(job_object, child.as_raw_handle()) };
+        let ret = unsafe { AssignProcessToJobObject(job_object, child_handle) };
         assert!(ret != 0, "AssignProcessToJobObject failed");
 
         #[cfg(windows_process_extensions_main_thread_handle)]
@@ -70,7 +72,7 @@ impl CPUTimer {
             // resume a process by it's handle.
 
             // SAFETY: The process handle is valid
-            let ret = unsafe { NtResumeProcess(child.as_raw_handle()) };
+            let ret = unsafe { NtResumeProcess(child_handle) };
             assert!(ret == STATUS_SUCCESS, "NtResumeProcess failed");
         }
 


Test patch: