immunant / c2rust

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

analyze: borrowck assertion failure on casts involving hypothetical region params #944

Closed spernsteiner closed 1 year ago

spernsteiner commented 1 year ago

Test case:

// Regression test for an assertion failure in `borrowck::type_check` `do_assign` related to
// mismatched numbers of origin params in casts.

pub struct fdnode {
    pub ctx: *mut u8,
}

unsafe extern "C" fn server_free(fdn: *mut fdnode) {
    let _fdn2 = fdn as *const fdnode;
}

Panics on this assertion:

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`', c2rust-analyze/src/borrowck/type_check.rs:423:13

This error currently appears in 102 places in lighttpd