Skip to content

Add multiple_unsafe_ops_per_block lint #10206

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
Jan 19, 2023

Conversation

Niki4tap
Copy link
Contributor

@Niki4tap Niki4tap commented Jan 16, 2023

Adds a lint, which restricts an unsafe block to only one unsafe operation.

Closes #10064


changelog: New lint: [multiple_unsafe_ops_per_block]
#10206

@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2023

r? @Alexendoo

(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 Jan 16, 2023
@Niki4tap
Copy link
Contributor Author

@rustbot label: +A-lint, +L-restriction

@rustbot rustbot added A-lint Area: New lints L-restriction Lint: Belongs in the restriction lint group labels Jan 16, 2023
Copy link
Member

@Alexendoo Alexendoo left a comment

Choose a reason for hiding this comment

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

👋

Thanks for the PR! It's looking good

@Niki4tap Niki4tap force-pushed the one_unsafe_op_per_block branch from bb5cfee to 6d6d5a4 Compare January 17, 2023 15:05
@Niki4tap Niki4tap changed the title Add one_unsafe_op_per_block lint Add multiple_unsafe_ops_per_block lint Jan 17, 2023
@Niki4tap
Copy link
Contributor Author

Thanks for the review, @Alexendoo! I've addressed the comments, can you review it again please?

) {
let expr = expr.peel_drop_temps();

for_each_expr_with_closures(cx, expr, |expr| {
Copy link
Member

Choose a reason for hiding this comment

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

You can pass the Block in here directly, letting you remove the collect_block function

Suggested change
for_each_expr_with_closures(cx, expr, |expr| {
for_each_expr_with_closures(cx, block, |expr| {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't take Block directly here, as I still have one recursive call at the bottom, but I figured I can take impl Visitable, so that works. Thanks for the comment!

@Niki4tap Niki4tap force-pushed the one_unsafe_op_per_block branch from 6d6d5a4 to 875e36f Compare January 18, 2023 07:00
@Niki4tap Niki4tap requested a review from Alexendoo January 18, 2023 12:17
@Niki4tap
Copy link
Contributor Author

@Alexendoo can you look again please? I think it should be good now

@Alexendoo
Copy link
Member

Yep looks great thanks

@bors r+

@bors
Copy link
Contributor

bors commented Jan 19, 2023

📌 Commit 875e36f has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 19, 2023

⌛ Testing commit 875e36f with merge aa0eb7f...

@bors
Copy link
Contributor

bors commented Jan 19, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing aa0eb7f to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints L-restriction Lint: Belongs in the restriction lint group 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.

New lint: Limit unsafe blocks to a single unsafe operation
4 participants