Open
Description
I have a generated struct
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct AVIndexEntry {
// ...fields
pub _bitfield_align_1: [u32; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>,
// ...more fields
}
from the corresponding C header
typedef struct AVIndexEntry {
// ...fields
int flags:2;
int size:30;
// ...more fields
} AVIndexEntry;
The generated Rust implementation to read/write these bitfields uses transmute, but since 1.87 cast_unsigned
/cast_signed
exist and it looks like not using them creates a compiler warning in 1.88.
Generated code:
impl AVIndexEntry {
#[inline]
pub fn flags(&self) -> libc::c_int {
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) }
}
}
Resulting compiler error:
warning: unnecessary transmute
--> /home/user/<...>/out/bindings.rs:15519:18
|
15519 | ... { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `u32::cast_signed(self._bitfield_1.get(0usize, 2u8) as u32)`
Metadata
Metadata
Assignees
Labels
No labels