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

More explanatory error when calling a closure via & #15506

Closed
brson opened this issue Jul 7, 2014 · 0 comments · Fixed by #17434
Closed

More explanatory error when calling a closure via & #15506

brson opened this issue Jul 7, 2014 · 0 comments · Fixed by #17434
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@brson
Copy link
Contributor

brson commented Jul 7, 2014

When calling a closure behind a shared reference the error reported is simply "closure invocation in a & reference". When I first encountered this I had no idea what the problem was or how to fix it. Simply mentioning that closures behind a reference can only be called via &mut would help.

Test case:

fn main() {
    let foo: &|| = &|| ();
    (*foo)();
}

Error:

test.rs:3:5: 3:11 error: closure invocation in a `&` reference
test.rs:3     (*foo)();
              ^~~~~~
ftxqxd added a commit to ftxqxd/rust that referenced this issue Oct 2, 2014
bors added a commit that referenced this issue Oct 2, 2014
This was originally part of #17215.

Closes #15506.
Closes #15630.
Closes #17263.

This also partially implements #15838.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants