Skip to content

bindgen: transmute build warning #169

@twilfredo

Description

@twilfredo

With Rust 1.90 we are seeing

cargo build
   Compiling SPDM-Utils v1.0.0 (/home/twilfred/wdc/spdm-utils)
warning: unnecessary transmute
     --> /home/twilfred/wdc/spdm-utils/target/debug/build/SPDM-Utils-f0ce4a3373be96f5/out/bindings.rs:16315:18
      |
16315 |         unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 24u8) as u32) }
      |                  ----------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |                  |
      |                  help: replace this with: `u32::cast_signed`
      |
      = note: `#[warn(unnecessary_transmutes)]` on by default

warning: unnecessary transmute
     --> /home/twilfred/wdc/spdm-utils/target/debug/build/SPDM-Utils-f0ce4a3373be96f5/out/bindings.rs:16320:28
      |
16320 |             let val: u32 = ::core::mem::transmute(val);
      |                            ----------------------^^^^^
      |                            |
      |                            help: replace this with: `i32::cast_unsigned`

warning: unnecessary transmute
     --> /home/twilfred/wdc/spdm-utils/target/debug/build/SPDM-Utils-f0ce4a3373be96f5/out/bindings.rs:16327:13
      |
16327 |               ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 3usize]>>::raw_get(
      |               ^---------------------
      |               |
      |  _____________help: replace this with: `u32::cast_signed`
      | |
16328 | |                 ::core::ptr::addr_of!((*this)._bitfield_1),
16329 | |                 0usize,
16330 | |                 24u8,
16331 | |             ) as u32)
      | |_____________________^

warning: unnecessary transmute
     --> /home/twilfred/wdc/spdm-utils/target/debug/build/SPDM-Utils-f0ce4a3373be96f5/out/bindings.rs:16337:28
      |
16337 |             let val: u32 = ::core::mem::transmute(val);
      |                            ----------------------^^^^^
      |                            |
      |                            help: replace this with: `i32::cast_unsigned`

warning: unnecessary transmute
     --> /home/twilfred/wdc/spdm-utils/target/debug/build/SPDM-Utils-f0ce4a3373be96f5/out/bindings.rs:16350:41
      |
16350 |             let _flags2: u32 = unsafe { ::core::mem::transmute(_flags2) };
      |                                         ----------------------^^^^^^^^^
      |                                         |
      |                                         help: replace this with: `i32::cast_unsigned

Which are from the generated bindings, it would be good to suppress these upon builds. I've tried adding a .raw_line("#[allow(unnecessary_transmutes)]") to the builder. But did not have much luck.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions