error[E0505]: cannot move out of `instance` because it is borrowed
--> src/fail_tests/use_after_free.rs:17:10
|
11 | let instance = BoxAndRefBuilder {
| -------- binding `instance` declared here
...
16 | let data_ref = instance.with_data_ref(|dref| *dref);
| -------- borrow of `instance` occurs here
17 | drop(instance);
| ^^^^^^^^ move out of `instance` occurs here
18 | println!("{:?}", data_ref);
| -------- borrow later used here
|
note: if `BoxAndRef` implemented `Clone`, you could clone the value
--> src/fail_tests/use_after_free.rs:3:1
|
3 | #[self_referencing]
| ^^^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
...
16 | let data_ref = instance.with_data_ref(|dref| *dref);
| -------- you could clone this value
= note: this error originates in the attribute macro `self_referencing` (in Nightly builds, run with -Z macro-backtrace for more info)