]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr
Rollup merge of #107022 - scottmcm:ordering-option-eq, r=m-ou-se
[rust.git] / tests / ui / borrowck / borrowck-overloaded-index-move-index.stderr
1 error[E0505]: cannot move out of `s` because it is borrowed
2   --> $DIR/borrowck-overloaded-index-move-index.rs:50:22
3    |
4 LL |     let mut s = "hello".to_string();
5    |         ----- binding `s` declared here
6 LL |     let rs = &mut s;
7    |              ------ borrow of `s` occurs here
8 LL |
9 LL |     println!("{}", f[s]);
10    |                      ^ move out of `s` occurs here
11 ...
12 LL |     use_mut(rs);
13    |             -- borrow later used here
14
15 error[E0505]: cannot move out of `s` because it is borrowed
16   --> $DIR/borrowck-overloaded-index-move-index.rs:53:7
17    |
18 LL |     let mut s = "hello".to_string();
19    |         ----- binding `s` declared here
20 LL |     let rs = &mut s;
21    |              ------ borrow of `s` occurs here
22 ...
23 LL |     f[s] = 10;
24    |       ^ move out of `s` occurs here
25 ...
26 LL |     use_mut(rs);
27    |             -- borrow later used here
28
29 error[E0382]: use of moved value: `s`
30   --> $DIR/borrowck-overloaded-index-move-index.rs:53:7
31    |
32 LL |     let mut s = "hello".to_string();
33    |         ----- move occurs because `s` has type `String`, which does not implement the `Copy` trait
34 ...
35 LL |     println!("{}", f[s]);
36    |                      - value moved here
37 ...
38 LL |     f[s] = 10;
39    |       ^ value used here after move
40    |
41 help: consider cloning the value if the performance cost is acceptable
42    |
43 LL |     println!("{}", f[s.clone()]);
44    |                       ++++++++
45
46 error: aborting due to 3 previous errors
47
48 Some errors have detailed explanations: E0382, E0505.
49 For more information about an error, try `rustc --explain E0382`.