-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Lint request: Safety comment on safe code #6880
Comments
Do you mean the |
No: the reverse. A safety doc was left on code that was not marked unsafe, implying that there were UB implications to using it incorrectly. This is dangerous because safe code should not cause UB, even indirectly by violating unsafe code's assumptions in complex ways. |
This is a good idea; in fact, possibly for both The description is unclear which one it is referring to, though (it says " |
My apologies. I meant the latter, but I suspect both would be useful. |
No need to apologize! And thanks for this idea and opening this issue. I have opened another one for the former, then: #7954. |
What it does
Warns when a SAFETY comment is left on a safe function, trait etc.
What is the advantage of the recommended code over the original code
Avoids users accidentally using unsafe code in an inappropriate fashion because it's marked safe.
Drawbacks
Won't work on normal comments, see #4828.
Example
Should be written as:
Here's an example of where this slipped through into real code.
The text was updated successfully, but these errors were encountered: