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

"value assigned is never used" should point to value, not binding #33536

Closed
sanxiyn opened this issue May 10, 2016 · 4 comments
Closed

"value assigned is never used" should point to value, not binding #33536

sanxiyn opened this issue May 10, 2016 · 4 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@sanxiyn
Copy link
Member

sanxiyn commented May 10, 2016

People are confused when warning points to binding, because it is often the case that while value assigned is never used, binding is used.

Suggestion found in users.rust-lang.org thread.

@sanxiyn sanxiyn added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label May 10, 2016
@birkenfeld
Copy link
Contributor

Problem is, this is also the case here:

let (mut a, b) = tup;
a = 5;

Where should we point here?

@CryZe
Copy link
Contributor

CryZe commented May 11, 2016

It should point to = tup;. Where else should it point to?

@CryZe
Copy link
Contributor

CryZe commented May 11, 2016

Oh I guess parts of tup could be used, I guess it should just say that the a binding is bound to tup which the code never reads from before assigning another value. It could potentially also point to the reassignment.

@Mark-Simulacrum
Copy link
Member

This has since been fixed.

fn main() {
    let mut a = 10;
    a = 15;
}
warning: variable `a` is assigned to, but never used
 --> test.rs:2:9
  |
2 |     let mut a = 10;
  |         ^^^^^
  |
  = note: #[warn(unused_variables)] on by default

warning: value assigned to `a` is never read
 --> test.rs:3:5
  |
3 |     a = 15;
  |     ^
  |
  = note: #[warn(unused_assignments)] on by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

4 participants