about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2018-11-05 14:32:00 +0100
committerFelix S. Klock II <pnkfelix@pnkfx.org>2018-11-05 15:26:02 +0100
commit9843a38632dcf4f33325bbef57ef4a1e55c48d6d (patch)
tree89537ba53228af82574298ca452876f143a86831
parent6c7d82e1ca246e914e96beb1874a75f7306ac9dd (diff)
downloadrust-9843a38632dcf4f33325bbef57ef4a1e55c48d6d.tar.gz
rust-9843a38632dcf4f33325bbef57ef4a1e55c48d6d.zip
Make `ui/borrowck/borrowck-unboxed-closures.rs` robust w.r.t. NLL.
-rw-r--r--src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr14
-rw-r--r--src/test/ui/borrowck/borrowck-unboxed-closures.rs4
-rw-r--r--src/test/ui/borrowck/borrowck-unboxed-closures.stderr1
3 files changed, 16 insertions, 3 deletions
diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr
index 3fbb747db24..ee5ad58290e 100644
--- a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr
@@ -1,3 +1,13 @@
+error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
+  --> $DIR/borrowck-unboxed-closures.rs:13:5
+   |
+LL |     let g = &mut f;
+   |             ------ mutable borrow occurs here
+LL |     f(1, 2);    //~ ERROR cannot borrow `f` as immutable
+   |     ^ immutable borrow occurs here
+LL |     use_mut(g);
+   |             - mutable borrow later used here
+
 error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-unboxed-closures.rs:17:5
    |
@@ -16,7 +26,7 @@ LL |     f(1, 2);    //~ ERROR use of moved value
    |
    = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
-Some errors occurred: E0382, E0596.
+Some errors occurred: E0382, E0502, E0596.
 For more information about an error, try `rustc --explain E0382`.
diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.rs b/src/test/ui/borrowck/borrowck-unboxed-closures.rs
index 4813b4b6a72..43f143a492f 100644
--- a/src/test/ui/borrowck/borrowck-unboxed-closures.rs
+++ b/src/test/ui/borrowck/borrowck-unboxed-closures.rs
@@ -11,8 +11,8 @@
 fn a<F:Fn(isize, isize) -> isize>(mut f: F) {
     let g = &mut f;
     f(1, 2);    //~ ERROR cannot borrow `f` as immutable
+    use_mut(g);
 }
-
 fn b<F:FnMut(isize, isize) -> isize>(f: F) {
     f(1, 2);    //~ ERROR cannot borrow immutable argument
 }
@@ -23,3 +23,5 @@ fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
 }
 
 fn main() {}
+
+fn use_mut<T>(_: &mut T) { }
diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr
index 0c067c47004..6ee1a6245a5 100644
--- a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr
+++ b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr
@@ -5,6 +5,7 @@ LL |     let g = &mut f;
    |                  - mutable borrow occurs here
 LL |     f(1, 2);    //~ ERROR cannot borrow `f` as immutable
    |     ^ immutable borrow occurs here
+LL |     use_mut(g);
 LL | }
    | - mutable borrow ends here