Skip to content

Conversation

@dfireBird
Copy link
Contributor

@dfireBird dfireBird commented Dec 13, 2025

fixes: #21039

@dfireBird dfireBird marked this pull request as ready for review December 13, 2025 19:03
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 13, 2025
fix: consider let-else expr for return control type
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.

One thing: due to destructuring assignments, patterns can also refer to variables (Pat::Path). So you need to account for that.

@dfireBird
Copy link
Contributor Author

Just to confirm, you mean for something like this right?

fn foo() {
    let mut a = 3;
    let mut b = 4;

     $0(a, b) = bar(1, 3);
    (a, b) = bar(5, 7);$0
}

fn bar(y: u32, z: u32) -> (u32, u32) {
}

@ChayimFriedman2
Copy link
Contributor

Yeah, exactly.

fix: assign mutable for variables in pattern destructing assignments
@dfireBird
Copy link
Contributor Author

dfireBird commented Dec 15, 2025

Thanks for confirming. I didn't knew this existed :(

While doing that I found an issue, where variables inside pattern destructing assignments are not marked mutable in the generate function, so I made a fix for that as well.

EDIT: Should I squash the two commits like I did before, just before merging? Please let me know?

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.

Thanks!

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Dec 15, 2025
Merged via the queue into rust-lang:master with commit 3f37e42 Dec 15, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 15, 2025
@dfireBird dfireBird deleted the hir-locals-used branch December 15, 2025 14:46
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.

Extract function assist misses bindings only used in the else branch of let-else

3 participants