2019-04-22 08:40:08 +01:00
|
|
|
error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable
|
|
|
|
--> $DIR/borrowck-closures-use-after-free.rs:22:8
|
2018-08-08 14:28:26 +02:00
|
|
|
|
|
|
|
|
LL | let mut test = |foo: &Foo| {
|
|
|
|
| ----------- mutable borrow occurs here
|
2021-08-25 02:39:40 +02:00
|
|
|
LL | ptr = Box::new(Foo { x: ptr.x + 1 });
|
2021-03-17 02:51:27 -04:00
|
|
|
| --- first borrow occurs due to use of `ptr` in closure
|
2018-08-08 14:28:26 +02:00
|
|
|
LL | };
|
2019-03-09 15:03:44 +03:00
|
|
|
LL | test(&*ptr);
|
2019-04-22 08:40:08 +01:00
|
|
|
| ---- ^^^^^ immutable borrow occurs here
|
|
|
|
| |
|
|
|
|
| mutable borrow later used by call
|
2018-08-08 14:28:26 +02:00
|
|
|
|
|
|
|
error: aborting due to previous error
|
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0502`.
|