rust-lang / rust-lang/rust-clippy
Unsafe attributes support (`unnecessary_safety_comment`)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
Unsafe attributes have been stabilized (https://github.com/rust-lang/rust/pull/128771, https://github.com/rust-lang/rust/issues/123757), thus it would be nice to have a lint that ensures // SAFETY comments are not written for safe attributes.
Since unnecessary_safety_comment covers impls too, perhaps it should also cover this too, although it may be best to possibly split them (but that is a different issue).
See https://github.com/rust-lang/rust-clippy/issues/13316 as well.
Advantage
No response
Drawbacks
No response
Example
// SAFETY: ...
#[derive(Debug)]
struct S;
Should be written as:
#[derive(Debug)]
struct S;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing unnecessary_safety_comment lint and its tests in rust-clippy, then inspect how it handles impls and unsafe attributes. Add coverage for a safe attribute such as #[derive(Debug)] preceded by a // SAFETY comment, and verify that the lint accepts the version without the comment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100