Skip to content

fix: Fix diverging destructuring assignments #20179

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

Merged

Conversation

ChayimFriedman2
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 commented Jul 5, 2025

They need to return !, unlike diverging ordinary assignments. See the comment in the code.

Fixes #20176.

They need to return `!`, unlike diverging ordinary assignments. See the comment in the code.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 5, 2025
Comment on lines +774 to +777
// Ordinary assignments always return `()`, even when they diverge.
// However, rustc lowers destructuring assignments into blocks, and blocks return `!` if they have no tail
// expression and they diverge. Therefore, we have to do the same here, even though we don't lower destructuring
// assignments into blocks.
Copy link
Member

Choose a reason for hiding this comment

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

Huh, I wonder if that was an intended side effect in rustc.

@Veykril Veykril added this pull request to the merge queue Jul 6, 2025
Merged via the queue into rust-lang:master with commit ef3e52b Jul 6, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2025
@ChayimFriedman2 ChayimFriedman2 deleted the destructuring-assignment-never branch July 6, 2025 09:24
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.

rust-analyzer infers incorrect type when using _ = expr
3 participants