2020-10-16 22:37:54 +00:00
|
|
|
warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes
|
|
|
|
--> $DIR/borrow-after-move.rs:1:12
|
|
|
|
|
|
|
|
|
LL | #![feature(unsized_locals, unsized_fn_params)]
|
|
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information
|
2022-09-18 15:55:36 +00:00
|
|
|
= note: `#[warn(incomplete_features)]` on by default
|
2020-10-16 22:37:54 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0382]: borrow of moved value: `x`
|
2020-10-16 22:37:54 +00:00
|
|
|
--> $DIR/borrow-after-move.rs:21:24
|
2018-10-27 08:17:24 +00:00
|
|
|
|
|
|
|
|
LL | let y = *x;
|
2019-04-22 07:40:08 +00:00
|
|
|
| -- value moved here
|
2018-10-27 08:17:24 +00:00
|
|
|
LL | drop_unsized(y);
|
|
|
|
LL | println!("{}", &x);
|
2020-08-08 17:16:43 +00:00
|
|
|
| ^^ value borrowed here after move
|
2018-10-27 08:17:24 +00:00
|
|
|
|
|
|
|
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
|
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0382]: borrow of moved value: `y`
|
2020-10-16 22:37:54 +00:00
|
|
|
--> $DIR/borrow-after-move.rs:23:24
|
2018-10-27 08:17:24 +00:00
|
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | let y = *x;
|
|
|
|
| - move occurs because `y` has type `str`, which does not implement the `Copy` trait
|
2018-10-27 08:17:24 +00:00
|
|
|
LL | drop_unsized(y);
|
|
|
|
| - value moved here
|
|
|
|
...
|
|
|
|
LL | println!("{}", &y);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^ value borrowed here after move
|
2022-11-03 04:22:24 +00:00
|
|
|
|
|
2022-11-12 00:57:01 +00:00
|
|
|
note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary
|
2022-11-03 04:22:24 +00:00
|
|
|
--> $DIR/borrow-after-move.rs:14:31
|
|
|
|
|
|
|
|
|
LL | fn drop_unsized<T: ?Sized>(_: T) {}
|
2022-11-03 21:10:08 +00:00
|
|
|
| ------------ ^ this parameter takes ownership of the value
|
2022-11-03 04:22:24 +00:00
|
|
|
| |
|
|
|
|
| in this function
|
2018-10-27 08:17:24 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0382]: borrow of moved value: `x`
|
2020-10-16 22:37:54 +00:00
|
|
|
--> $DIR/borrow-after-move.rs:31:24
|
2018-10-27 08:17:24 +00:00
|
|
|
|
|
|
|
|
LL | let y = *x;
|
2019-04-22 07:40:08 +00:00
|
|
|
| -- value moved here
|
2018-10-27 08:17:24 +00:00
|
|
|
LL | y.foo();
|
|
|
|
LL | println!("{}", &x);
|
2020-08-08 17:16:43 +00:00
|
|
|
| ^^ value borrowed here after move
|
2018-10-27 08:17:24 +00:00
|
|
|
|
|
|
|
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
|
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0382]: borrow of moved value: `y`
|
2020-10-16 22:37:54 +00:00
|
|
|
--> $DIR/borrow-after-move.rs:33:24
|
2018-10-27 08:17:24 +00:00
|
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | let y = *x;
|
|
|
|
| - move occurs because `y` has type `str`, which does not implement the `Copy` trait
|
2018-10-27 08:17:24 +00:00
|
|
|
LL | y.foo();
|
2020-06-11 17:48:46 +00:00
|
|
|
| ----- `y` moved due to this method call
|
2018-10-27 08:17:24 +00:00
|
|
|
...
|
|
|
|
LL | println!("{}", &y);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^ value borrowed here after move
|
2020-06-11 17:48:46 +00:00
|
|
|
|
|
2021-01-08 19:57:28 +00:00
|
|
|
note: this function takes ownership of the receiver `self`, which moves `y`
|
2020-10-16 22:37:54 +00:00
|
|
|
--> $DIR/borrow-after-move.rs:5:12
|
2020-06-11 17:48:46 +00:00
|
|
|
|
|
|
|
|
LL | fn foo(self) -> String;
|
|
|
|
| ^^^^
|
2018-10-27 08:17:24 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0382]: borrow of moved value: `x`
|
2020-10-16 22:37:54 +00:00
|
|
|
--> $DIR/borrow-after-move.rs:40:24
|
2018-10-27 08:17:24 +00:00
|
|
|
|
|
2020-04-17 12:27:35 +00:00
|
|
|
LL | let x = "hello".to_owned().into_boxed_str();
|
2020-09-02 07:40:56 +00:00
|
|
|
| - move occurs because `x` has type `Box<str>`, which does not implement the `Copy` trait
|
2018-10-27 08:17:24 +00:00
|
|
|
LL | x.foo();
|
|
|
|
| - value moved here
|
|
|
|
LL | println!("{}", &x);
|
2020-04-17 12:27:35 +00:00
|
|
|
| ^^ value borrowed here after move
|
2022-11-03 04:22:24 +00:00
|
|
|
|
|
|
|
|
help: consider cloning the value if the performance cost is acceptable
|
|
|
|
|
|
|
|
|
LL | x.clone().foo();
|
|
|
|
| ++++++++
|
2018-10-27 08:17:24 +00:00
|
|
|
|
2020-10-16 22:37:54 +00:00
|
|
|
error: aborting due to 5 previous errors; 1 warning emitted
|
2018-10-27 08:17:24 +00:00
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0382`.
|