

Add undocumented_unsafe_blocks lint by Serial-ATA · Pull Request #7748 · rust-la...
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.

Conversation
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.
Yes, sure. I have time this afternoon.
r? @flip1995
The latest upstream changes (presumably #7709) made this pull request unmergeable. Please resolve the merge conflicts.
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) };
clippy_lints/src/undocumented_unsafe_blocks.rs
Outdated Show resolved
changed the title Add undocumented_unsafe_block_safety lint
Add undocumented_unsafe_blocks lint
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
The latest upstream changes (presumably #7773) made this pull request unmergeable. Please resolve the merge conflicts.
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)
Looks great now! Could you address the multi-line unsafe block case? After that this should be good to go.
Did I not take care of that? The no_comment_match
and internal_comment
tests only show the first line now.
Did I not take care of that? The
no_comment_match
andinternal_comment
tests only show the first line now.
Oh I missed that. In that case all good
(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)
Please squash some commits, so that we can merge this.
The latest upstream changes (presumably #7705) made this pull request unmergeable. Please resolve the merge conflicts.
@bors r+
Thanks for sticking around through all the review iterations. Great work!
Commit 412b862 has been approved by
flip1995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
No milestone
Successfully merging this pull request may close these issues.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK