Skip to content

Conversation

dgulotta
Copy link
Contributor

@dgulotta dgulotta commented Mar 18, 2025

This fixes an issue where clippy suggests passing a function that takes no arguments as the first argument of Result::map_or_else. The function needs to take one argument. Example that triggers the issue: Playground link

Fixes #10335.

changelog: [option_if_let_else]: fix incorrect suggestion when the contents of an Err variant are ignored

@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2025

r? @Manishearth

rustbot has assigned @Manishearth.
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 Mar 18, 2025
Copy link
Member

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. Since the issue had been closed and not reopened, this apparently flew under the radard.

Can you add a "Fixes #10335" in the PR description and squash your 3 commits into one?

LL + })
|

error: use Option::map_or_else instead of an if let/else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: this lint says Option, and has Option in its name, we should probably not be linting here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we already lint on Result here.

Tbh I'm not convinced of the value of this lint overall, we should probably have a team discussion about it, but separately to that we shoudl figure out if it should also handle Result in the same lint (and if so, it needs to be updated)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a separate issue from fixing what currently exists.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zulip thead started here.

@rustbot

This comment has been minimized.

@Jarcho
Copy link
Contributor

Jarcho commented Sep 17, 2025

Ping @dgulotta from triage. Can you rebase this please.

@rustbot
Copy link
Collaborator

rustbot commented Sep 18, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Manishearth Manishearth added this pull request to the merge queue Sep 18, 2025
Merged via the queue into rust-lang:master with commit e1130b6 Sep 18, 2025
8 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

option_if_let_else generates wrong suggestion for Results
5 participants