about summary refs log tree commit diff
path: root/tests/ui/error-codes
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-03-13 01:51:08 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-04-11 16:41:41 +0000
commitfa2fc3ab9638aec571574e551cd9708aa4b64280 (patch)
treed4e1e696e03bd7b9a8858841cda70da7928813cb /tests/ui/error-codes
parentccae456863cf2c10e66d1e179b74ff8e950ebfa4 (diff)
downloadrust-fa2fc3ab9638aec571574e551cd9708aa4b64280.tar.gz
rust-fa2fc3ab9638aec571574e551cd9708aa4b64280.zip
Suggest `.clone()` when moved while borrowed
Diffstat (limited to 'tests/ui/error-codes')
-rw-r--r--tests/ui/error-codes/E0504.stderr5
-rw-r--r--tests/ui/error-codes/E0505.stderr5
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/error-codes/E0504.stderr b/tests/ui/error-codes/E0504.stderr
index c8a48961cb3..9759e81a2c7 100644
--- a/tests/ui/error-codes/E0504.stderr
+++ b/tests/ui/error-codes/E0504.stderr
@@ -13,6 +13,11 @@ LL |         println!("child function: {}", fancy_num.num);
 ...
 LL |     println!("main function: {}", fancy_ref.num);
    |                                   ------------- borrow later used here
+   |
+help: consider cloning the value if the performance cost is acceptable
+   |
+LL |     let fancy_ref = &fancy_num.clone();
+   |                               ++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/error-codes/E0505.stderr b/tests/ui/error-codes/E0505.stderr
index 250680d2c1c..6808943796c 100644
--- a/tests/ui/error-codes/E0505.stderr
+++ b/tests/ui/error-codes/E0505.stderr
@@ -10,6 +10,11 @@ LL |         eat(x);
    |             ^ move out of `x` occurs here
 LL |         _ref_to_val.use_ref();
    |         ----------- borrow later used here
+   |
+help: consider cloning the value if the performance cost is acceptable
+   |
+LL |         let _ref_to_val: &Value = &x.clone();
+   |                                     ++++++++
 
 error: aborting due to 1 previous error