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

Error message for reuse of variable moved into a closure uses closure type instead of variable type #24357

Closed
huonw opened this issue Apr 13, 2015 · 0 comments
Labels
A-closures Area: closures (`|args| { .. }`) A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@huonw
Copy link
Member

huonw commented Apr 13, 2015

struct NoCopy;
fn main() {
   let x = NoCopy;
   let f = move || { let y = x; };
   let z = x;
}
<anon>:5:8: 5:9 error: use of moved value: `x`
<anon>:5    let z = x;
                ^
<anon>:4:17: 4:34 note: `x` moved into closure environment here because it has type `[closure(())]`, which is non-copyable
<anon>:4    let f = move || { let y = x; };
                         ^~~~~~~~~~~~~~~~~
<anon>:4:34: 4:34 help: perhaps you meant to use `clone()`?

Presumably the error message should say because it has type NoCopy which is non-copyable.

@huonw huonw added A-diagnostics Area: Messages for errors, warnings, and lints A-closures Area: closures (`|args| { .. }`) labels Apr 13, 2015
nham pushed a commit to nham/rust that referenced this issue Jun 25, 2015
bors added a commit that referenced this issue Jun 25, 2015
Fixes #24357.

Also adds a (totally separate) regression test, which

Closes #18119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: closures (`|args| { .. }`) A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

1 participant