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

fix: manual_unwrap_or_default suggests falsely when condition type is uncertain #13889

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

profetia
Copy link
Contributor

fixes #12670

Continuation of #12688. r? @Jarcho if you don't mind?

changelog: [manual_unwrap_or_default] fix wrong suggestions when condition type is uncertain

@rustbot
Copy link
Collaborator

rustbot commented Dec 28, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Jarcho (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 28, 2024
@profetia profetia force-pushed the issue12670 branch 2 times, most recently from ca507e7 to e6044a5 Compare December 28, 2024 16:57
@profetia
Copy link
Contributor Author

profetia commented Feb 4, 2025

r? clippy

@rustbot rustbot assigned llogiq and unassigned Jarcho Feb 4, 2025
MANUAL_UNWRAP_OR_DEFAULT,
expr.span,
format!("{expr_name} can be simplified with `.unwrap_or_default()`"),
format!("explicit the type {expr_type} and replace your expression with"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
format!("explicit the type {expr_type} and replace your expression with"),
format!("ascribe the type {expr_type} and replace your expression with"),

Or we could maybe even do a multispan suggestion using a empty span at the end of the let pattern, to be replaced with the type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@llogiq
Copy link
Contributor

llogiq commented Feb 4, 2025

Can you squash your commits, please?

@profetia
Copy link
Contributor Author

profetia commented Feb 5, 2025

Can you squash your commits, please?

squashed

@llogiq
Copy link
Contributor

llogiq commented Feb 5, 2025

Thank you!

@llogiq llogiq added this pull request to the merge queue Feb 5, 2025
Merged via the queue into rust-lang:master with commit e6d9641 Feb 5, 2025
11 checks passed
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.

manual_unwrap_or_default suggested fix fails to compile due to missing type annotation
4 participants