Skip to content

core::array::from_fn extracted with incorrect type parameter for closures returning references #1920

@parrot7483

Description

@parrot7483

When extracting Rust code that uses core::array::from_fn with a closure returning reference types (e.g., &[u8]), hax incorrectly generates the F* type parameter as a function type instead of the element type.

Expected F* extraction: Core_models.Array.from_fn #(t_Slice u8) N (fun i -> ...)
Actual F* extraction: Core_models.Array.from_fn #(usize -> t_Slice u8) N (fun i -> ...)

See this example:

const N: usize = 4;
const M: usize = 168;

fn main() {
    let data = [[0u8; M]; N];
    let slices: [&[u8]; N] = core::array::from_fn(|i| data[i].as_slice());
}

Open this code snippet in the playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions