-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.I-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveT-middleType: Probably requires verifiying typesType: Probably requires verifiying types
Description
Clippy will suggest to iterate over the supplied value without regards to borrowing. For example,
while let Some(foo) = self.iter.next() { .. }
will lead clippy to produce the following suggestion:
for foo in self.iter { .. }
wich would move iter
out of self
, which is clearly not what we want. The correct suggestion would be:
for foo in &self.iter { .. }
But only if &self.iter : Iterator<_>
. Otherwise the whole lint is wrong, and the while let
loop should be left alone.
lilydjwg and shaleh
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.I-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveT-middleType: Probably requires verifiying typesType: Probably requires verifiying types