-
Notifications
You must be signed in to change notification settings - Fork 2k
collapsible_if suggestions are not safe #7965
Copy link
Copy link
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 haveS-fixedStatus: Issues that got fixed, waiting to be closed as completedStatus: Issues that got fixed, waiting to be closed as completed
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 haveS-fixedStatus: Issues that got fixed, waiting to be closed as completedStatus: Issues that got fixed, waiting to be closed as completed
Type
Fields
Give feedbackNo fields configured for issues without a type.
Consider this example of using a tokio watch channel. Clippy suggests to collapse the nested
ifblocks into this form.Following clippy's suggestion leads to a dead-lock. This is because
watch::Sender::borrow()locks the sender untils its return value goes out of scope. Having two separateifblocks, the lock is released before callingwatch::Sender::send()and everything is fine. Having both calls in one statement means one scope, so the lock is still there and blocks the second call.