rust-lang / rust-lang/rust-clippy
`manual_unwrap_or` is not showing for simple ref cases
Open
Nobody has claimed this yet.
C-bug
I-false-negative
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
This case is not detected. I suspect this is due to the initial fix for #7228 (?).
Lint Name
manual_unwrap_or
Reproducer
I tried this code:
fn test_func(val: Option<&str>) -> String {
let s = match val {
None => "",
Some(v) => v,
};
s.to_string()
}
I expected to see this happen: a warning to simplify the match statement to use unwrap_or
Instead, this happened: no warnings
Version
rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.73.0
LLVM version: 17.0.2
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
Start by locating the manual_unwrap_or lint and reproduce the Rust example from this issue. Check why the simple Option<&str> match is not recognized, then add coverage for the example and verify that Clippy emits the expected unwrap_or warning.
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
- Mostly clear
- Newbie friendliness
- 45/100