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

show message with try block in map_unwrap_or #13245

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

Conversation

kyoto7250
Copy link
Contributor

close #13242

This PR fixes the issue where errors from map_unwrap_or were only partially displayed. When the error spans multiple lines, it needs to be shown in a block format.

changelog:
Corrected the error display for map_unwrap_or.

@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2024

r? @y21

rustbot has assigned @y21.
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 9, 2024
@kyoto7250 kyoto7250 marked this pull request as ready for review August 9, 2024 17:50
@y21
Copy link
Member

y21 commented Aug 10, 2024

I've thought about this for a bit and I'm unsure if this is something we should fix in clippy. This seems more like a bug in the compiler to me (presumably the emitter code that's responsible for rendering these), given that the spans and replacements are right and rustfix can apply the suggestion with no issue.

map_unwrap_or is not the only lint that is affected by this bug. It seems to happen to pretty much almost any lint that uses multipart_suggestion and an empty replacement on a separate line. E.g. redundant_guards: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=80efbab3a6429e898ec637c8d9c1efb8 (note how the suggestion doesn't actually have the guard removed)


I opened a zulip thread for this, to see what others think if it's worth working around this in clippy: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Verbose.20suggestion.20missing.20line.20deletions

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.

Incorrectly printed suggestion for map(<f>).unwrap_or(false) on multiple lines
3 participants