4

Fix invalid suggestion for mismatched types in closure arguments by Urgau · Pull...

 9 months ago
source link: https://github.com/rust-lang/rust/pull/114256
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Conversation

Contributor

This PR fixes the invalid suggestion for mismatched types in closure arguments.

The invalid suggestion came from a wrongly created span in the parser for closure arguments that don't have a type specified. Specifically, the span in this case was the last token span, but in the case of tuples, the span represented the last parenthesis instead of the whole tuple, which is fixed by taking the more accurate span of the pattern.

There is one unfortunate downside of this fix, it worsens even more the diagnostic for mismatched types in closure args without an explicit type. This happens because there is no correct span for implied inferred type. I tried also fixing this but it's a rabbit hole.

Fixes #114180

mark-i-m reacted with heart emoji

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK