12

Add undocumented_unsafe_blocks lint by Serial-ATA · Pull Request #7748 · rust-la...

 3 years ago
source link: https://github.com/rust-lang/rust-clippy/pull/7748
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Copy link

Contributor

Serial-ATA commented 20 days ago

edited

changelog: Added a new lint [undocumented_unsafe_blocks]

Fixes #7464, #7238 (?)

Copy link

Collaborator

rust-highfive commented 20 days ago

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @xFrednet (or someone else) soon.

Please see the contribution instructions for more information.

Copy link

Member

xFrednet commented 19 days ago

Welcome to the project, it's nice to see that you got a working implementation upside_down_face.

@flip1995 would you maybe like to review this, as you've also reviewed #7557? Otherwise, I'll have a look at it during the next week upside_down_face

Copy link

Member

flip1995 commented 19 days ago

Yes, sure. I have time this afternoon.

r? @flip1995

Copy link

Member

@flip1995 flip1995 left a comment

If I had to guess, I assume, that you didn't look at #7557 before implementing this?

I think your approach and the approach taken in #7557 combined would be ideal. I left comments about that below. IMO the work done in #7557 is really valuable. The PR was only closed, because it was inactive.

Copy link

Contributor

bors commented 18 days ago

umbrella The latest upstream changes (presumably #7709) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link

@ShadowJonathan ShadowJonathan left a comment •

edited

Thanks! Just missing one feature from the original suggestion in #7464;

The lint would also raise a warning if that comment is copied verbatim.

The following code would still raise a warning (not because of what transmute is doing here, but because the safety comment still has "...", as suggested. The developer would need to update it with an actual sentence.);

// Safety: ...
let totally_a_usize = unsafe {
    std::mem::transmute::<String, usize>(string)
};

Serial-ATA

changed the title Add undocumented_unsafe_block_safety lint

Add undocumented_unsafe_blocks lint

17 days ago

Copy link

Member

@flip1995 flip1995 left a comment

This PR should be almost done. I have some suggestions on how to simplify the code a bit.

The tests look awesome! The only test that is missing is a macro test. Two important tests here would be

  • unsafe block in the macro call: m!(unsafe{ ... }
  • unsafe block in the macro definition

Just for posterity; the behaviour that makes sure that "..." is also checked and errored on is removed, I think that's fine for now to get this PR through, but I'd still like to see it somewhere in the future

Copy link

Contributor

bors commented 15 days ago

umbrella The latest upstream changes (presumably #7773) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link

Member

flip1995 commented 15 days ago

One more thing that came to mind: What if the unsafe block has multi-line code in it? How does the suggestion look in that case? I expect that the full unsafe block is shown. We may want to avoid this, by using the span_until_char function ( or similar functions)

Copy link

Member

flip1995 commented 14 days ago

Looks great now! Could you address the multi-line unsafe block case? After that this should be good to go. rocket

Copy link

Contributor

Author

Serial-ATA commented 14 days ago

Did I not take care of that? The no_comment_match and internal_comment tests only show the first line now.

Copy link

Member

flip1995 commented 14 days ago

Did I not take care of that? The no_comment_match and internal_comment tests only show the first line now.

Oh I missed that. In that case all good +1

(no_comment_match doesn't test that, because the unsafe block is still empty and all on one line in this test case, but the other test case does)

Copy link

Member

flip1995 commented 14 days ago

Please squash some commits, so that we can merge this.

Copy link

Contributor

bors commented 14 days ago

umbrella The latest upstream changes (presumably #7705) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link

Member

flip1995 commented 13 days ago

edited

@bors r+

Thanks for sticking around through all the review iterations. Great work!

Copy link

Contributor

bors commented 13 days ago

pushpin Commit 412b862 has been approved by flip1995

Copy link

Contributor

bors commented 13 days ago

hourglass Testing commit 412b862 with merge 78e7312...

bors

merged commit 78e7312 into

rust-lang:master 13 days ago

8 checks passed

Serial-ATA

deleted the lint-undocumented-unsafe branch

13 days ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Assignees

flip1995

Projects

None yet

Milestone

No milestone

Linked issues

Successfully merging this pull request may close these issues.

6 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK