Skip to content

Why doesn't let (&x, &y) = &(t, t,) work? #71730

Closed as not planned
Closed as not planned
@crlf0710

Description

@crlf0710

I'm not sure whether this is a bug or not, feel free to close if it's not.
I tried this code:

fn foo1() {
    let c = 1i32;
    let &x = &c;
}

fn foo2() {
    let c = (1i32, 2i32);
    let (&x, &y) = &c;
}

I expected to see this happen: Everything compiles fine, since components of the tuple are all Copy.

Instead, this happened: The second case fails with bad diagnostics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions