rust-lang / rust-lang/rust-clippy
Lint code that "indexes" generic pointers but doesn't special-case zero-sized types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Basically, it'd be nice to have a lint which checks unsafe code dealing with pointers that indexes them (either by from_raw_parts(...) or *ptr.offset(...)) which doesn't specifically special-case zero-sized types.
This could probably simplified to checking that functions that perform said indexing don't contain any mentions of mem::size_of or similar.
The main idea is that this would lint custom data structures similar to Vec and co. that will not work with zero-sized types. Obviously not a lint that I'd expect to come up very often, but people working in embedded code might run into a problem like this and it's good to point it out and require an #[allow(...)] that acknowledges the risks.
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
The issue names no files, tests, or entry points. Start by clarifying the intended lint scope for unsafe pointer indexing and zero-sized types, including which patterns count as a special case. Done would mean a defined lint that identifies affected custom data structures and requires an explicit allow when the risk is intentional.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100