rust-lang / rust-lang/rust-clippy

uninit_assumed_init lint does not recognize trivial misuse

Open
#4,765 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

uninit_assumed_init lint (see #4272) correctly recognizes the following anti-pattern:

unsafe { let mut x = MaybeUninit::<&i32>::uninit().assume_init(); }

However, it does not recognize a slightly altered version of it:

    let mut x = MaybeUninit::<&i32>::uninit();
    let x = unsafe { x.assume_init() };

Clippy version: clippy 0.0.212 (c8e3cfb 2019-10-28)

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

Reproduce the two Rust examples and inspect the uninit_assumed_init lint implementation introduced by #4272. Done means the lint recognizes both the direct and the separated assume_init forms without losing the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.