-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[unnecessary_safety_comment
] Some fixes regarding comments above attributes
#15678
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
base: master
Are you sure you want to change the base?
Conversation
Lintcheck changes for 05d5c5d
This comment will be updated if you push new changes |
I checked all the removed/added lints and they all make sense to me
|
rustbot has assigned @samueltardieu. Use |
unnecessary_safety_comment
] Considering comments above attributes for itemsunnecessary_safety_comment
] Some fixes regarding comments above attributes
r? blyxyas Being that this is R4L-oriented, I'll give it priority |
We totally should! could you add that case? (It should be simple) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great patch, but I have one request.
It's a bit hard to distinguish why you're being prompted to remove a SAFETY
comment from an unsafe function without extra help. What about not linting when that SAFETY
comment comes from a doc-comment, as it will be rendered as useful information for consumers?
Also, if it's not a doc-comment, we can suggest to make it into a doc comment (/// # Safety
)
Some((start + (text.len() - trimmed.len()), trimmed)) | ||
}) | ||
.filter(|(_, text)| !text.is_empty()); | ||
.filter(|(_, text)| !(text.is_empty() || (accept_comment_above_attributes && is_attribute(text)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like how you managed to do a solution so elegant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I really appreciate it
- No longer using attr.span() - ignoring attributes manually
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Hey, thanks for the review! I tried to reach a (useful) middle grounds, if there's a
I modified what position is used for the lint, so I don't need to find the position of Anyways, I think this lint deserves a bigger refactor (I'd like to work on it, but have no time right now). #15755 and #clippy > broken lint: `undocumented_unsafe_blocks` Let me know what you think @rustbot ready |
☔ The latest upstream changes (possibly f3c020c) made this pull request unmergeable. Please resolve the merge conflicts. |
The way clippy checked for SAFETY comments above attributes was wrong:
This PR tries to fix this by delegating the skipping of attributes to the function analyzing the source code itself.
changelog: [
unnecessary_safety_comment
]: Taking into account comments above attributes for itemsFixes #14555
Fixes #15684
Fixes #15754