Skip to content

Unboxed closures: cannot invoke no-argument closures #16673

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

Closed
netvl opened this issue Aug 22, 2014 · 3 comments
Closed

Unboxed closures: cannot invoke no-argument closures #16673

netvl opened this issue Aug 22, 2014 · 3 comments

Comments

@netvl
Copy link
Contributor

netvl commented Aug 22, 2014

#![feature(unboxed_closures, unboxed_closure_sugar)]

fn make_adder(a: int, b: int) -> Box<|&:| -> int> {
    (box |&:| a + b) as Box<|&:| -> int>
}

fn main() {
    println!("{}", make_adder(1, 2).call(()));
}

This code does not compile with this error:

<anon>:8:42: 8:44 error: mismatched types: expected `()` but found `()` (expected tuple but found ())
<anon>:8     println!("{}", make_adder(1, 2).call(()));
                                                  ^~
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
<anon>:8:5: 8:47 note: expansion site
error: aborting due to previous error

Naturally, call() without arguments does not work, but I know of no other way to pass zero argument to the closure.

@japaric
Copy link
Member

japaric commented Aug 22, 2014

This code is working on master, it must've been fixed by one of many unboxed closure PRs that have landed in the past 24 hours.

@japaric
Copy link
Member

japaric commented Aug 22, 2014

Found it, duplicate of #16168, fixed by PR #16637.

@alexcrichton
Copy link
Member

Thanks for investigating @japaric!

bors added a commit to rust-lang-ci/rust that referenced this issue Mar 3, 2024
Narrow down typos ignores

- remove ignored files
- check dotfiles
- reorder config sections: files, regexp, words, IDs
- remove non-existent ignores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants