Skip to content
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

[missing_asserts_for_indexing]: work with bodies instead of blocks separately #11859

Merged
merged 1 commit into from Nov 24, 2023

Conversation

y21
Copy link
Member

@y21 y21 commented Nov 23, 2023

Fixes #11856

Before this change, this lint would check blocks independently of each other, which means that it misses assert!()s from parent blocks.

// check_block
assert!(x.len() > 1);

{
  // check_block
  // no assert here
  let _ = x[0] + x[1];
}

This PR changes it to work with bodies rather than individual blocks. That means that a function will be checked in one go and we can remember if an assert! occurred anywhere.

Eventually it would be nice to have a more control flow-aware analysis, possibly by rewriting it as a MIR lint, but that's more complicated and I wanted this fixed first.

changelog: [missing_asserts_for_indexing]: accept assert!s from parent blocks

@rustbot
Copy link
Collaborator

rustbot commented Nov 23, 2023

r? @blyxyas

(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 Nov 23, 2023
Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! ❤️

@blyxyas
Copy link
Member

blyxyas commented Nov 24, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 24, 2023

📌 Commit 553857b has been approved by blyxyas

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Nov 24, 2023

⌛ Testing commit 553857b with merge 96eab06...

@bors
Copy link
Collaborator

bors commented Nov 24, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: blyxyas
Pushing 96eab06 to master...

@bors bors merged commit 96eab06 into rust-lang:master Nov 24, 2023
5 checks passed
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.

missing_asserts_for_indexing fires for indexing inside if after assert!
4 participants