Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad closure bounds check #3354

Open
1 task done
philberty opened this issue Jan 6, 2025 · 0 comments
Open
1 task done

Bad closure bounds check #3354

philberty opened this issue Jan 6, 2025 · 0 comments
Assignees
Labels

Comments

@philberty
Copy link
Member

philberty commented Jan 6, 2025

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

9de4235

@philberty philberty added the bug label Jan 6, 2025
@philberty philberty added this to the Remaining typecheck issues milestone Jan 6, 2025
@philberty philberty self-assigned this Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant