Rust-GCC / Rust-GCC/gccrs

Function pointers are not getting monormophized fully

Open
#2,877 1 comment 0 reactions 1 assignee View on GitHub

@CohenArthur is already working on this.

Since Feb 29, 2024.

bug typechecking
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

    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);
      |                                ^~~~~~~~~~~~~

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.