Check whether loans conflict with old loans or with themselves.

Along the way, convert from dvec-of-dvec representation to track loans in scope
to just a single flattened list.  It's more convenient.

Fixes #3765. r+ pcwalton.
This commit is contained in:
Niko Matsakis 2012-10-14 13:39:17 -07:00
parent 0643466f85
commit 2a1aa9fb53
5 changed files with 164 additions and 93 deletions

View file

@ -0,0 +1,25 @@
use core::either::{Either, Left, Right};
fn f(x: &mut Either<int,float>, y: &Either<int,float>) -> int {
match *y {
Left(ref z) => {
*x = Right(1.0);
*z
}
_ => fail
}
}
fn g() {
let mut x: Either<int,float> = Left(3);
io::println(f(&mut x, &x).to_str()); //~ ERROR conflicts with prior loan
}
fn h() {
let mut x: Either<int,float> = Left(3);
let y: &Either<int, float> = &x;
let z: &mut Either<int, float> = &mut x; //~ ERROR conflicts with prior loan
*z = *y;
}
fn main() {}