Skip to content

Disable unused_must_use for statically known bool values #88017

@HKalbasi

Description

@HKalbasi

In this code (playground) compiler with warn is_prime(x) || continue; with unused logical operation that must be used. However, if we add a let temp = is_prime(x) || continue; the temp would be always true, if is_prime(x) is true it will be short-circuited with true, and otherwise it would be diverge and we will never see anything other than true. It is like warning unused_must_use on Result<(), !> which it is always Ok(()) and using it is pointless. So is it good to turn off this warning? Or current behavior is intended?

I see that this isn't a good code, but unused_must_use isn't a good warning for preventing that. Another warning (probably in clippy) can say that please don't abuse short circuit operators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions