error[E0505]: cannot move out of `instance` because it is borrowed
--> src/fail_tests/use_moved_ref_after_free.rs:18:10
|
11 | let instance = BoxAndRefBuilder {
| -------- binding `instance` declared here
...
17 | instance.with_data_ref(|dref| stored_ref = Some(*dref));
| -------- borrow of `instance` occurs here
18 | drop(instance);
| ^^^^^^^^ move out of `instance` occurs here
19 | println!("{:?}", stored_ref);
| ---------- borrow later used here
|
note: if `BoxAndRef` implemented `Clone`, you could clone the value
--> src/fail_tests/use_moved_ref_after_free.rs:3:1
|
3 | #[self_referencing]
| ^^^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
...
17 | instance.with_data_ref(|dref| stored_ref = Some(*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)