Skip to content

Inconsistency between destructuring assignment and pattern matching with tuples #5689

Description

@bstrie

This code fails to compile:

fn main() {
    let bar = ~(1,2);
    foo(bar);
}

fn foo<T,U>(x: &(T,U)) {
    let (ref a, ref b) = *x;  // error: moving out of dereference of immutable & pointer
}

...but this (seemingly) logically equivalent does compile:

fn main() {
    let bar = ~(1,2);
    foo(bar);
}

fn foo<T,U>(x: &(T,U)) {
    let (a, b) = match *x {
        (ref a, ref b) => (a, b)
    };
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions