11error[E0500]: closure requires unique access to `x` but it is already borrowed
2- --> $DIR/borrowck-closures-unique.rs:34 :14
2+ --> $DIR/borrowck-closures-unique.rs:36 :14
33 |
44LL | let c1 = || get(x);
55 | -- - previous borrow occurs due to use of `x` in closure
@@ -9,11 +9,12 @@ LL | let c2 = || set(x); //~ ERROR closure requires unique access to `x`
99 | ^^ - borrow occurs due to use of `x` in closure
1010 | |
1111 | closure construction occurs here
12+ LL | c1;
1213LL | }
1314 | - borrow ends here
1415
1516error[E0500]: closure requires unique access to `x` but it is already borrowed
16- --> $DIR/borrowck-closures-unique.rs:39 :14
17+ --> $DIR/borrowck-closures-unique.rs:42 :14
1718 |
1819LL | let c1 = || get(x);
1920 | -- - previous borrow occurs due to use of `x` in closure
@@ -23,11 +24,12 @@ LL | let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique acce
2324 | ^^ - borrow occurs due to use of `x` in closure
2425 | |
2526 | closure construction occurs here
27+ LL | c1;
2628LL | }
2729 | - borrow ends here
2830
2931error[E0524]: two closures require unique access to `x` at the same time
30- --> $DIR/borrowck-closures-unique.rs:44 :14
32+ --> $DIR/borrowck-closures-unique.rs:48 :14
3133 |
3234LL | let c1 = || set(x);
3335 | -- - previous borrow occurs due to use of `x` in closure
@@ -37,11 +39,22 @@ LL | let c2 = || set(x); //~ ERROR two closures require unique access to `x`
3739 | ^^ - borrow occurs due to use of `x` in closure
3840 | |
3941 | second closure is constructed here
42+ LL | c1;
4043LL | }
4144 | - borrow from first closure ends here
4245
4346error[E0595]: closure cannot assign to immutable argument `x`
44- --> $DIR/borrowck-closures-unique.rs:48:14
47+ --> $DIR/borrowck-closures-unique.rs:57:14
48+ |
49+ LL | let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument
50+ | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably
51+ help: consider removing the `&mut`, as it is an immutable binding to a mutable reference
52+ |
53+ LL | x //~ ERROR closure cannot assign to immutable argument
54+ | ^
55+
56+ error[E0595]: closure cannot assign to immutable argument `x`
57+ --> $DIR/borrowck-closures-unique.rs:62:14
4558 |
4659LL | let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable argument
4760 | ^^ cannot borrow mutably
@@ -50,7 +63,7 @@ help: consider removing the `&mut`, as it is an immutable binding to a mutable r
5063LL | x //~ ERROR closure cannot assign to immutable argument
5164 | ^
5265
53- error: aborting due to 4 previous errors
66+ error: aborting due to 5 previous errors
5467
5568Some errors occurred: E0500, E0524, E0595.
5669For more information about an error, try `rustc --explain E0500`.
0 commit comments