You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
warning: unused `std::slice::Iter` that must be used
--> src\main.rs:52:5
|
52 | vec.remove(0);| ^^^^^^^^^^^^^^
|
= note: iterators are lazy and do nothing unless consumed
Desired output
No warning when nothing is done to an iterator or similar when they are returned from a function with side effects.
If a warning is shown, it should be like this:
warning: unused return value.
You can use `let _ = vec.remove(0)` to signify that dropping it without usage is the intended behavior.
Rationale and extra context
rustc finds that remove returns an iterator.
Obviously I am not doing anything with it.
But the of the line is not to do something with the iterator, but to remove it from the list.
Activity
workingjubilee commentedon Mar 8, 2023
You may silence the warning with
let _ = vec.remove(0);workingjubilee commentedon Mar 8, 2023
This diagnostic should recommend that.
FlorianDyck commentedon Mar 8, 2023
In this case I think the output could be improved to:
warning: unused return value.
You can use "let _ = ..." to signify that dropping it without usage is the intended behavior.
Ezrashaw commentedon Mar 11, 2023
@rustbot claim
Rollup merge of rust-lang#109158 - Ezrashaw:expand-sugg-for-unused-li…