diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr index e8fae63a5d61..160a84c480cd 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr @@ -1,15 +1,32 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-closures-mut-of-imm.rs:23:21 + --> $DIR/borrowck-closures-mut-of-imm.rs:23:25 | -LL | let c1 = || set(&mut *x); - | ^^^^^^^ cannot borrow as mutable +LL | let mut c1 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-closures-mut-of-imm.rs:25:21 + --> $DIR/borrowck-closures-mut-of-imm.rs:25:25 | -LL | let c2 = || set(&mut *x); - | ^^^^^^^ cannot borrow as mutable +LL | let mut c2 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable -error: aborting due to 2 previous errors +error[E0524]: two closures require unique access to `x` at the same time + --> $DIR/borrowck-closures-mut-of-imm.rs:25:18 + | +LL | let mut c1 = || set(&mut *x); + | -- - first borrow occurs due to use of `x` in closure + | | + | first closure is constructed here +LL | //~^ ERROR cannot borrow +LL | let mut c2 = || set(&mut *x); + | ^^ - second borrow occurs due to use of `x` in closure + | | + | second closure is constructed here +... +LL | c2(); c1(); + | -- first borrow later used here -For more information about this error, try `rustc --explain E0596`. +error: aborting due to 3 previous errors + +Some errors occurred: E0524, E0596. +For more information about an error, try `rustc --explain E0524`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs index dc2f0e8395f0..3bf4f17fde1a 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs @@ -20,11 +20,12 @@ fn set(x: &mut isize) { } fn a(x: &isize) { - let c1 = || set(&mut *x); + let mut c1 = || set(&mut *x); //~^ ERROR cannot borrow - let c2 = || set(&mut *x); + let mut c2 = || set(&mut *x); //~^ ERROR cannot borrow //~| ERROR two closures require unique access to `x` at the same time + c2(); c1(); } fn main() { diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr index 87eb52b6aa60..c248595d5711 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr @@ -1,30 +1,30 @@ error[E0524]: two closures require unique access to `x` at the same time - --> $DIR/borrowck-closures-mut-of-imm.rs:25:14 + --> $DIR/borrowck-closures-mut-of-imm.rs:25:18 | -LL | let c1 = || set(&mut *x); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first closure is constructed here +LL | let mut c1 = || set(&mut *x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first closure is constructed here LL | //~^ ERROR cannot borrow -LL | let c2 = || set(&mut *x); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second closure is constructed here +LL | let mut c2 = || set(&mut *x); + | ^^ - borrow occurs due to use of `x` in closure + | | + | second closure is constructed here ... LL | } | - borrow from first closure ends here error[E0596]: cannot borrow immutable borrowed content `***x` as mutable - --> $DIR/borrowck-closures-mut-of-imm.rs:23:26 + --> $DIR/borrowck-closures-mut-of-imm.rs:23:30 | -LL | let c1 = || set(&mut *x); - | ^^ cannot borrow as mutable +LL | let mut c1 = || set(&mut *x); + | ^^ cannot borrow as mutable error[E0596]: cannot borrow immutable borrowed content `***x` as mutable - --> $DIR/borrowck-closures-mut-of-imm.rs:25:26 + --> $DIR/borrowck-closures-mut-of-imm.rs:25:30 | -LL | let c2 = || set(&mut *x); - | ^^ cannot borrow as mutable +LL | let mut c2 = || set(&mut *x); + | ^^ cannot borrow as mutable error: aborting due to 3 previous errors