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