about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2018-11-05 15:25:11 +0100
committerFelix S. Klock II <pnkfelix@pnkfx.org>2018-11-05 15:26:02 +0100
commitc25319fcfc5046b91b773c87edbfdb087e875343 (patch)
tree0e62f2b82f29446e1d8187ea12ec7e812ae5e10b
parentfe29cd0a3d1ebff0d90f3e4ebc929f944863be4c (diff)
downloadrust-c25319fcfc5046b91b773c87edbfdb087e875343.tar.gz
rust-c25319fcfc5046b91b773c87edbfdb087e875343.zip
Update `ui/borrowck/borrowck-closures-mut-of-imm.rs` robust w.r.t. NLL.
-rw-r--r--src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr33
-rw-r--r--src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs5
-rw-r--r--src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr30
3 files changed, 43 insertions, 25 deletions
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 e8fae63a5d6..160a84c480c 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
+
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0596`.
+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 dc2f0e8395f..3bf4f17fde1 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 87eb52b6aa6..c248595d571 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