Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
thestinger opened this issue Mar 13, 2013 · 4 comments
Assignees
Labels
A-lifetimes Area: lifetime related
Milestone

Comments

@thestinger
Copy link
Contributor

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 => ()
    }
}
@ghost ghost assigned nikomatsakis Mar 13, 2013
@nikomatsakis
Copy link
Contributor

problem is that the mem_categorization structures don't consider the index into a tuple

@bstrie
Copy link
Contributor

bstrie commented May 6, 2013

Still reproduces, but try again once the new borrowck lands.

@nikomatsakis
Copy link
Contributor

This is not yet fixed, but it would be easy to do so. I was trying to avoid making the patch bigger than otherwise necessary.

@nikomatsakis
Copy link
Contributor

Fixed now.

oli-obk pushed a commit to oli-obk/rust that referenced this issue May 2, 2020
…lip1995

Do not lint in macros for match lints

Don't lint in macros for match lints, more precisely in `check_pat` and `check_local` where it was not the case.

changelog: none

fixes: rust-lang#5362
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: lifetime related
Projects
None yet
Development

No branches or pull requests

3 participants