os-rust/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr

41 lines
1.2 KiB
Text
Raw Normal View History

2018-08-08 14:28:26 +02:00
error[E0505]: cannot move out of `s` because it is borrowed
2018-12-25 08:56:47 -07:00
--> $DIR/borrowck-overloaded-index-move-index.rs:50:22
2018-08-08 14:28:26 +02:00
|
LL | let rs = &mut s;
| ------ borrow of `s` occurs here
2018-08-08 14:28:26 +02:00
LL |
LL | println!("{}", f[s]);
| ^ move out of `s` occurs here
...
LL | use_mut(rs);
| -- borrow later used here
2018-08-08 14:28:26 +02:00
error[E0505]: cannot move out of `s` because it is borrowed
2018-12-25 08:56:47 -07:00
--> $DIR/borrowck-overloaded-index-move-index.rs:53:7
2018-08-08 14:28:26 +02:00
|
LL | let rs = &mut s;
| ------ borrow of `s` occurs here
2018-08-08 14:28:26 +02:00
...
LL | f[s] = 10;
| ^ move out of `s` occurs here
...
LL | use_mut(rs);
| -- borrow later used here
2018-08-08 14:28:26 +02:00
error[E0382]: use of moved value: `s`
2018-12-25 08:56:47 -07:00
--> $DIR/borrowck-overloaded-index-move-index.rs:53:7
2018-08-08 14:28:26 +02:00
|
LL | let mut s = "hello".to_string();
| ----- move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
...
2018-08-08 14:28:26 +02:00
LL | println!("{}", f[s]);
| - value moved here
...
LL | f[s] = 10;
| ^ value used here after move
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0382, E0505.
2018-08-08 14:28:26 +02:00
For more information about an error, try `rustc --explain E0382`.