diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-10-14 13:39:17 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-10-15 13:37:50 -0700 |
| commit | 2a1aa9fb5356dc43e649b86622bd12463722d2af (patch) | |
| tree | 9a1a6c0263b6e5e0e600ccef00079ddc43927f08 /src/test | |
| parent | 0643466f85a765bbd0d7ec14a96e0980795aebec (diff) | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs new file mode 100644 index 00000000000..54048ed2fd8 --- /dev/null +++ b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs @@ -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() {} |
