Skip to content

Add ide-assists: merge let statements #19777

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

A4-Tacks
Copy link
Contributor

@A4-Tacks A4-Tacks commented May 11, 2025

Close #10651

Assist: merge_let_stmts

Merge multiple lets into a let tuple pattern, allowing for the use of multiple identical let-else.

fn main() {
    $0let a = 2;
    let b = 3;$0
}

->

fn main() {
    let (a, b) = (2, 3);
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 11, 2025
@rustbot

This comment has been minimized.

@A4-Tacks A4-Tacks changed the title feat: ide-assists, merge let statements Add ide-assists: merge let statements Jun 2, 2025
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

I am not sure how useful this assist really is. It seems very niche, but given its self-contained (and thus could easily enough be removed again if we decide to) it's probably fine to merge for now. Thoughs? @rust-lang/rust-analyzer

@Veykril
Copy link
Member

Veykril commented Jun 2, 2025

Thinking about this a bit more, I really don't see the usefulness in this. I am not quite sure why you'd want to turn multiple let statements into a single one that just does destructuring on the left, and merging via a tuple expression on the right. That seems like a net readability downgrade to me.

@A4-Tacks
Copy link
Contributor Author

A4-Tacks commented Jun 2, 2025

For related simple assignments, in single let statement may be more readable

Such as let (x, y) = (10, 5);

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.

Combining let statements into a pattern
3 participants