Skip to content

closure type inference bug #2827

@philberty

Description

@philberty

I tried this code: https://godbolt.org/z/aKPfG1Khf

#[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) -> i32 = |x, y| {
    	*x + *y
    };
}

I expected to see this happen: compile without error

Instead, this happened:

x86-64 GCCRS (GCCRS master) - 579ms

<source>:15:16: error: expected reference type got T?
   15 |         *x + *y
      |                ^
<source>:15:21: error: expected reference type got T?
   15 |         *x + *y
      |                     ^
<source>:15:16: error: cannot apply this operator to types <tyty::error> and <tyty::error>
   15 |         *x + *y
      |                ^
<source>:14:5: error: bounds not satisfied for fnptr (& i32 ,& i32 ,) -> i32 'FnOnce' is not satisfied [E0277]
   14 |     let add: fn(&i32, &i32) -> i32 = |x, y| {
      |     ^~~    

Meta

  • What version of Rust GCC were you using, git sha if possible.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions