Skip to content

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

@svix-jplatte

Description

@svix-jplatte

The extract function assist fails to add parameters for bindings only used in let-eles to the generated function. Reproducer below (generated function should have x as a parameter, but has none).

rust-analyzer version: 0.4.2679-standalone
rustc version: 1.93.0-nightly (01867557c 2025-11-12)
editor or extension: VSCode
code snippet to reproduce:

fn foo() -> u32 {
    let x = 5;

    // extract this let-else branch into a new function
    let Some(y) = Some(1) else {
        return x * 2;
    };

    y
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions