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

Hint about a moved value in nested closure #41482

Closed
antoyo opened this issue Apr 23, 2017 · 0 comments
Closed

Hint about a moved value in nested closure #41482

antoyo opened this issue Apr 23, 2017 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@antoyo
Copy link
Contributor

antoyo commented Apr 23, 2017

Hello.
In the following code:

fn main() {
    let mut vec = vec![1];
    let vec2 = vec![1];
    let vec3 = vec![1];
    vec2.iter().map(move |_| {
        vec3.iter().map(move |_| {
            vec.iter();
            0
        });
        0
    });
}

we get the following error:

error[E0507]: cannot move out of captured outer variable in an `FnMut` closure
 --> src/main.rs:6:25
  |
6 |         vec3.iter().map(move |_| {
  |                         ^^^^^^^^ cannot move out of captured outer variable in an `FnMut` closure

which is not very helpful as it does not indicate which variable it is.
It would be nice to have a better hint in this case.
Thanks.

@jdm jdm added the A-diagnostics Area: Messages for errors, warnings, and lints label Apr 23, 2017
arielb1 pushed a commit to arielb1/rust that referenced this issue Apr 27, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Apr 27, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Apr 27, 2017
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

No branches or pull requests

2 participants