Skip to content

collapsible_if suggestions are not safe #7965

Open
@jonnius

Description

@jonnius

Consider this example of using a tokio watch channel. Clippy suggests to collapse the nested if blocks 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 separate if blocks, the lock is released before calling watch::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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.I-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions