rust-lang / rust-lang/rust-clippy

Lint code that "indexes" generic pointers but doesn't special-case zero-sized types

Open
#2,260 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint C-an-interesting-project E-hard T-middle T-MIR
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.