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