Closed darklajid closed 1 year ago
The AlsoUsableFor
attribute is needed for this conversion to apply automatically. I'll transfer the issue to the Win32 metadata repo for consideration.
In the short term, a workaround is to convert it yourself. Something like HANDLE(hwnd.0)
.
Which crate is this about?
windows
Crate version
0.48
Summary
Creating a window using
CreateWindowExA
I hold on to a HWND. A few lines later I try toRegisterDeviceNotificationA
and pass that HWND as the first argument of type HANDLE. I'm not sure if things would blow up the way I cast the second parameter for the function, but we don't even get that far - Rust claims a HWND isn't/cannot be turned into a HANDLE..Toolchain version/configuration
rustup show Default host: x86_64-pc-windows-msvc rustup home: C:\Users\Ben.rustup
stable-x86_64-pc-windows-msvc (default) rustc 1.68.2 (9eb3afe9e 2023-03-27)
Reproducible example
Crate manifest
Expected behavior
A HWND is a HANDLE as far as I understand. I should be able to pass it as one
Actual behavior
windows::Win32::Foundation::HWND: CanInto<HANDLE>
is not satisfied --> src\main.rs:51:41CanInto<HANDLE>
is not implemented forwindows::Win32::Foundation::HWND
note: required by a bound in,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in
windows::Win32::UI::WindowsAndMessaging::RegisterDeviceNotificationA
--> C:\Users\Ben.cargo\registry\src\github.com-1ecc6299db9ec823\windows-0.48.0\src\Windows\Win32\UI\WindowsAndMessaging\mod.rs:3037:9 | 3037 | P0: ::windows::core::IntoParamRegisterDeviceNotificationA
For more information about this error, try
rustc --explain E0277
. error: could not compileusb_fun
due to previous errorAdditional comments
No response