2018-08-08 07:28:26 -05:00
|
|
|
error[E0505]: cannot move out of `s` because it is borrowed
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/borrowck-overloaded-index-move-index.rs:50:22
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2023-01-14 21:06:44 -06:00
|
|
|
LL | let mut s = "hello".to_string();
|
|
|
|
| ----- binding `s` declared here
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | let rs = &mut s;
|
2019-04-22 02:40:08 -05:00
|
|
|
| ------ borrow of `s` occurs here
|
2022-06-08 13:07:59 -05:00
|
|
|
LL |
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | println!("{}", f[s]);
|
|
|
|
| ^ move out of `s` occurs here
|
2019-04-22 02:40:08 -05:00
|
|
|
...
|
|
|
|
LL | use_mut(rs);
|
|
|
|
| -- borrow later used here
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0505]: cannot move out of `s` because it is borrowed
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/borrowck-overloaded-index-move-index.rs:53:7
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2023-01-14 21:06:44 -06:00
|
|
|
LL | let mut s = "hello".to_string();
|
|
|
|
| ----- binding `s` declared here
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | let rs = &mut s;
|
2019-04-22 02:40:08 -05:00
|
|
|
| ------ borrow of `s` occurs here
|
2018-08-08 07:28:26 -05:00
|
|
|
...
|
|
|
|
LL | f[s] = 10;
|
|
|
|
| ^ move out of `s` occurs here
|
2019-04-22 02:40:08 -05:00
|
|
|
...
|
|
|
|
LL | use_mut(rs);
|
|
|
|
| -- borrow later used here
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0382]: use of moved value: `s`
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/borrowck-overloaded-index-move-index.rs:53:7
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-04-22 02:40:08 -05:00
|
|
|
LL | let mut s = "hello".to_string();
|
2020-09-02 02:40:56 -05:00
|
|
|
| ----- move occurs because `s` has type `String`, which does not implement the `Copy` trait
|
2019-04-22 02:40:08 -05:00
|
|
|
...
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | println!("{}", f[s]);
|
|
|
|
| - value moved here
|
|
|
|
...
|
|
|
|
LL | f[s] = 10;
|
|
|
|
| ^ value used here after move
|
2022-11-02 23:22:24 -05:00
|
|
|
|
|
|
|
|
help: consider cloning the value if the performance cost is acceptable
|
|
|
|
|
|
|
|
|
LL | println!("{}", f[s.clone()]);
|
|
|
|
| ++++++++
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error: aborting due to 3 previous errors
|
|
|
|
|
2019-04-17 12:26:38 -05:00
|
|
|
Some errors have detailed explanations: E0382, E0505.
|
2018-08-08 07:28:26 -05:00
|
|
|
For more information about an error, try `rustc --explain E0382`.
|