immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.95k stars 234 forks source link

analyze: missing hypothetical lifetimes within function pointer types #992

Closed spernsteiner closed 1 year ago

spernsteiner commented 1 year ago
struct NeedsLifetime {
    p: *mut u8,
}

struct Vtable {
    copy: Option<unsafe extern "C" fn(*const NeedsLifetime) -> *mut NeedsLifetime>,
}

Rewritten output:

struct NeedsLifetime<'h1> {
    p: &'h1 (u8),
}

struct Vtable<'h2,'h1,'h3> {
    copy: Option<unsafe extern "C" fn(*const NeedsLifetime) -> *mut NeedsLifetime>,
}

Notice the uses of NeedsLifetime within the type of Vtable::copy don't pass the necessary lifetime arguments.