Closure capture borrow diagnostics for disjoint captures

This commit is contained in:
Chris Pardy 2021-03-17 02:51:27 -04:00
parent 6e2a34474b
commit 08c4fbcea7
56 changed files with 532 additions and 152 deletions

View file

@ -5,7 +5,7 @@ LL | let mut test = |foo: &Foo| {
| ----------- mutable borrow occurs here
LL | println!("access {}", foo.x);
LL | ptr = box Foo { x: ptr.x + 1 };
| --- first borrow occurs due to use of `ptr` in closure
| --- first borrow occurs due to use of `ptr` in closure
...
LL | test(&*ptr);
| ---- ^^^^^ immutable borrow occurs here

View file

@ -5,7 +5,7 @@ LL | match x {
| - value is immutable in match guard
...
LL | (|| { *x = None; drop(force_fn_once); })();
| ^^ - borrow occurs due to use of `x` in closure
| ^^ -- borrow occurs due to use of `x` in closure
| |
| cannot mutably borrow

View file

@ -5,7 +5,7 @@ LL | match **x {
| --- value is immutable in match guard
...
LL | (|| { *x = &None; drop(force_fn_once); })();
| ^^ - borrow occurs due to use of `x` in closure
| ^^ -- borrow occurs due to use of `x` in closure
| |
| cannot mutably borrow

View file

@ -10,7 +10,7 @@ error[E0502]: cannot borrow `*x.1` as mutable because it is also borrowed as imm
--> $DIR/issue-61623.rs:6:19
|
LL | f2(|| x.0, f1(x.1))
| -- -- - ^^^ mutable borrow occurs here
| -- -- --- ^^^ mutable borrow occurs here
| | | |
| | | first borrow occurs due to use of `x` in closure
| | immutable borrow occurs here

View file

@ -2,7 +2,7 @@ error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/issue-6801.rs:19:13
|
LL | let sq = || { *x * *x };
| -- - borrow occurs due to use in closure
| -- -- borrow occurs due to use in closure
| |
| borrow of `x` occurs here
LL |