New lint (unnecessary_safety_comment
): reverse of undocumented_unsafe_blocks
· Issue #7954 · rust-lang/rust-clippy (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
What it does
Warns about unexpected // SAFETY:
comments (i.e. the reverse of the undocumented_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
// SAFETY: x
is Some
.
x.unwrap()
Could be written as: