Skip to content

Rewrite unwrap_in_result lint #15445

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samueltardieu
Copy link
Member

@samueltardieu samueltardieu commented Aug 8, 2025

  • Lint non-impl functions as well.
  • Lint function calls in addition to method calls (such as Option::unwrap(…)).
  • Put the lint on the unwrap and expect node instead of the function signature. This lets the user #[allow] specific unwrap() or expect() calls.
  • Do not lint inside closures, const and static.
  • Do not mix warnings about Option and Result.

changelog: [unwrap_in_result]: issue lint on .unwrap() and .expect() nodes instead of the function one
changelog: [unwrap_in_result]: also lint in functions outside implementation blocks
changelog: [unwrap_in_result]: do not mix Result and Option

Fixes #15439

@rustbot
Copy link
Collaborator

rustbot commented Aug 8, 2025

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 8, 2025
- Lint non-`impl` functions as well.
- Lint function calls in addition to method calls (such as
  `Option::unwrap(…)`).
- Put the lint on the `unwrap` and `expect` node instead of the function
  signature. This lets the user `#[allow]` specific `unwrap()` or
  `expect()` calls.
- Do not lint inside closures, `const` and `static`.
- Do not mix warnings about `Option` and `Result`.
Copy link

github-actions bot commented Aug 8, 2025

Lintcheck changes for 500f1e4

Lint Added Removed Changed
clippy::unwrap_in_result 267 409 0

This comment will be updated if you push new changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow specific unwraps with unwrap_in_result
3 participants