-
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-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
When we have direct unwraps on an Option
or Result
like the following:
let val = Some(1).unwrap();
let val = Some(1).expect(...);
let val = Ok(1).unwrap();
let val = Err(1).unwrap_err();
let val = Ok(1).expect(...);
The lint remove the unnecessary unwrap/expect and unnecessary wraps from the above lines.
let val = 1;
let val = 1;
let val = 1;
let val = 1;
let val = 1;
Lint Name
unnecessary_unwrap
Reproducer
I tried this code:
let val = Some(1).unwrap();
I expected to see this happen:
let val = 1;
Instead, this happened:
Nothing changed.
Version
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't