Skip to content

Commit 9843a38

Browse files
committed
Make ui/borrowck/borrowck-unboxed-closures.rs robust w.r.t. NLL.
1 parent 6c7d82e commit 9843a38

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
2+
--> $DIR/borrowck-unboxed-closures.rs:13:5
3+
|
4+
LL | let g = &mut f;
5+
| ------ mutable borrow occurs here
6+
LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable
7+
| ^ immutable borrow occurs here
8+
LL | use_mut(g);
9+
| - mutable borrow later used here
10+
111
error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
212
--> $DIR/borrowck-unboxed-closures.rs:17:5
313
|
@@ -16,7 +26,7 @@ LL | f(1, 2); //~ ERROR use of moved value
1626
|
1727
= note: move occurs because `f` has type `F`, which does not implement the `Copy` trait
1828

19-
error: aborting due to 2 previous errors
29+
error: aborting due to 3 previous errors
2030

21-
Some errors occurred: E0382, E0596.
31+
Some errors occurred: E0382, E0502, E0596.
2232
For more information about an error, try `rustc --explain E0382`.

src/test/ui/borrowck/borrowck-unboxed-closures.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
fn a<F:Fn(isize, isize) -> isize>(mut f: F) {
1212
let g = &mut f;
1313
f(1, 2); //~ ERROR cannot borrow `f` as immutable
14+
use_mut(g);
1415
}
15-
1616
fn b<F:FnMut(isize, isize) -> isize>(f: F) {
1717
f(1, 2); //~ ERROR cannot borrow immutable argument
1818
}
@@ -23,3 +23,5 @@ fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
2323
}
2424

2525
fn main() {}
26+
27+
fn use_mut<T>(_: &mut T) { }

src/test/ui/borrowck/borrowck-unboxed-closures.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let g = &mut f;
55
| - mutable borrow occurs here
66
LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable
77
| ^ immutable borrow occurs here
8+
LL | use_mut(g);
89
LL | }
910
| - mutable borrow ends here
1011

0 commit comments

Comments
 (0)