c2rust
c2rust copied to clipboard
bitfields: error when using `derive(BitfieldStruct)` on a struct with lifetime parameters
use c2rust_bitfields::BitfieldStruct;
#[derive(BitfieldStruct)]
pub struct Foo {
pub x: &'static i32,
#[bitfield(name = "flags", ty = "u32", bits = "0..=7")]
pub flags: [u8; 1],
}
#[derive(BitfieldStruct)]
pub struct Bar<'a> {
pub x: &'a i32,
#[bitfield(name = "flags", ty = "u32", bits = "0..=7")]
pub flags: [u8; 1],
}
struct Foo works, struct Bar doesn't:
error[E0726]: implicit elided lifetime not allowed here
--> src/main.rs:11:12
|
11 | pub struct Bar<'a> {
| ^^^ expected lifetime parameter
|
= note: assuming a `'static` lifetime...
help: indicate the anonymous lifetime
|
11 | pub struct Bar<'_><'a> {
| ++++
Presumably the weird error reporting is due to the Bar token being reused somewhere in the derive(BitfieldStruct) output (without the necessary lifetime arguments) while keeping its original span.