Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary direct unwraps on Option and Result are not warned/fixed #10352

Closed
pksunkara opened this issue Feb 16, 2023 · 1 comment · Fixed by #10358
Closed

Unnecessary direct unwraps on Option and Result are not warned/fixed #10352

pksunkara opened this issue Feb 16, 2023 · 1 comment · Fixed by #10358
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@pksunkara
Copy link
Contributor

pksunkara commented Feb 16, 2023

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

@pksunkara pksunkara added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Feb 16, 2023
@pksunkara
Copy link
Contributor Author

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant