-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Summary
See code below
Lint Name
manual_unwrap_or_default
Reproducer
I tried this code:
fn main() {
let x = Some((1, 2));
let y = if let Some((a, _)) = x {
a
} else {
0
};
println!("{y}");
}
I saw this happen:
warning: if let can be simplified with `.unwrap_or_default()`
--> src/main.rs:3:13
|
3 | let y = if let Some((a, _)) = x {
| _____________^
4 | | a
5 | | } else {
6 | | 0
7 | | };
| |_____^ help: replace it with: `x.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 default
I expected to see this happen: [nothing]
Version
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
Additional Labels
@rustbot label +I-suggestion-causes-error
dj8yfo
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 haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
GuillaumeGomez commentedon Jun 19, 2024
Taking a look.
manual_unwrap_or_default
#12961manual_unwrap_or_default
invalid suggestion on macro expanded code #12967Auto merge of #12961 - GuillaumeGomez:fix-manual_unwrap_or_default, r…
manual_unwrap_or_default
triggered for tuple unpacked with_
#12994manual_unwrap_or_default
false positive with a nested pattern #13031