Closed
Description
For reference, see this Reddit thread
It seems to me that if you have code like this
for x in foo {
// code that does not use `x`...
}
Then in addition to the "unused variable" warning that you currently get:
unused_var.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variables)] on by default
unused_var.rs:2 for x in [1,2,3].iter() {
^
it should also display a note, perhaps saying
note: to disable this warning, consider using `_x` or `_` instead
Barring that, the lint could have an error code and the error explanation could mention that you can disable the warning in either of these ways.
I'm not sure if this note should only be displayed with for
loops (and similar situations), or if it should be unconditionally displayed alongside the "unused variable" warning.