Skip to content

Conversation

dianne
Copy link
Contributor

@dianne dianne commented Sep 4, 2025

Pursuant to rust-lang/rust#145838 (comment), I've added a note and some examples detailing how destructuring assignment expressions effectively introduce two scopes for its temporaries, whereas basic assignment expressions don't introduce any.

I've included it alongside the description of destructuring assignment desugaring, but I could see it being at home in the destructors chapter as well. I also considered adding the assigned value operand of a destructuring assignment operand to the list of temporary scopes, but it's a bit more complicated than that since it has two scopes, so I figured it would be simplest to talk directly in terms of the desugaring, where the two scopes are visible.

I've used borrowck errors to demonstrate scoping in the tests since the test scaffolding is much simpler in that case than for testing runtime drop order, but a runtime drop order comparison may help further illustrate it.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Sep 4, 2025
@dianne dianne force-pushed the destructuring-temp-scope branch from 2188e67 to 13cf2f3 Compare September 4, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: The marked PR is awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants