fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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