-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.