rust-lang / rust-lang/rust-clippy

New lint: casting &mut T to &mut MaybeUninit<T> and exposing it as safe

Open
#4,896 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint E-medium L-correctness
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

As discussed at several different places, the pattern of casting &mut T to &mut MaybeUninit<T> or &mut [T] to &mut [MaybeUninit<T>] and exposing it as safe is reoccurring (see bellow), so making Correctness lint would help.

IDK if there's any policy about clippy suggesting particular crates, but if this is allowed, maybe suggest possibly_uninit.

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

Begin by reviewing the linked Rust documentation issue, bytes issue, and uninit discussion to compare the recurring unsafe patterns. Then determine the scope of a Clippy correctness lint and whether it may suggest possibly_uninit; done means those casts are diagnosed with appropriate coverage.

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
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.