Skip to content

panicked at 'cannot transmute_copy if U is larger than T' #121

Closed
@NaokiM03

Description

@NaokiM03

Describe the bug

On windows, functions that use fn keybd_event(flags: u32, vk: u16, scan: u16) internally cause panic when used in Rust 1.64.0 or later.

See also the following issue.
rust-lang/rust#100545

thread 'main' panicked at 'cannot transmute_copy if U is larger than T', /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634\library\core\src\mem\mod.rs:1057:5
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library\core\src\panicking.rs:142
   2: core::mem::transmute_copy<winapi::um::winuser::KEYBDINPUT,winapi::um::winuser::INPUT_u>
             at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634\library\core\src\mem\mod.rs:1057
   3: enigo::win::win_impl::keybd_event
             at .\src\win\win_impl.rs:36
   4: enigo::win::win_impl::impl$1::key_down
             at .\src\win\win_impl.rs:138
   5: key::main
             at .\examples\key.rs:9
   6: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634\library\core\src\ops\function.rs:248
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\examples\key.exe` (exit code: 101)

To Reproduce

Use rustc 1.64.0-nightly and run cargo run --example key.

Expected behavior

Expects a input, but in fact panic occurs.

Environment (please complete the following information):

  • OS: Windows
  • Rust: rustc 1.64.0-nightly (f6f9d5e73 2022-08-04)
  • Library Version: enigo 0.0.14

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions