Skip to content

borrow check doesn't distinguish different tuple elements in match expression #5362

@thestinger

Description

@thestinger
enum Foo {
    X, Y(uint, uint)
}

fn main() {
    // works
    let mut x = (1, 2);
    let (ref _k, ref mut _v) = x;

    // doesn't work
    let mut y = Y(1, 2);
    match y {
      Y(ref _v, ref mut _k) => {}

      // error: loan of enum content as mutable conflicts with prior loan
      // Y(ref _v, ref mut _k) => {}
      //           ^~~~~~~~~~~
      // note: prior loan as immutable granted here
      // Y(ref _v, ref mut _k) => {}
      //   ^~~~~~~

      X => ()
    }
}

Metadata

Metadata

Assignees

Labels

A-lifetimesArea: Lifetimes / regions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions