Skip to content

fix: use ExprIsRead::Yes for rhs of ordinary assignments#21649

Merged
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
Albab-Hasan:fix/assignment-rhs-never-coercion
Feb 15, 2026
Merged

fix: use ExprIsRead::Yes for rhs of ordinary assignments#21649
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
Albab-Hasan:fix/assignment-rhs-never-coercion

Conversation

@Albab-Hasan
Copy link
Contributor

the rhs of an ordinary assignment x = *never_ptr was inferred with ExprIsRead::No, which prevented NeverToAny coercion for place expressions of type !. this caused false type mismatches and missing divergence detection. the destructuring assignment path and let binding path both correctly use ExprIsRead::Yes for the rhs value, since the value is always consumed (read). this makes the ordinary assignment path consistent with both.

the rhs of an ordinary assignment `x = *never_ptr` was inferred with
`ExprIsRead::No`, which prevented `NeverToAny` coercion for place
expressions of type `!`. this caused false type mismatches and missing
divergence detection. the destructuring assignment path and let binding
path both correctly use `ExprIsRead::Yes` for the rhs value, since the
value is always consumed (read). this makes the ordinary assignment path
consistent with both.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 15, 2026
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

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

True, the RHS of an assignment does constitute read (the LHS does not).

Thanks!

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Feb 15, 2026
Merged via the queue into rust-lang:master with commit 4d29f32 Feb 15, 2026
16 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 15, 2026
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.

3 participants