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

unused_mut lint improvement: warn when variable only copied into closure #47128

Closed
rphmeier opened this issue Jan 2, 2018 · 1 comment · Fixed by #72465
Closed

unused_mut lint improvement: warn when variable only copied into closure #47128

rphmeier opened this issue Jan 2, 2018 · 1 comment · Fixed by #72465
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@rphmeier
Copy link
Contributor

rphmeier commented Jan 2, 2018

Minimal example of the lint failure to fire:

fn foo() -> bool {
    let mut res = false;
    
    let mut do_thing = move || res = true;
    do_thing();
    
    res
}

foo unconditionally returns false, but the top-level binding of res doesn't get an unused_mut warning.

@pietroalbini pietroalbini added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. labels Jan 30, 2018
@jakubadamw
Copy link
Contributor

jakubadamw commented Aug 13, 2019

This is related to or even a duplicate of #37707 and it will be probably be fixed as part of #51003.

@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 20, 2020
@bors bors closed this as completed in 9ef6227 May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants