Skip to content

non-&mut unboxed closures look for FnMut trait for direct call_once/call method call #16599

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
huonw opened this issue Aug 19, 2014 · 2 comments
Labels
A-closures Area: Closures (`|…| { … }`)

Comments

@huonw
Copy link
Member

huonw commented Aug 19, 2014

#![feature(unboxed_closures, unboxed_closure_sugar)]

fn main() {
    let once_ = |: x| x;
    once_.call_once((0i, ));

    let mut_ = |&mut: x| x;
    mut_.call_once((0i, ));
}
<anon>:7:5: 7:28 error: failed to find an implementation of trait core::ops::FnMut<(int),int> for closure
<anon>:7     once_.call_once((0i, ));
             ^~~~~~~~~~~~~~~~~~~~~~~
<anon>:7:5: 7:28 error: failed to find an implementation of trait core::ops::FnMut<(int),int> for closure
<anon>:7     once_.call_once((0i, ));
             ^~~~~~~~~~~~~~~~~~~~~~~

It's particularly strange that the mut_.call_once form works (it's also a little strange that the error message is emitted twice.)

@huonw
Copy link
Member Author

huonw commented Aug 19, 2014

Oh, this fails for Fn & .call too:

#![feature(unboxed_closures, unboxed_closure_sugar)]

fn main() {
    let f = |&: x: int| x;
    f.call((1i,));
}
<anon>:5:5: 5:18 error: failed to find an implementation of trait core::ops::FnMut<(int),int> for closure
<anon>:5     f.call((1i,));
             ^~~~~~~~~~~~~
<anon>:5:5: 5:18 error: failed to find an implementation of trait core::ops::FnMut<(int),int> for closure
<anon>:5     f.call((1i,));
             ^~~~~~~~~~~~~

@huonw huonw changed the title |: ...| closure syntax looks for FnMut for call_once method call non-&mut unboxed closures look for FnMut trait for direct call_once/call method call Aug 19, 2014
@jroesch
Copy link
Member

jroesch commented Aug 20, 2014

Just leaving a comment here because I've run into this bug in the past few hours as well, and I am interested in its progress.

bors added a commit that referenced this issue Aug 21, 2014
…huonw

the right trait and take the method name into account.

Closes #16599.

r? @huonw
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
internal: Also downgrade actions/setup-node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants