Closure capture borrow diagnostics for disjoint captures
This commit is contained in:
parent
6e2a34474b
commit
08c4fbcea7
56 changed files with 532 additions and 152 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue