diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/moves/borrow-closures-instead-of-move.rs (renamed from src/test/ui/moves/borrow-closures-instead-of-move.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/borrow-closures-instead-of-move.stderr (renamed from src/test/ui/moves/borrow-closures-instead-of-move.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/issue-46099-move-in-macro.rs (renamed from src/test/ui/moves/issue-46099-move-in-macro.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/issue-46099-move-in-macro.stderr (renamed from src/test/ui/moves/issue-46099-move-in-macro.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/issue-72649-uninit-in-loop.rs (renamed from src/test/ui/moves/issue-72649-uninit-in-loop.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/issue-72649-uninit-in-loop.stderr (renamed from src/test/ui/moves/issue-72649-uninit-in-loop.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/issue-75904-move-closure-loop.rs (renamed from src/test/ui/moves/issue-75904-move-closure-loop.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/issue-75904-move-closure-loop.stderr (renamed from src/test/ui/moves/issue-75904-move-closure-loop.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/issue-99470-move-out-of-some.rs (renamed from src/test/ui/moves/issue-99470-move-out-of-some.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/issue-99470-move-out-of-some.stderr | 21 | ||||
-rw-r--r-- | tests/ui/moves/move-1-unique.rs (renamed from src/test/ui/moves/move-1-unique.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-2-unique.rs (renamed from src/test/ui/moves/move-2-unique.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-2.rs (renamed from src/test/ui/moves/move-2.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-3-unique.rs (renamed from src/test/ui/moves/move-3-unique.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-4-unique.rs (renamed from src/test/ui/moves/move-4-unique.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-4.rs (renamed from src/test/ui/moves/move-4.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-arg-2-unique.rs (renamed from src/test/ui/moves/move-arg-2-unique.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-arg-2.rs (renamed from src/test/ui/moves/move-arg-2.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-arg.rs (renamed from src/test/ui/moves/move-arg.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-deref-coercion.rs (renamed from src/test/ui/moves/move-deref-coercion.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-deref-coercion.stderr (renamed from src/test/ui/moves/move-deref-coercion.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-fn-self-receiver.rs (renamed from src/test/ui/moves/move-fn-self-receiver.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-fn-self-receiver.stderr (renamed from src/test/ui/moves/move-fn-self-receiver.stderr) | 30 | ||||
-rw-r--r-- | tests/ui/moves/move-guard-same-consts.rs (renamed from src/test/ui/moves/move-guard-same-consts.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-guard-same-consts.stderr (renamed from src/test/ui/moves/move-guard-same-consts.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-in-guard-1.rs (renamed from src/test/ui/moves/move-in-guard-1.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-in-guard-1.stderr (renamed from src/test/ui/moves/move-in-guard-1.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-in-guard-2.rs (renamed from src/test/ui/moves/move-in-guard-2.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-in-guard-2.stderr (renamed from src/test/ui/moves/move-in-guard-2.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-into-dead-array-1.rs (renamed from src/test/ui/moves/move-into-dead-array-1.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-into-dead-array-1.stderr (renamed from src/test/ui/moves/move-into-dead-array-1.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-into-dead-array-2.rs (renamed from src/test/ui/moves/move-into-dead-array-2.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-into-dead-array-2.stderr (renamed from src/test/ui/moves/move-into-dead-array-2.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-nullary-fn.rs (renamed from src/test/ui/moves/move-nullary-fn.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-of-addr-of-mut.rs (renamed from src/test/ui/moves/move-of-addr-of-mut.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-of-addr-of-mut.stderr (renamed from src/test/ui/moves/move-of-addr-of-mut.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-array-1.rs (renamed from src/test/ui/moves/move-out-of-array-1.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-array-1.stderr (renamed from src/test/ui/moves/move-out-of-array-1.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-array-ref.rs (renamed from src/test/ui/moves/move-out-of-array-ref.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-array-ref.stderr | 63 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-field.rs (renamed from src/test/ui/moves/move-out-of-field.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-slice-1.rs (renamed from src/test/ui/moves/move-out-of-slice-1.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-slice-1.stderr (renamed from src/test/ui/moves/move-out-of-slice-1.stderr) | 5 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-slice-2.rs (renamed from src/test/ui/moves/move-out-of-slice-2.rs) | 1 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-slice-2.stderr (renamed from src/test/ui/moves/move-out-of-slice-2.stderr) | 28 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-tuple-field.rs (renamed from src/test/ui/moves/move-out-of-tuple-field.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-out-of-tuple-field.stderr (renamed from src/test/ui/moves/move-out-of-tuple-field.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/move-scalar.rs (renamed from src/test/ui/moves/move-scalar.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-access-to-field.rs (renamed from src/test/ui/moves/moves-based-on-type-access-to-field.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-access-to-field.stderr | 20 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-block-bad.rs (renamed from src/test/ui/moves/moves-based-on-type-block-bad.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-block-bad.stderr (renamed from src/test/ui/moves/moves-based-on-type-block-bad.stderr) | 7 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-capture-clause-bad.rs (renamed from src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr (renamed from src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-capture-clause.rs (renamed from src/test/ui/moves/moves-based-on-type-capture-clause.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs (renamed from src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr (renamed from src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs (renamed from src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr (renamed from src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-exprs.rs (renamed from src/test/ui/moves/moves-based-on-type-exprs.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-exprs.stderr (renamed from src/test/ui/moves/moves-based-on-type-exprs.stderr) | 18 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-match-bindings.rs (renamed from src/test/ui/moves/moves-based-on-type-match-bindings.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-match-bindings.stderr (renamed from src/test/ui/moves/moves-based-on-type-match-bindings.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs (renamed from src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr (renamed from src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs (renamed from src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr (renamed from src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-tuple.rs (renamed from src/test/ui/moves/moves-based-on-type-tuple.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-based-on-type-tuple.stderr (renamed from src/test/ui/moves/moves-based-on-type-tuple.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-sru-moved-field.rs (renamed from src/test/ui/moves/moves-sru-moved-field.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/moves-sru-moved-field.stderr (renamed from src/test/ui/moves/moves-sru-moved-field.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/pin-mut-reborrow.fixed | 15 | ||||
-rw-r--r-- | tests/ui/moves/pin-mut-reborrow.rs | 15 | ||||
-rw-r--r-- | tests/ui/moves/pin-mut-reborrow.stderr | 23 | ||||
-rw-r--r-- | tests/ui/moves/suggest-clone.fixed | 11 | ||||
-rw-r--r-- | tests/ui/moves/suggest-clone.rs | 11 | ||||
-rw-r--r-- | tests/ui/moves/suggest-clone.stderr | 22 | ||||
-rw-r--r-- | tests/ui/moves/use_of_moved_value_clone_suggestions.rs (renamed from src/test/ui/moves/use_of_moved_value_clone_suggestions.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/use_of_moved_value_clone_suggestions.stderr (renamed from src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/moves/use_of_moved_value_copy_suggestions.fixed (renamed from src/test/ui/moves/use_of_moved_value_copy_suggestions.fixed) | 0 | ||||
-rw-r--r-- | tests/ui/moves/use_of_moved_value_copy_suggestions.rs (renamed from src/test/ui/moves/use_of_moved_value_copy_suggestions.rs) | 0 | ||||
-rw-r--r-- | tests/ui/moves/use_of_moved_value_copy_suggestions.stderr (renamed from src/test/ui/moves/use_of_moved_value_copy_suggestions.stderr) | 0 |
82 files changed, 257 insertions, 33 deletions
diff --git a/src/test/ui/moves/borrow-closures-instead-of-move.rs b/tests/ui/moves/borrow-closures-instead-of-move.rs index 51771ced7..51771ced7 100644 --- a/src/test/ui/moves/borrow-closures-instead-of-move.rs +++ b/tests/ui/moves/borrow-closures-instead-of-move.rs diff --git a/src/test/ui/moves/borrow-closures-instead-of-move.stderr b/tests/ui/moves/borrow-closures-instead-of-move.stderr index 9a84ddef7..9a84ddef7 100644 --- a/src/test/ui/moves/borrow-closures-instead-of-move.stderr +++ b/tests/ui/moves/borrow-closures-instead-of-move.stderr diff --git a/src/test/ui/moves/issue-46099-move-in-macro.rs b/tests/ui/moves/issue-46099-move-in-macro.rs index 576fe1f4c..576fe1f4c 100644 --- a/src/test/ui/moves/issue-46099-move-in-macro.rs +++ b/tests/ui/moves/issue-46099-move-in-macro.rs diff --git a/src/test/ui/moves/issue-46099-move-in-macro.stderr b/tests/ui/moves/issue-46099-move-in-macro.stderr index 94bc9e6f4..94bc9e6f4 100644 --- a/src/test/ui/moves/issue-46099-move-in-macro.stderr +++ b/tests/ui/moves/issue-46099-move-in-macro.stderr diff --git a/src/test/ui/moves/issue-72649-uninit-in-loop.rs b/tests/ui/moves/issue-72649-uninit-in-loop.rs index 56c225bab..56c225bab 100644 --- a/src/test/ui/moves/issue-72649-uninit-in-loop.rs +++ b/tests/ui/moves/issue-72649-uninit-in-loop.rs diff --git a/src/test/ui/moves/issue-72649-uninit-in-loop.stderr b/tests/ui/moves/issue-72649-uninit-in-loop.stderr index 7e119fe8c..7e119fe8c 100644 --- a/src/test/ui/moves/issue-72649-uninit-in-loop.stderr +++ b/tests/ui/moves/issue-72649-uninit-in-loop.stderr diff --git a/src/test/ui/moves/issue-75904-move-closure-loop.rs b/tests/ui/moves/issue-75904-move-closure-loop.rs index 6641a0376..6641a0376 100644 --- a/src/test/ui/moves/issue-75904-move-closure-loop.rs +++ b/tests/ui/moves/issue-75904-move-closure-loop.rs diff --git a/src/test/ui/moves/issue-75904-move-closure-loop.stderr b/tests/ui/moves/issue-75904-move-closure-loop.stderr index 5e427a1fc..5e427a1fc 100644 --- a/src/test/ui/moves/issue-75904-move-closure-loop.stderr +++ b/tests/ui/moves/issue-75904-move-closure-loop.stderr diff --git a/src/test/ui/moves/issue-99470-move-out-of-some.rs b/tests/ui/moves/issue-99470-move-out-of-some.rs index f404cd3cd..f404cd3cd 100644 --- a/src/test/ui/moves/issue-99470-move-out-of-some.rs +++ b/tests/ui/moves/issue-99470-move-out-of-some.rs diff --git a/tests/ui/moves/issue-99470-move-out-of-some.stderr b/tests/ui/moves/issue-99470-move-out-of-some.stderr new file mode 100644 index 000000000..c5159471f --- /dev/null +++ b/tests/ui/moves/issue-99470-move-out-of-some.stderr @@ -0,0 +1,21 @@ +error[E0507]: cannot move out of `x` as enum variant `Some` which is behind a shared reference + --> $DIR/issue-99470-move-out-of-some.rs:4:11 + | +LL | match x { + | ^ +LL | +LL | &Some(_y) => (), + | -- + | | + | data moved here + | move occurs because `_y` has type `Box<i32>`, which does not implement the `Copy` trait + | +help: consider removing the borrow + | +LL - &Some(_y) => (), +LL + Some(_y) => (), + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/moves/move-1-unique.rs b/tests/ui/moves/move-1-unique.rs index f98d075d1..f98d075d1 100644 --- a/src/test/ui/moves/move-1-unique.rs +++ b/tests/ui/moves/move-1-unique.rs diff --git a/src/test/ui/moves/move-2-unique.rs b/tests/ui/moves/move-2-unique.rs index 8fda3c1c8..8fda3c1c8 100644 --- a/src/test/ui/moves/move-2-unique.rs +++ b/tests/ui/moves/move-2-unique.rs diff --git a/src/test/ui/moves/move-2.rs b/tests/ui/moves/move-2.rs index 5e0100874..5e0100874 100644 --- a/src/test/ui/moves/move-2.rs +++ b/tests/ui/moves/move-2.rs diff --git a/src/test/ui/moves/move-3-unique.rs b/tests/ui/moves/move-3-unique.rs index 8e5df2c3f..8e5df2c3f 100644 --- a/src/test/ui/moves/move-3-unique.rs +++ b/tests/ui/moves/move-3-unique.rs diff --git a/src/test/ui/moves/move-4-unique.rs b/tests/ui/moves/move-4-unique.rs index 24aec7ea6..24aec7ea6 100644 --- a/src/test/ui/moves/move-4-unique.rs +++ b/tests/ui/moves/move-4-unique.rs diff --git a/src/test/ui/moves/move-4.rs b/tests/ui/moves/move-4.rs index 63aa031a6..63aa031a6 100644 --- a/src/test/ui/moves/move-4.rs +++ b/tests/ui/moves/move-4.rs diff --git a/src/test/ui/moves/move-arg-2-unique.rs b/tests/ui/moves/move-arg-2-unique.rs index 9622c8375..9622c8375 100644 --- a/src/test/ui/moves/move-arg-2-unique.rs +++ b/tests/ui/moves/move-arg-2-unique.rs diff --git a/src/test/ui/moves/move-arg-2.rs b/tests/ui/moves/move-arg-2.rs index 77ee06e19..77ee06e19 100644 --- a/src/test/ui/moves/move-arg-2.rs +++ b/tests/ui/moves/move-arg-2.rs diff --git a/src/test/ui/moves/move-arg.rs b/tests/ui/moves/move-arg.rs index 5942cd89f..5942cd89f 100644 --- a/src/test/ui/moves/move-arg.rs +++ b/tests/ui/moves/move-arg.rs diff --git a/src/test/ui/moves/move-deref-coercion.rs b/tests/ui/moves/move-deref-coercion.rs index 41154388f..41154388f 100644 --- a/src/test/ui/moves/move-deref-coercion.rs +++ b/tests/ui/moves/move-deref-coercion.rs diff --git a/src/test/ui/moves/move-deref-coercion.stderr b/tests/ui/moves/move-deref-coercion.stderr index 5760f4a7f..5760f4a7f 100644 --- a/src/test/ui/moves/move-deref-coercion.stderr +++ b/tests/ui/moves/move-deref-coercion.stderr diff --git a/src/test/ui/moves/move-fn-self-receiver.rs b/tests/ui/moves/move-fn-self-receiver.rs index 946642ef6..946642ef6 100644 --- a/src/test/ui/moves/move-fn-self-receiver.rs +++ b/tests/ui/moves/move-fn-self-receiver.rs diff --git a/src/test/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr index c13dc5882..7f69e5dcf 100644 --- a/src/test/ui/moves/move-fn-self-receiver.stderr +++ b/tests/ui/moves/move-fn-self-receiver.stderr @@ -6,12 +6,13 @@ LL | val.0.into_iter().next(); LL | val.0; | ^^^^^ value used here after move | -note: this function takes ownership of the receiver `self`, which moves `val.0` +note: `into_iter` takes ownership of the receiver `self`, which moves `val.0` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL - | -LL | fn into_iter(self) -> Self::IntoIter; - | ^^^^ = note: move occurs because `val.0` has type `Vec<bool>`, which does not implement the `Copy` trait +help: you can `clone` the value and consume it, but this might not be your desired behavior + | +LL | val.0.clone().into_iter().next(); + | ++++++++ error[E0382]: use of moved value: `foo` --> $DIR/move-fn-self-receiver.rs:34:5 @@ -23,7 +24,7 @@ LL | foo.use_self(); LL | foo; | ^^^ value used here after move | -note: this function takes ownership of the receiver `self`, which moves `foo` +note: `Foo::use_self` takes ownership of the receiver `self`, which moves `foo` --> $DIR/move-fn-self-receiver.rs:13:17 | LL | fn use_self(self) {} @@ -49,7 +50,7 @@ LL | boxed_foo.use_box_self(); LL | boxed_foo; | ^^^^^^^^^ value used here after move | -note: this function takes ownership of the receiver `self`, which moves `boxed_foo` +note: `Foo::use_box_self` takes ownership of the receiver `self`, which moves `boxed_foo` --> $DIR/move-fn-self-receiver.rs:14:21 | LL | fn use_box_self(self: Box<Self>) {} @@ -65,7 +66,7 @@ LL | pin_box_foo.use_pin_box_self(); LL | pin_box_foo; | ^^^^^^^^^^^ value used here after move | -note: this function takes ownership of the receiver `self`, which moves `pin_box_foo` +note: `Foo::use_pin_box_self` takes ownership of the receiver `self`, which moves `pin_box_foo` --> $DIR/move-fn-self-receiver.rs:15:25 | LL | fn use_pin_box_self(self: Pin<Box<Self>>) {} @@ -91,15 +92,15 @@ LL | rc_foo.use_rc_self(); LL | rc_foo; | ^^^^^^ value used here after move | -note: this function takes ownership of the receiver `self`, which moves `rc_foo` +note: `Foo::use_rc_self` takes ownership of the receiver `self`, which moves `rc_foo` --> $DIR/move-fn-self-receiver.rs:16:20 | LL | fn use_rc_self(self: Rc<Self>) {} | ^^^^ -help: consider cloning the value if the performance cost is acceptable +help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | rc_foo.clone().use_rc_self(); - | ++++++++ + | ++++++++ error[E0382]: use of moved value: `foo_add` --> $DIR/move-fn-self-receiver.rs:59:5 @@ -113,9 +114,6 @@ LL | foo_add; | note: calling this operator moves the left-hand side --> $SRC_DIR/core/src/ops/arith.rs:LL:COL - | -LL | fn add(self, rhs: Rhs) -> Self::Output; - | ^^^^ error[E0382]: use of moved value: `implicit_into_iter` --> $DIR/move-fn-self-receiver.rs:63:5 @@ -142,10 +140,10 @@ LL | for _val in explicit_into_iter.into_iter() {} LL | explicit_into_iter; | ^^^^^^^^^^^^^^^^^^ value used here after move | -help: consider cloning the value if the performance cost is acceptable +help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | for _val in explicit_into_iter.clone().into_iter() {} - | ++++++++ + | ++++++++ error[E0382]: use of moved value: `container` --> $DIR/move-fn-self-receiver.rs:71:5 @@ -157,7 +155,7 @@ LL | for _val in container.custom_into_iter() {} LL | container; | ^^^^^^^^^ value used here after move | -note: this function takes ownership of the receiver `self`, which moves `container` +note: `Container::custom_into_iter` takes ownership of the receiver `self`, which moves `container` --> $DIR/move-fn-self-receiver.rs:23:25 | LL | fn custom_into_iter(self) -> impl Iterator<Item = bool> { diff --git a/src/test/ui/moves/move-guard-same-consts.rs b/tests/ui/moves/move-guard-same-consts.rs index b96ef8e19..b96ef8e19 100644 --- a/src/test/ui/moves/move-guard-same-consts.rs +++ b/tests/ui/moves/move-guard-same-consts.rs diff --git a/src/test/ui/moves/move-guard-same-consts.stderr b/tests/ui/moves/move-guard-same-consts.stderr index 86e5f6524..86e5f6524 100644 --- a/src/test/ui/moves/move-guard-same-consts.stderr +++ b/tests/ui/moves/move-guard-same-consts.stderr diff --git a/src/test/ui/moves/move-in-guard-1.rs b/tests/ui/moves/move-in-guard-1.rs index 36e39fea6..36e39fea6 100644 --- a/src/test/ui/moves/move-in-guard-1.rs +++ b/tests/ui/moves/move-in-guard-1.rs diff --git a/src/test/ui/moves/move-in-guard-1.stderr b/tests/ui/moves/move-in-guard-1.stderr index f04cb34d7..f04cb34d7 100644 --- a/src/test/ui/moves/move-in-guard-1.stderr +++ b/tests/ui/moves/move-in-guard-1.stderr diff --git a/src/test/ui/moves/move-in-guard-2.rs b/tests/ui/moves/move-in-guard-2.rs index 085b7ec6e..085b7ec6e 100644 --- a/src/test/ui/moves/move-in-guard-2.rs +++ b/tests/ui/moves/move-in-guard-2.rs diff --git a/src/test/ui/moves/move-in-guard-2.stderr b/tests/ui/moves/move-in-guard-2.stderr index 26047861f..26047861f 100644 --- a/src/test/ui/moves/move-in-guard-2.stderr +++ b/tests/ui/moves/move-in-guard-2.stderr diff --git a/src/test/ui/moves/move-into-dead-array-1.rs b/tests/ui/moves/move-into-dead-array-1.rs index 0b8d76def..0b8d76def 100644 --- a/src/test/ui/moves/move-into-dead-array-1.rs +++ b/tests/ui/moves/move-into-dead-array-1.rs diff --git a/src/test/ui/moves/move-into-dead-array-1.stderr b/tests/ui/moves/move-into-dead-array-1.stderr index 6db0f0bcb..6db0f0bcb 100644 --- a/src/test/ui/moves/move-into-dead-array-1.stderr +++ b/tests/ui/moves/move-into-dead-array-1.stderr diff --git a/src/test/ui/moves/move-into-dead-array-2.rs b/tests/ui/moves/move-into-dead-array-2.rs index 9b66ea35f..9b66ea35f 100644 --- a/src/test/ui/moves/move-into-dead-array-2.rs +++ b/tests/ui/moves/move-into-dead-array-2.rs diff --git a/src/test/ui/moves/move-into-dead-array-2.stderr b/tests/ui/moves/move-into-dead-array-2.stderr index 19e476c04..19e476c04 100644 --- a/src/test/ui/moves/move-into-dead-array-2.stderr +++ b/tests/ui/moves/move-into-dead-array-2.stderr diff --git a/src/test/ui/moves/move-nullary-fn.rs b/tests/ui/moves/move-nullary-fn.rs index 14c9262c7..14c9262c7 100644 --- a/src/test/ui/moves/move-nullary-fn.rs +++ b/tests/ui/moves/move-nullary-fn.rs diff --git a/src/test/ui/moves/move-of-addr-of-mut.rs b/tests/ui/moves/move-of-addr-of-mut.rs index 19fd70286..19fd70286 100644 --- a/src/test/ui/moves/move-of-addr-of-mut.rs +++ b/tests/ui/moves/move-of-addr-of-mut.rs diff --git a/src/test/ui/moves/move-of-addr-of-mut.stderr b/tests/ui/moves/move-of-addr-of-mut.stderr index ddebaa012..ddebaa012 100644 --- a/src/test/ui/moves/move-of-addr-of-mut.stderr +++ b/tests/ui/moves/move-of-addr-of-mut.stderr diff --git a/src/test/ui/moves/move-out-of-array-1.rs b/tests/ui/moves/move-out-of-array-1.rs index 77cb73e47..77cb73e47 100644 --- a/src/test/ui/moves/move-out-of-array-1.rs +++ b/tests/ui/moves/move-out-of-array-1.rs diff --git a/src/test/ui/moves/move-out-of-array-1.stderr b/tests/ui/moves/move-out-of-array-1.stderr index 0af083e5b..0af083e5b 100644 --- a/src/test/ui/moves/move-out-of-array-1.stderr +++ b/tests/ui/moves/move-out-of-array-1.stderr diff --git a/src/test/ui/moves/move-out-of-array-ref.rs b/tests/ui/moves/move-out-of-array-ref.rs index 343f00ff2..343f00ff2 100644 --- a/src/test/ui/moves/move-out-of-array-ref.rs +++ b/tests/ui/moves/move-out-of-array-ref.rs diff --git a/tests/ui/moves/move-out-of-array-ref.stderr b/tests/ui/moves/move-out-of-array-ref.stderr new file mode 100644 index 000000000..26d4996d6 --- /dev/null +++ b/tests/ui/moves/move-out-of-array-ref.stderr @@ -0,0 +1,63 @@ +error[E0508]: cannot move out of type `[D; 4]`, a non-copy array + --> $DIR/move-out-of-array-ref.rs:8:24 + | +LL | let [_, e, _, _] = *a; + | - ^^ cannot move out of here + | | + | data moved here + | move occurs because `e` has type `D`, which does not implement the `Copy` trait + | +help: consider removing the dereference here + | +LL - let [_, e, _, _] = *a; +LL + let [_, e, _, _] = a; + | + +error[E0508]: cannot move out of type `[D; 4]`, a non-copy array + --> $DIR/move-out-of-array-ref.rs:13:27 + | +LL | let [_, s @ .. , _] = *a; + | - ^^ cannot move out of here + | | + | data moved here + | move occurs because `s` has type `[D; 2]`, which does not implement the `Copy` trait + | +help: consider removing the dereference here + | +LL - let [_, s @ .. , _] = *a; +LL + let [_, s @ .. , _] = a; + | + +error[E0508]: cannot move out of type `[D; 4]`, a non-copy array + --> $DIR/move-out-of-array-ref.rs:18:24 + | +LL | let [_, e, _, _] = *a; + | - ^^ cannot move out of here + | | + | data moved here + | move occurs because `e` has type `D`, which does not implement the `Copy` trait + | +help: consider removing the dereference here + | +LL - let [_, e, _, _] = *a; +LL + let [_, e, _, _] = a; + | + +error[E0508]: cannot move out of type `[D; 4]`, a non-copy array + --> $DIR/move-out-of-array-ref.rs:23:27 + | +LL | let [_, s @ .. , _] = *a; + | - ^^ cannot move out of here + | | + | data moved here + | move occurs because `s` has type `[D; 2]`, which does not implement the `Copy` trait + | +help: consider removing the dereference here + | +LL - let [_, s @ .. , _] = *a; +LL + let [_, s @ .. , _] = a; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/moves/move-out-of-field.rs b/tests/ui/moves/move-out-of-field.rs index 9f697db4f..9f697db4f 100644 --- a/src/test/ui/moves/move-out-of-field.rs +++ b/tests/ui/moves/move-out-of-field.rs diff --git a/src/test/ui/moves/move-out-of-slice-1.rs b/tests/ui/moves/move-out-of-slice-1.rs index 982648f5b..982648f5b 100644 --- a/src/test/ui/moves/move-out-of-slice-1.rs +++ b/tests/ui/moves/move-out-of-slice-1.rs diff --git a/src/test/ui/moves/move-out-of-slice-1.stderr b/tests/ui/moves/move-out-of-slice-1.stderr index ce5ddb3e1..5a0357cf5 100644 --- a/src/test/ui/moves/move-out-of-slice-1.stderr +++ b/tests/ui/moves/move-out-of-slice-1.stderr @@ -8,6 +8,11 @@ LL | box [a] => {}, | | | data moved here | move occurs because `a` has type `A`, which does not implement the `Copy` trait + | +help: consider borrowing the pattern binding + | +LL | box [ref a] => {}, + | +++ error: aborting due to previous error diff --git a/src/test/ui/moves/move-out-of-slice-2.rs b/tests/ui/moves/move-out-of-slice-2.rs index 59c02d42b..2f7394fbf 100644 --- a/src/test/ui/moves/move-out-of-slice-2.rs +++ b/tests/ui/moves/move-out-of-slice-2.rs @@ -1,5 +1,6 @@ #![feature(unsized_locals)] //~^ WARN the feature `unsized_locals` is incomplete +#![allow(unused)] struct A; #[derive(Clone, Copy)] diff --git a/src/test/ui/moves/move-out-of-slice-2.stderr b/tests/ui/moves/move-out-of-slice-2.stderr index 46357ce6f..b46854cd6 100644 --- a/src/test/ui/moves/move-out-of-slice-2.stderr +++ b/tests/ui/moves/move-out-of-slice-2.stderr @@ -8,7 +8,7 @@ LL | #![feature(unsized_locals)] = note: `#[warn(incomplete_features)]` on by default error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:10:11 + --> $DIR/move-out-of-slice-2.rs:11:11 | LL | match *a { | ^^ cannot move out of here @@ -18,9 +18,14 @@ LL | [a @ ..] => {} | | | data moved here | move occurs because `a` has type `[A]`, which does not implement the `Copy` trait + | +help: consider borrowing the pattern binding + | +LL | [ref a @ ..] => {} + | +++ error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:16:11 + --> $DIR/move-out-of-slice-2.rs:17:11 | LL | match *b { | ^^ cannot move out of here @@ -30,9 +35,14 @@ LL | [_, _, b @ .., _] => {} | | | data moved here | move occurs because `b` has type `[A]`, which does not implement the `Copy` trait + | +help: consider borrowing the pattern binding + | +LL | [_, _, ref b @ .., _] => {} + | +++ error[E0508]: cannot move out of type `[C]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:24:11 + --> $DIR/move-out-of-slice-2.rs:25:11 | LL | match *c { | ^^ cannot move out of here @@ -42,9 +52,14 @@ LL | [c @ ..] => {} | | | data moved here | move occurs because `c` has type `[C]`, which does not implement the `Copy` trait + | +help: consider borrowing the pattern binding + | +LL | [ref c @ ..] => {} + | +++ error[E0508]: cannot move out of type `[C]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:30:11 + --> $DIR/move-out-of-slice-2.rs:31:11 | LL | match *d { | ^^ cannot move out of here @@ -54,6 +69,11 @@ LL | [_, _, d @ .., _] => {} | | | data moved here | move occurs because `d` has type `[C]`, which does not implement the `Copy` trait + | +help: consider borrowing the pattern binding + | +LL | [_, _, ref d @ .., _] => {} + | +++ error: aborting due to 4 previous errors; 1 warning emitted diff --git a/src/test/ui/moves/move-out-of-tuple-field.rs b/tests/ui/moves/move-out-of-tuple-field.rs index 66912fa4d..66912fa4d 100644 --- a/src/test/ui/moves/move-out-of-tuple-field.rs +++ b/tests/ui/moves/move-out-of-tuple-field.rs diff --git a/src/test/ui/moves/move-out-of-tuple-field.stderr b/tests/ui/moves/move-out-of-tuple-field.stderr index bb4eb7677..bb4eb7677 100644 --- a/src/test/ui/moves/move-out-of-tuple-field.stderr +++ b/tests/ui/moves/move-out-of-tuple-field.stderr diff --git a/src/test/ui/moves/move-scalar.rs b/tests/ui/moves/move-scalar.rs index 98bfeb1bc..98bfeb1bc 100644 --- a/src/test/ui/moves/move-scalar.rs +++ b/tests/ui/moves/move-scalar.rs diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.rs b/tests/ui/moves/moves-based-on-type-access-to-field.rs index e2003ed6e..e2003ed6e 100644 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.rs +++ b/tests/ui/moves/moves-based-on-type-access-to-field.rs diff --git a/tests/ui/moves/moves-based-on-type-access-to-field.stderr b/tests/ui/moves/moves-based-on-type-access-to-field.stderr new file mode 100644 index 000000000..a28f324aa --- /dev/null +++ b/tests/ui/moves/moves-based-on-type-access-to-field.stderr @@ -0,0 +1,20 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-access-to-field.rs:11:12 + | +LL | let x = vec!["hi".to_string()]; + | - move occurs because `x` has type `Vec<String>`, which does not implement the `Copy` trait +LL | consume(x.into_iter().next().unwrap()); + | ----------- `x` moved due to this method call +LL | touch(&x[0]); + | ^ value borrowed here after move + | +note: `into_iter` takes ownership of the receiver `self`, which moves `x` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL +help: you can `clone` the value and consume it, but this might not be your desired behavior + | +LL | consume(x.clone().into_iter().next().unwrap()); + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-block-bad.rs b/tests/ui/moves/moves-based-on-type-block-bad.rs index eca33167f..eca33167f 100644 --- a/src/test/ui/moves/moves-based-on-type-block-bad.rs +++ b/tests/ui/moves/moves-based-on-type-block-bad.rs diff --git a/src/test/ui/moves/moves-based-on-type-block-bad.stderr b/tests/ui/moves/moves-based-on-type-block-bad.stderr index 5ed91a0d5..df09ababa 100644 --- a/src/test/ui/moves/moves-based-on-type-block-bad.stderr +++ b/tests/ui/moves/moves-based-on-type-block-bad.stderr @@ -2,13 +2,18 @@ error[E0507]: cannot move out of `hellothere.x` as enum variant `Bar` which is b --> $DIR/moves-based-on-type-block-bad.rs:22:19 | LL | match hellothere.x { - | ^^^^^^^^^^^^ help: consider borrowing here: `&hellothere.x` + | ^^^^^^^^^^^^ LL | box E::Foo(_) => {} LL | box E::Bar(x) => println!("{}", x.to_string()), | - | | | data moved here | move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait + | +help: consider borrowing here + | +LL | match &hellothere.x { + | + error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs b/tests/ui/moves/moves-based-on-type-capture-clause-bad.rs index b2f68352f..b2f68352f 100644 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs +++ b/tests/ui/moves/moves-based-on-type-capture-clause-bad.rs diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr b/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr index 34b7ea658..34b7ea658 100644 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr +++ b/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause.rs b/tests/ui/moves/moves-based-on-type-capture-clause.rs index 4a6a4ed28..4a6a4ed28 100644 --- a/src/test/ui/moves/moves-based-on-type-capture-clause.rs +++ b/tests/ui/moves/moves-based-on-type-capture-clause.rs diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs b/tests/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs index 4417fb926..4417fb926 100644 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs +++ b/tests/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr b/tests/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr index db4382b58..db4382b58 100644 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr +++ b/tests/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs b/tests/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs index d256e18b6..d256e18b6 100644 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs +++ b/tests/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr b/tests/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr index 0930df148..0930df148 100644 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr +++ b/tests/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr diff --git a/src/test/ui/moves/moves-based-on-type-exprs.rs b/tests/ui/moves/moves-based-on-type-exprs.rs index 4a52d8d32..4a52d8d32 100644 --- a/src/test/ui/moves/moves-based-on-type-exprs.rs +++ b/tests/ui/moves/moves-based-on-type-exprs.rs diff --git a/src/test/ui/moves/moves-based-on-type-exprs.stderr b/tests/ui/moves/moves-based-on-type-exprs.stderr index 838b1282c..ab7c27456 100644 --- a/src/test/ui/moves/moves-based-on-type-exprs.stderr +++ b/tests/ui/moves/moves-based-on-type-exprs.stderr @@ -160,15 +160,12 @@ LL | let _y = x.into_iter().next().unwrap(); LL | touch(&x); | ^^ value borrowed here after move | -note: this function takes ownership of the receiver `self`, which moves `x` +note: `into_iter` takes ownership of the receiver `self`, which moves `x` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL - | -LL | fn into_iter(self) -> Self::IntoIter; - | ^^^^ -help: consider cloning the value if the performance cost is acceptable +help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | let _y = x.clone().into_iter().next().unwrap(); - | ++++++++ + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-exprs.rs:83:11 @@ -180,15 +177,12 @@ LL | let _y = [x.into_iter().next().unwrap(); 1]; LL | touch(&x); | ^^ value borrowed here after move | -note: this function takes ownership of the receiver `self`, which moves `x` +note: `into_iter` takes ownership of the receiver `self`, which moves `x` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL - | -LL | fn into_iter(self) -> Self::IntoIter; - | ^^^^ -help: consider cloning the value if the performance cost is acceptable +help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | let _y = [x.clone().into_iter().next().unwrap(); 1]; - | ++++++++ + | ++++++++ error: aborting due to 11 previous errors diff --git a/src/test/ui/moves/moves-based-on-type-match-bindings.rs b/tests/ui/moves/moves-based-on-type-match-bindings.rs index 4fb9b40e8..4fb9b40e8 100644 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.rs +++ b/tests/ui/moves/moves-based-on-type-match-bindings.rs diff --git a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr b/tests/ui/moves/moves-based-on-type-match-bindings.stderr index 225935532..225935532 100644 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr +++ b/tests/ui/moves/moves-based-on-type-match-bindings.stderr diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs index 490d91ac1..490d91ac1 100644 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs +++ b/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr b/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr index 125e446c3..125e446c3 100644 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr +++ b/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs b/tests/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs index 86fd37e78..86fd37e78 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs +++ b/tests/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr b/tests/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr index 4759b4589..4759b4589 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr +++ b/tests/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr diff --git a/src/test/ui/moves/moves-based-on-type-tuple.rs b/tests/ui/moves/moves-based-on-type-tuple.rs index 2e67d8f8a..2e67d8f8a 100644 --- a/src/test/ui/moves/moves-based-on-type-tuple.rs +++ b/tests/ui/moves/moves-based-on-type-tuple.rs diff --git a/src/test/ui/moves/moves-based-on-type-tuple.stderr b/tests/ui/moves/moves-based-on-type-tuple.stderr index 0bcce3012..0bcce3012 100644 --- a/src/test/ui/moves/moves-based-on-type-tuple.stderr +++ b/tests/ui/moves/moves-based-on-type-tuple.stderr diff --git a/src/test/ui/moves/moves-sru-moved-field.rs b/tests/ui/moves/moves-sru-moved-field.rs index 72957c49f..72957c49f 100644 --- a/src/test/ui/moves/moves-sru-moved-field.rs +++ b/tests/ui/moves/moves-sru-moved-field.rs diff --git a/src/test/ui/moves/moves-sru-moved-field.stderr b/tests/ui/moves/moves-sru-moved-field.stderr index cf7213637..cf7213637 100644 --- a/src/test/ui/moves/moves-sru-moved-field.stderr +++ b/tests/ui/moves/moves-sru-moved-field.stderr diff --git a/tests/ui/moves/pin-mut-reborrow.fixed b/tests/ui/moves/pin-mut-reborrow.fixed new file mode 100644 index 000000000..e808186d7 --- /dev/null +++ b/tests/ui/moves/pin-mut-reborrow.fixed @@ -0,0 +1,15 @@ +// run-rustfix +use std::pin::Pin; + +struct Foo; + +impl Foo { + fn foo(self: Pin<&mut Self>) {} +} + +fn main() { + let mut foo = Foo; + let mut foo = Pin::new(&mut foo); + foo.as_mut().foo(); + foo.foo(); //~ ERROR use of moved value +} diff --git a/tests/ui/moves/pin-mut-reborrow.rs b/tests/ui/moves/pin-mut-reborrow.rs new file mode 100644 index 000000000..fee6236eb --- /dev/null +++ b/tests/ui/moves/pin-mut-reborrow.rs @@ -0,0 +1,15 @@ +// run-rustfix +use std::pin::Pin; + +struct Foo; + +impl Foo { + fn foo(self: Pin<&mut Self>) {} +} + +fn main() { + let mut foo = Foo; + let mut foo = Pin::new(&mut foo); + foo.foo(); + foo.foo(); //~ ERROR use of moved value +} diff --git a/tests/ui/moves/pin-mut-reborrow.stderr b/tests/ui/moves/pin-mut-reborrow.stderr new file mode 100644 index 000000000..16fa4bacc --- /dev/null +++ b/tests/ui/moves/pin-mut-reborrow.stderr @@ -0,0 +1,23 @@ +error[E0382]: use of moved value: `foo` + --> $DIR/pin-mut-reborrow.rs:14:5 + | +LL | let mut foo = Pin::new(&mut foo); + | ------- move occurs because `foo` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait +LL | foo.foo(); + | ----- `foo` moved due to this method call +LL | foo.foo(); + | ^^^ value used here after move + | +note: `Foo::foo` takes ownership of the receiver `self`, which moves `foo` + --> $DIR/pin-mut-reborrow.rs:7:12 + | +LL | fn foo(self: Pin<&mut Self>) {} + | ^^^^ +help: consider reborrowing the `Pin` instead of moving it + | +LL | foo.as_mut().foo(); + | +++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/moves/suggest-clone.fixed b/tests/ui/moves/suggest-clone.fixed new file mode 100644 index 000000000..204bfdb10 --- /dev/null +++ b/tests/ui/moves/suggest-clone.fixed @@ -0,0 +1,11 @@ +// run-rustfix + +#[derive(Clone)] +struct Foo; +impl Foo { + fn foo(self) {} +} +fn main() { + let foo = &Foo; + foo.clone().foo(); //~ ERROR cannot move out +} diff --git a/tests/ui/moves/suggest-clone.rs b/tests/ui/moves/suggest-clone.rs new file mode 100644 index 000000000..25dd9f006 --- /dev/null +++ b/tests/ui/moves/suggest-clone.rs @@ -0,0 +1,11 @@ +// run-rustfix + +#[derive(Clone)] +struct Foo; +impl Foo { + fn foo(self) {} +} +fn main() { + let foo = &Foo; + foo.foo(); //~ ERROR cannot move out +} diff --git a/tests/ui/moves/suggest-clone.stderr b/tests/ui/moves/suggest-clone.stderr new file mode 100644 index 000000000..cbb3dfea3 --- /dev/null +++ b/tests/ui/moves/suggest-clone.stderr @@ -0,0 +1,22 @@ +error[E0507]: cannot move out of `*foo` which is behind a shared reference + --> $DIR/suggest-clone.rs:10:5 + | +LL | foo.foo(); + | ^^^^----- + | | | + | | `*foo` moved due to this method call + | move occurs because `*foo` has type `Foo`, which does not implement the `Copy` trait + | +note: `Foo::foo` takes ownership of the receiver `self`, which moves `*foo` + --> $DIR/suggest-clone.rs:6:12 + | +LL | fn foo(self) {} + | ^^^^ +help: you can `clone` the value and consume it, but this might not be your desired behavior + | +LL | foo.clone().foo(); + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/moves/use_of_moved_value_clone_suggestions.rs b/tests/ui/moves/use_of_moved_value_clone_suggestions.rs index d5c8d4e6b..d5c8d4e6b 100644 --- a/src/test/ui/moves/use_of_moved_value_clone_suggestions.rs +++ b/tests/ui/moves/use_of_moved_value_clone_suggestions.rs diff --git a/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr b/tests/ui/moves/use_of_moved_value_clone_suggestions.stderr index 22e7951db..22e7951db 100644 --- a/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr +++ b/tests/ui/moves/use_of_moved_value_clone_suggestions.stderr diff --git a/src/test/ui/moves/use_of_moved_value_copy_suggestions.fixed b/tests/ui/moves/use_of_moved_value_copy_suggestions.fixed index 45acf5beb..45acf5beb 100644 --- a/src/test/ui/moves/use_of_moved_value_copy_suggestions.fixed +++ b/tests/ui/moves/use_of_moved_value_copy_suggestions.fixed diff --git a/src/test/ui/moves/use_of_moved_value_copy_suggestions.rs b/tests/ui/moves/use_of_moved_value_copy_suggestions.rs index 0a43dd1a9..0a43dd1a9 100644 --- a/src/test/ui/moves/use_of_moved_value_copy_suggestions.rs +++ b/tests/ui/moves/use_of_moved_value_copy_suggestions.rs diff --git a/src/test/ui/moves/use_of_moved_value_copy_suggestions.stderr b/tests/ui/moves/use_of_moved_value_copy_suggestions.stderr index 3e37fcb21..3e37fcb21 100644 --- a/src/test/ui/moves/use_of_moved_value_copy_suggestions.stderr +++ b/tests/ui/moves/use_of_moved_value_copy_suggestions.stderr |