Skip to content

Function pointers are not getting monormophized fully #2877

@CohenArthur

Description

@CohenArthur
    pub fn new<'b, T>(
        value: &'b T,
        formatter: fn(&T, &mut Formatter<'_>),
    ) -> Argument<'b> { ... }


fn int_formatter(value: &i32, _: &mut Formatter<'_>) {
    unsafe {
        puts("hell yeah!\n\0" as *const str as *const i8);
    }
}

fn main() {
    let a = 15;
    let a = Argument::new(&15, int_formatter);
}

should work, but errors out with this instead:

extern_types_test.rs:61:32: error: mismatched types, expected ‘fnptr (& T=T REF: 65 ,&mut Formatter{Formatter (0:& ())} ,) -> Result{Result {}}’ but got ‘fn (value & i32,_ &mut Formatter{Formatter (0:& ())},) -> Result{Result {}}[E0308]
   29 |         formatter: fn(&T, &mut Formatter<'_>) -> Result,
      |         ~~~~~~~~~
......
   61 |     let a = Argument::new(&15, int_formatter);
      |                                ^~~~~~~~~~~~~

Metadata

Metadata

Assignees

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions