Skip to content
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 suggestion: unsafe should require a // Safety comment #4828

Closed
Lucretiel opened this issue Nov 19, 2019 · 3 comments
Closed

Lint suggestion: unsafe should require a // Safety comment #4828

Lucretiel opened this issue Nov 19, 2019 · 3 comments

Comments

@Lucretiel
Copy link

I was pleased to see that there's a clippy lint for requiring a /// # Safety header in exposed unsafe methods; my suggestion is to go further and add a lint requiring safety commentary in all unsafe { } blocks.

@flip1995
Copy link
Member

Normal comments // can't be checked by Clippy, since they are handled by the lexer and don't appear in the AST. Clippy can only check for Doc comments ///. To lint this, Clippy would have to lex the code itself, which is something we really don't want to do (performance, code duplication, ...).

I'm closing this, since it is sadly not possible to accomplish. Sorry.

@Lucretiel
Copy link
Author

Ah :( sad to hear, but I understand.

@PatchMixolydic
Copy link
Contributor

An implementation for this seems to be in the works: #7557

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants