You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lint unnecessary safety comments
changelog: [`unnecessary_safety_comment`]: Add unnecessary safety comment lint
Addresses #7954
This does not necessarily catch all occurences, as doing so would require checking all expressions in the entire source which seems rather expensive. Instead what the lint does is it checks items, statements and the tail expression of blocks for safety comments, then checks if those comments are necessary or not, then linting for the unnecessary ones.
I kept the tests in one file to check that the lints do not clash with each other.
ojeda
changed the title
New lint: reverse of undocumented_unsafe_blocks
New lint (unnecessary_safety_comment): reverse of undocumented_unsafe_blocksJul 24, 2024
What it does
Warns about unexpected
// SAFETY:
comments (i.e. the reverse of theundocumented_unsafe_blocks
lint).This lint is similar to #6880, which is requesting the reverse of
missing_safety_docs
.Drawbacks
A project might also be using
// SAFETY:
comments to explain why safe code makes other unsafe code sound, e.g. within the module.Potential false positives in general (depending on how it is implemented).
Example
Could be written as:
The text was updated successfully, but these errors were encountered: