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_assignments lint false positive #22630

Closed
TimNN opened this issue Feb 21, 2015 · 5 comments
Closed

unused_assignments lint false positive #22630

TimNN opened this issue Feb 21, 2015 · 5 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.

Comments

@TimNN
Copy link
Contributor

TimNN commented Feb 21, 2015

The following code produces an unused_assignment warning (playground):

fn main() {
    let mut done = false;
    while !done {
        done = true;
        continue;
    }
}
warning: value assigned to `done` is never read
 --> src/main.rs:4:9
  |
4 |         done = true;
  |         ^^^^
  |
  = note: #[warn(unused_assignments)] on by default
@ghost ghost added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Feb 21, 2015
@steveklabnik
Copy link
Member

Triage: no change

@dchammond
Copy link

Bumping: This issue has not yet been fixed.

@yuval-k
Copy link

yuval-k commented Jul 20, 2017

Is this bug easy to fix? i would love to help, but have no idea where to start :)
Any pointers? even just the general direction of where to look would be great.

Thanks!

@oli-obk
Copy link
Contributor

oli-obk commented Sep 5, 2017

@yuval-k You can search the codebase for UNUSED_ASSIGNMENTS. There should be 2 or 3 mentions. The one that is surrounded by a span_lint call is where everything happens. From there you can go backwards to find out when that code is actually called.

@Amanieu
Copy link
Member

Amanieu commented Jan 2, 2019

Just hit this today, still an issue.

Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
…ebank

Fix unused_assignments false positive

Fixes rust-lang#22630.

In liveness analysis, make `continue` jump to the loop condition's `LiveNode` (`cond` as in comment) instead of the loop's one (`expr`).

https://github.com/rust-lang/rust/blob/069b0c410808c1d1d33b495e048b1186e9f8d57f/src/librustc/middle/liveness.rs#L1358-L1370
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-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

7 participants