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

Slice pattern incorrectly report double borrow #37302

Closed
Popog opened this issue Oct 20, 2016 · 2 comments
Closed

Slice pattern incorrectly report double borrow #37302

Popog opened this issue Oct 20, 2016 · 2 comments
Labels
A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. NLL-fixed-by-NLL Bugs fixed, but only when NLL is enabled.

Comments

@Popog
Copy link

Popog commented Oct 20, 2016

Seems you can work around issue by throwing enough &mut/& and * at the problem.

let mut v: [i32;2] = [1; 2];

let [ref mut _a, ref mut _b] = v; // Double borrow error
let [ref mut _a, ref mut _b] = *&mut v;
let &mut [ref mut _a, ref mut _b] = &mut v;

let rv = &mut v;
let &mut [ref mut _a, ref mut _b] = rv; // Double borrow error
let &mut [ref mut _a, ref mut _b] = &mut* rv;

let [ref mut _a, ref mut _b] = *rv; // Double borrow error
let [ref mut _a, ref mut _b] = *&mut *rv;

Value case has a similar issue that might be related (haven't found a workaround yet):

struct NoCopy;
let v: [NoCopy;2] = [NoCopy, NoCopy];
let [_a, _b] = v; // Value used after move
@Mark-Simulacrum Mark-Simulacrum added the A-borrow-checker Area: The borrow checker label May 15, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 26, 2017
@memoryruins
Copy link
Contributor

Triage: now compiles and runs on 2018 edition. 2015 errors.
rustc: 1.32.0

@memoryruins memoryruins added NLL-fixed-by-NLL Bugs fixed, but only when NLL is enabled. and removed NLL-fixed-by-NLL Bugs fixed, but only when NLL is enabled. labels Jan 30, 2019
@pnkfelix pnkfelix added the NLL-fixed-by-NLL Bugs fixed, but only when NLL is enabled. label Feb 27, 2019
@matthewjasper
Copy link
Contributor

Closing as this is now fixed on both editions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. NLL-fixed-by-NLL Bugs fixed, but only when NLL is enabled.
Projects
None yet
Development

No branches or pull requests

5 participants