2019-01-03 00:56:45 +00:00
|
|
|
error[E0382]: use of moved value: `x`
|
2019-11-20 00:43:24 +00:00
|
|
|
--> $DIR/issue-34721.rs:27:9
|
2019-01-03 00:56:45 +00:00
|
|
|
|
|
|
|
|
LL | pub fn baz<T: Foo>(x: T) -> T {
|
2019-12-26 12:43:33 +00:00
|
|
|
| - move occurs because `x` has type `T`, which does not implement the `Copy` trait
|
2019-01-03 00:56:45 +00:00
|
|
|
LL | if 0 == 1 {
|
|
|
|
LL | bar::bar(x.zero())
|
2020-06-11 17:48:46 +00:00
|
|
|
| ------ `x` moved due to this method call
|
2019-01-03 00:56:45 +00:00
|
|
|
LL | } else {
|
|
|
|
LL | x.zero()
|
2020-06-11 17:48:46 +00:00
|
|
|
| ------ `x` moved due to this method call
|
2019-01-03 00:56:45 +00:00
|
|
|
LL | };
|
|
|
|
LL | x.zero()
|
|
|
|
| ^ value used here after move
|
2019-12-26 12:43:33 +00:00
|
|
|
|
|
2022-12-12 12:07:09 +00:00
|
|
|
note: `Foo::zero` takes ownership of the receiver `self`, which moves `x`
|
2020-06-11 17:48:46 +00:00
|
|
|
--> $DIR/issue-34721.rs:4:13
|
|
|
|
|
|
|
|
|
LL | fn zero(self) -> Self;
|
|
|
|
| ^^^^
|
2020-03-14 02:28:14 +00:00
|
|
|
help: consider further restricting this bound
|
2019-12-26 12:43:33 +00:00
|
|
|
|
|
2020-03-14 02:28:14 +00:00
|
|
|
LL | pub fn baz<T: Foo + Copy>(x: T) -> T {
|
2021-06-22 02:07:19 +00:00
|
|
|
| ++++++
|
2019-01-03 00:56:45 +00:00
|
|
|
|
2023-11-21 15:44:16 +00:00
|
|
|
error: aborting due to 1 previous error
|
2019-01-03 00:56:45 +00:00
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0382`.
|