fork/rust

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

borsAuto merge of #72883 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum49cae55760d

1.44.0
1.2 KiB40 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 rs = &mut s;
5   |              ------ borrow of `s` occurs here
6LL | 
7LL |     println!("{}", f[s]);
8   |                      ^ move out of `s` occurs here
9...
10LL |     use_mut(rs);
11   |             -- borrow later used here
12
13error[E0505]: cannot move out of `s` because it is borrowed
14  --> $DIR/borrowck-overloaded-index-move-index.rs:53:7
15   |
16LL |     let rs = &mut s;
17   |              ------ borrow of `s` occurs here
18...
19LL |     f[s] = 10;
20   |       ^ move out of `s` occurs here
21...
22LL |     use_mut(rs);
23   |             -- borrow later used here
24
25error[E0382]: use of moved value: `s`
26  --> $DIR/borrowck-overloaded-index-move-index.rs:53:7
27   |
28LL |     let mut s = "hello".to_string();
29   |         ----- move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
30...
31LL |     println!("{}", f[s]);
32   |                      - value moved here
33...
34LL |     f[s] = 10;
35   |       ^ value used here after move
36
37error: aborting due to 3 previous errors
38
39Some errors have detailed explanations: E0382, E0505.
40For more information about an error, try `rustc --explain E0382`.