Skip to content

Misleading unused_mut warning when moving into a proc #16671

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
tomjakubowski opened this issue Aug 22, 2014 · 1 comment
Closed

Misleading unused_mut warning when moving into a proc #16671

tomjakubowski opened this issue Aug 22, 2014 · 1 comment

Comments

@tomjakubowski
Copy link
Contributor

This example:

fn main() {
    let mut stdin = std::io::stdio::stdin();
    spawn(proc() {
        for line in stdin.lines() {
            print!("{}", line);
        }
    });
}

Gives this warning:

<anon>:2:9: 2:18 warning: variable does not need to be mutable, #[warn(unused_mut)] on by default
<anon>:2     let mut stdin = std::io::stdio::stdin();
                 ^~~~~~~~~

However, removing the mut is an error:

<anon>:4:21: 4:26 error: cannot borrow immutable captured outer variable in a proc `stdin` as mutable
<anon>:4         for line in stdin.lines() {
                             ^~~~~
error: aborting due to previous error
@alexcrichton
Copy link
Member

cc @luqmana and #16253

@bors bors closed this as completed in a284240 Aug 23, 2014
sfackler added a commit to sfackler/rust that referenced this issue Dec 6, 2014
Seems to be blocking forever
sfackler added a commit to sfackler/rust that referenced this issue Mar 1, 2015
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

Successfully merging a pull request may close this issue.

2 participants