rust-lang / rust-lang/rust-clippy
New Lint: *mut used
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Now that NonNull is stable, I'd love to have a lint that warns when any type has *mut T as a field, or any function takes *mut T as an argument. The lint would recommend using NonNull<T> (or Option<NonNull<T>> if the pointer can be null).
Most of the times I've dealt with raw pointers, it's when dealing with a C FFI, and I often forget to add null checks. Switching to NonNull everywhere means that anywhere I cross a function/type boundary I've either done a null check, or opted out with unsafe code.
Since there are plenty of legitimate use cases for raw pointers where NonNull would just make things more painful, this lint should be allow by default.
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
No file, test, or entry point is named in the issue. Start by locating existing Clippy lints for raw pointers and their tests; done means an allow-by-default lint detects the described fields and arguments and recommends the appropriate NonNull form without flagging legitimate cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100