Skip to content

Check if if conditions always evaluate to true in never_loop #11005

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

Merged
merged 1 commit into from
Jun 26, 2023

Conversation

Centri3
Copy link
Member

@Centri3 Centri3 commented Jun 22, 2023

This fixes the example provided in #11004, but it shouldn't be closed as this is still an issue on like

let x = true;
if x { /* etc */ }`

This also makes clippy_utils::consts::constant handle ConstBlock and DropTemps.

changelog: [never_loop]: Check if if conditions always evaluate to true

@rustbot
Copy link
Collaborator

rustbot commented Jun 22, 2023

r? @giraffate

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 22, 2023
@blyxyas
Copy link
Member

blyxyas commented Jun 22, 2023

I'm amazed with the complexity of this lint, I feel like it could be so much simpler 😅.
Just checking if there's something before a return / break should be enough, right? Maybe I'm missing something important here.

@Centri3
Copy link
Member Author

Centri3 commented Jun 22, 2023

I suppose so, but then there's something like

if false {
	break 'a;
}
return;

You're basically switching a few FPs for a whole bunch of FNs, pick your poison I suppose. I think the current way is fine and only has its shortcomings here, with unevaluable conditions

@giraffate
Copy link
Contributor

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented Jun 26, 2023

📌 Commit 6a1084c has been approved by giraffate

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jun 26, 2023

⌛ Testing commit 6a1084c with merge 407bfd4...

@bors
Copy link
Contributor

bors commented Jun 26, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing 407bfd4 to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Jun 26, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing 407bfd4 to master...

@bors bors merged commit 407bfd4 into rust-lang:master Jun 26, 2023
@Centri3 Centri3 deleted the never_loop branch June 26, 2023 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants