Skip to content

fix: reconstruct struct values after destructuring - #23380

Open
efegokdemir wants to merge 1 commit into
rust-lang:masterfrom
efegokdemir:fix-8673-reconstruct-struct
Open

efegokdemir wants to merge 1 commit into
rust-lang:masterfrom
efegokdemir:fix-8673-reconstruct-struct

Conversation

@efegokdemir

@efegokdemir efegokdemir commented Sep 17, 2026

Copy link
Copy Markdown

Summary

This PR updates destructure_struct_binding to reconstruct the original struct when it's used after destructuring, rather than replacing those usages with todo!().

The change works for both record and tuple structs. It also handles field name conflicts and preserves the existing fallback for unsupported cases, including references, private fields, and certain borrowing scenarios.

I added regression tests for reconstruction, method calls, name collisions, and fallback behaviour.

This addresses part of #8673. Combining the tuple and struct assists and handling the remaining reconstruction cases are still out of scope.

Testing

  • 36 targeted tests passed.
  • 2,827 ide-assists tests passed (3 ignored).
  • Formatting and Clippy checks passed.

AI assistance

I used ChatGPT extensively while working on the implementation and regression tests.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 17, 2026
@ChayimFriedman2

Copy link
Copy Markdown
Contributor

Please read and follow our AI policy.

@efegokdemir

Copy link
Copy Markdown
Author

Please read and follow our AI policy.

I opened this PR manually, though AI handled much of the implementation. Is there anything I need to change or do for this PR to comply with your AI policy?

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

I don't know, but:

  • Review the code thoroughly like the policy requires (understanding is not enough, you need to be able to write it yourself).
  • Not write the PR description with AI, if you did.

@efegokdemir

Copy link
Copy Markdown
Author

I used AI to help polish the wording and formatting of the PR description. I wasn't trying to hide that. If this doesn't align with your policy, I'm happy to close the PR rather than take up more of your time.

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

It indeed does not align with the policy, but closing is not needed. You can just revert to the version without AI editing.

@efegokdemir

Copy link
Copy Markdown
Author

I've rewritten the PR description myself. Thanks for clarifying.

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.

3 participants