Suggest .clone() when moved while borrowed

This commit is contained in:
Esteban Küber 2024-03-13 01:51:08 +00:00
parent ccae456863
commit fa2fc3ab96
29 changed files with 246 additions and 19 deletions

View file

@ -10,6 +10,11 @@ LL | let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
LL | _x1 = U;
LL | drop(hold_all);
| -------- borrow later used here
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let hold_all = &arr.clone();
| ++++++++
error[E0384]: cannot assign twice to immutable variable `_x1`
--> $DIR/borrowck-move-ref-pattern.rs:9:5