Skip to content

Disable unused_must_use for statically known bool values #88017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HKalbasi opened this issue Aug 13, 2021 · 2 comments
Closed

Disable unused_must_use for statically known bool values #88017

HKalbasi opened this issue Aug 13, 2021 · 2 comments

Comments

@HKalbasi
Copy link
Member

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.

@ecstatic-morse
Copy link
Contributor

Duplicate of #69466.

@Dylan-DPC
Copy link
Member

Closing as duplicate

@Dylan-DPC Dylan-DPC closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants