-
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 thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be startedgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Clippy will suggest replacing
let x = mem::replace(&mut thing, Thing::default());
with:
let x = mem::take(&mut thing);
This is great! But it will also suggest replacing
mem::replace(&mut thing, Thing::default());
with:
mem::take(&mut thing);
This is not great. The construction using mem::replace
in the second case is much clearer IMO as it indicates that the function is being executed for its side effects. The construction using mem::take
looks like a mistake.
Would you folks be open to making the lint not apply in the second case?
Luro02
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be startedgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy