rust-lang / rust-lang/rust-clippy

needless option take improvement

Open
#8,740 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What it does

The lint already exists but it needs an improvement in the way it detects temporaries :
Currently, it matches a DefId against &["core", "option", "Option", "as_ref"], while this works, this can give false negatives on temporary bindings.
The way we want that to work instead is described here : https://github.com/rust-lang/rust-clippy/pull/8665#issuecomment-1103939951

Upstream PR introducing the initial lint : https://github.com/rust-lang/rust-clippy/pull/8665

Lint Name

needless_option_take

Category

complexity

Advantage

No response

Drawbacks

No response

Example
<code>

Could be written as:

<code>

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

Start with the existing needless_option_take lint and read the linked rust-clippy#8665 discussion, especially the referenced comment describing temporary bindings. Update the detection behavior to avoid the stated false negatives, and verify that the lint handles the cases defined there without changing its intended purpose.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.