Rust-GCC / Rust-GCC/gccrs

Bad closure bounds check

Open
#3,354 1 comment 0 reactions 1 assignee View on GitHub

@philberty is already working on this.

Since Jan 6, 2025.

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

Description

Summary

Closures automatically implement the fn trait so this needs fixed

Reproducer

I tried this code:

#[lang = "sized"]
pub trait Sized {}

#[lang = "fn_once"]
pub trait FnOnce<Args> {
    #[lang = "fn_once_output"]
    type Output;

    extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
}


pub fn test() {
    let add: fn(i32) -> i32 = |x| {
    	x
    };
}
Does the code make use of any (1.49) nightly feature ?
  • Nightly
Godbolt link

https://godbolt.org/z/d4oo8dYoT

Actual behavior

The current behavior is...

<source>:14:5: error: bounds not satisfied for fnptr (i32 ,) -> i32 'FnOnce' is not satisfied [E0277]
   14 |     let add: fn(i32) -> i32 = |x| {
      |     ^~~ 
Expected behavior

I expected to see...

compiles

GCC Version

9de42352bb28dc20752fa81ca26cf9929936a48a

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.