-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add a lint to warn about un-necessary .into_iter() #1250
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
Conversation
@@ -577,6 +596,16 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) { | |||
object, | |||
method_name)); | |||
} | |||
} else if method_name.as_str() == "into_iter" && match_trait_method(cx, arg, &paths::I) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be INTO_ITERATOR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah miss commit.
@@ -87,7 +87,7 @@ impl Unrelated { | |||
} | |||
} | |||
|
|||
#[deny(needless_range_loop, explicit_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop)] | |||
#[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually just do #[deny(clippy)]
. I wonder why this file does not use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know for sure. Let me clean that up in a separate pr.
@@ -294,6 +294,10 @@ fn main() { | |||
for _v in vec.iter() { } //~ERROR it is more idiomatic to loop over `&vec` | |||
for _v in vec.iter_mut() { } //~ERROR it is more idiomatic to loop over `&mut vec` | |||
|
|||
|
|||
let mut _out_vec = vec![1,2,3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a leading _
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed. Let me remove it.
Thanks! |
This should close #1094.