rust/src/test/ui/unsized-locals/borrow-after-move.stderr

64 lines
2.2 KiB
Plaintext
Raw Normal View History

error[E0382]: borrow of moved value: `x`
--> $DIR/borrow-after-move.rs:20:24
|
LL | let y = *x;
| -- value moved here
LL | drop_unsized(y);
LL | println!("{}", &x);
| ^^ value borrowed here after move
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
error[E0382]: borrow of moved value: `y`
--> $DIR/borrow-after-move.rs:22:24
|
LL | let y = *x;
| - move occurs because `y` has type `str`, which does not implement the `Copy` trait
LL | drop_unsized(y);
| - value moved here
...
LL | println!("{}", &y);
| ^^ value borrowed here after move
error[E0382]: borrow of moved value: `x`
--> $DIR/borrow-after-move.rs:30:24
|
LL | let y = *x;
| -- value moved here
LL | y.foo();
LL | println!("{}", &x);
| ^^ value borrowed here after move
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
error[E0382]: borrow of moved value: `y`
--> $DIR/borrow-after-move.rs:32:24
|
LL | let y = *x;
| - move occurs because `y` has type `str`, which does not implement the `Copy` trait
LL | y.foo();
| ----- `y` moved due to this method call
...
LL | println!("{}", &y);
| ^^ value borrowed here after move
|
note: this function consumes the receiver `self` by taking ownership of it, which moves `y`
--> $DIR/borrow-after-move.rs:4:12
|
LL | fn foo(self) -> String;
| ^^^^
error[E0382]: borrow of moved value: `x`
--> $DIR/borrow-after-move.rs:39:24
|
LL | let x = "hello".to_owned().into_boxed_str();
| - move occurs because `x` has type `std::boxed::Box<str>`, which does not implement the `Copy` trait
LL | x.foo();
| - value moved here
LL | println!("{}", &x);
| ^^ value borrowed here after move
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0382`.