-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
fn returns_tuple() -> Option<(usize, usize)> {
todo!()
}
fn passes() -> usize {
match returns_tuple() {
Some((x, _z)) => x,
None => 0,
}
}
fn fails() -> usize {
match returns_tuple() {
Some((x, _)) => x,
None => 0,
}
}
fn main() {
passes();
fails();
} Checking playground v0.0.1 (/playground)
warning: match can be simplified with `.unwrap_or_default()`
--> src/main.rs:13:5
|
13 | / match returns_tuple() {
14 | | Some((x, _)) => x,
15 | | None => 0,
16 | | }
| |_____^ help: replace it with: `returns_tuple().unwrap_or_default()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
= note: `#[warn(clippy::manual_unwrap_or_default)]` on by defaultLint Name
manual_unwrap_or_default
Reproducer
I tried this code:
<code>I saw this happen:
<output>
I expected to see this happen:
Version
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: aarch64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have