Closed
Description
Code
fn main() {
let mut vec = vec![[0].iter(), [1].iter()];
vec.remove(0);
}
Current output
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.
Other cases
No response
Anything else?
No response