summaryrefslogtreecommitdiffstats
path: root/src/test/ui/moves
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/moves')
-rw-r--r--src/test/ui/moves/borrow-closures-instead-of-move.stderr15
-rw-r--r--src/test/ui/moves/issue-46099-move-in-macro.stderr5
-rw-r--r--src/test/ui/moves/issue-72649-uninit-in-loop.rs6
-rw-r--r--src/test/ui/moves/issue-72649-uninit-in-loop.stderr10
-rw-r--r--src/test/ui/moves/move-fn-self-receiver.stderr10
-rw-r--r--src/test/ui/moves/move-guard-same-consts.stderr12
-rw-r--r--src/test/ui/moves/move-in-guard-1.stderr12
-rw-r--r--src/test/ui/moves/move-in-guard-2.stderr12
-rw-r--r--src/test/ui/moves/moves-based-on-type-access-to-field.stderr4
-rw-r--r--src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr2
-rw-r--r--src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr10
-rw-r--r--src/test/ui/moves/moves-based-on-type-exprs.stderr60
-rw-r--r--src/test/ui/moves/moves-based-on-type-match-bindings.stderr4
-rw-r--r--src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs4
-rw-r--r--src/test/ui/moves/moves-based-on-type-tuple.stderr5
-rw-r--r--src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr5
16 files changed, 168 insertions, 8 deletions
diff --git a/src/test/ui/moves/borrow-closures-instead-of-move.stderr b/src/test/ui/moves/borrow-closures-instead-of-move.stderr
index 3146b6959..9a84ddef7 100644
--- a/src/test/ui/moves/borrow-closures-instead-of-move.stderr
+++ b/src/test/ui/moves/borrow-closures-instead-of-move.stderr
@@ -4,9 +4,17 @@ error[E0382]: use of moved value: `f`
LL | fn takes_fn(f: impl Fn()) {
| - move occurs because `f` has type `impl Fn()`, which does not implement the `Copy` trait
LL | loop {
+ | ---- inside of this loop
LL | takes_fnonce(f);
| ^ value moved here, in previous iteration of loop
|
+note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
+ --> $DIR/borrow-closures-instead-of-move.rs:34:20
+ |
+LL | fn takes_fnonce(_: impl FnOnce()) {}
+ | ------------ ^^^^^^^^^^^^^ this parameter takes ownership of the value
+ | |
+ | in this function
help: consider borrowing `f`
|
LL | takes_fnonce(&f);
@@ -24,6 +32,13 @@ LL | takes_fnonce(m);
LL | takes_fnonce(m);
| ^ value used here after move
|
+note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
+ --> $DIR/borrow-closures-instead-of-move.rs:34:20
+ |
+LL | fn takes_fnonce(_: impl FnOnce()) {}
+ | ------------ ^^^^^^^^^^^^^ this parameter takes ownership of the value
+ | |
+ | in this function
help: consider mutably borrowing `m`
|
LL | takes_fnonce(&mut m);
diff --git a/src/test/ui/moves/issue-46099-move-in-macro.stderr b/src/test/ui/moves/issue-46099-move-in-macro.stderr
index baa87e3e9..94bc9e6f4 100644
--- a/src/test/ui/moves/issue-46099-move-in-macro.stderr
+++ b/src/test/ui/moves/issue-46099-move-in-macro.stderr
@@ -5,6 +5,11 @@ LL | let b = Box::new(true);
| - move occurs because `b` has type `Box<bool>`, which does not implement the `Copy` trait
LL | test!({b});
| ^ value used here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | test!({b.clone()});
+ | ++++++++
error: aborting due to previous error
diff --git a/src/test/ui/moves/issue-72649-uninit-in-loop.rs b/src/test/ui/moves/issue-72649-uninit-in-loop.rs
index d76b69ecd..56c225bab 100644
--- a/src/test/ui/moves/issue-72649-uninit-in-loop.rs
+++ b/src/test/ui/moves/issue-72649-uninit-in-loop.rs
@@ -25,7 +25,7 @@ fn moved_here_1() {
fn moved_here_2() {
let value = NonCopy{};
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
- loop {
+ loop { //~ NOTE inside of this loop
let _used = value;
//~^ NOTE value moved here
loop {
@@ -38,7 +38,7 @@ fn moved_here_2() {
fn moved_loop_1() {
let value = NonCopy{};
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
- loop {
+ loop { //~ NOTE inside of this loop
let _used = value; //~ ERROR use of moved value: `value`
//~^ NOTE value moved here, in previous iteration of loop
}
@@ -49,7 +49,7 @@ fn moved_loop_2() {
//~^ NOTE move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
let _used = value;
value = NonCopy{};
- loop {
+ loop { //~ NOTE inside of this loop
let _used2 = value; //~ ERROR use of moved value: `value`
//~^ NOTE value moved here, in previous iteration of loop
}
diff --git a/src/test/ui/moves/issue-72649-uninit-in-loop.stderr b/src/test/ui/moves/issue-72649-uninit-in-loop.stderr
index 974994223..7e119fe8c 100644
--- a/src/test/ui/moves/issue-72649-uninit-in-loop.stderr
+++ b/src/test/ui/moves/issue-72649-uninit-in-loop.stderr
@@ -15,7 +15,9 @@ error[E0382]: use of moved value: `value`
|
LL | let value = NonCopy{};
| ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
-...
+LL |
+LL | loop {
+ | ---- inside of this loop
LL | let _used = value;
| ----- value moved here
...
@@ -27,7 +29,9 @@ error[E0382]: use of moved value: `value`
|
LL | let value = NonCopy{};
| ----- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
-...
+LL |
+LL | loop {
+ | ---- inside of this loop
LL | let _used = value;
| ^^^^^ value moved here, in previous iteration of loop
@@ -37,6 +41,8 @@ error[E0382]: use of moved value: `value`
LL | let mut value = NonCopy{};
| --------- move occurs because `value` has type `NonCopy`, which does not implement the `Copy` trait
...
+LL | loop {
+ | ---- inside of this loop
LL | let _used2 = value;
| ^^^^^ value moved here, in previous iteration of loop
diff --git a/src/test/ui/moves/move-fn-self-receiver.stderr b/src/test/ui/moves/move-fn-self-receiver.stderr
index 3a686121a..c13dc5882 100644
--- a/src/test/ui/moves/move-fn-self-receiver.stderr
+++ b/src/test/ui/moves/move-fn-self-receiver.stderr
@@ -96,6 +96,10 @@ note: this function takes ownership of the receiver `self`, which moves `rc_foo`
|
LL | fn use_rc_self(self: Rc<Self>) {}
| ^^^^
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | rc_foo.clone().use_rc_self();
+ | ++++++++
error[E0382]: use of moved value: `foo_add`
--> $DIR/move-fn-self-receiver.rs:59:5
@@ -137,6 +141,11 @@ LL | for _val in explicit_into_iter.into_iter() {}
| ----------- `explicit_into_iter` moved due to this method call
LL | explicit_into_iter;
| ^^^^^^^^^^^^^^^^^^ value used here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+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
@@ -160,6 +169,7 @@ error[E0382]: use of moved value: `foo2`
LL | let foo2 = Foo;
| ---- move occurs because `foo2` has type `Foo`, which does not implement the `Copy` trait
LL | loop {
+ | ---- inside of this loop
LL | foo2.use_self();
| ^^^^ ---------- `foo2` moved due to this method call, in previous iteration of loop
diff --git a/src/test/ui/moves/move-guard-same-consts.stderr b/src/test/ui/moves/move-guard-same-consts.stderr
index 2048fefef..86e5f6524 100644
--- a/src/test/ui/moves/move-guard-same-consts.stderr
+++ b/src/test/ui/moves/move-guard-same-consts.stderr
@@ -8,6 +8,18 @@ LL | (1, 2) if take(x) => (),
| - value moved here
LL | (1, 2) if take(x) => (),
| ^ value used here after move
+ |
+note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
+ --> $DIR/move-guard-same-consts.rs:25:15
+ |
+LL | fn take<T>(_: T) -> bool { false }
+ | ---- ^ this parameter takes ownership of the value
+ | |
+ | in this function
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | (1, 2) if take(x.clone()) => (),
+ | ++++++++
error: aborting due to previous error
diff --git a/src/test/ui/moves/move-in-guard-1.stderr b/src/test/ui/moves/move-in-guard-1.stderr
index 5e9aa66b9..f04cb34d7 100644
--- a/src/test/ui/moves/move-in-guard-1.stderr
+++ b/src/test/ui/moves/move-in-guard-1.stderr
@@ -8,6 +8,18 @@ LL | (1, _) if take(x) => (),
| - value moved here
LL | (_, 2) if take(x) => (),
| ^ value used here after move
+ |
+note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
+ --> $DIR/move-in-guard-1.rs:15:15
+ |
+LL | fn take<T>(_: T) -> bool { false }
+ | ---- ^ this parameter takes ownership of the value
+ | |
+ | in this function
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | (1, _) if take(x.clone()) => (),
+ | ++++++++
error: aborting due to previous error
diff --git a/src/test/ui/moves/move-in-guard-2.stderr b/src/test/ui/moves/move-in-guard-2.stderr
index 8d636c11b..26047861f 100644
--- a/src/test/ui/moves/move-in-guard-2.stderr
+++ b/src/test/ui/moves/move-in-guard-2.stderr
@@ -6,6 +6,18 @@ LL | let x: Box<_> = Box::new(1);
...
LL | (_, 2) if take(x) => (),
| ^ value used here after move
+ |
+note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
+ --> $DIR/move-in-guard-2.rs:13:15
+ |
+LL | fn take<T>(_: T) -> bool { false }
+ | ---- ^ this parameter takes ownership of the value
+ | |
+ | in this function
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | (_, 2) if take(x.clone()) => (),
+ | ++++++++
error: aborting due to previous error
diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr
index 3cc8ca291..a49ee31b4 100644
--- a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr
+++ b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr
@@ -13,6 +13,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | consume(x.clone().into_iter().next().unwrap());
+ | ++++++++
error: aborting due to previous error
diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr
index a315bbaab..db4382b58 100644
--- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr
+++ b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr
@@ -8,7 +8,7 @@ LL | consume(node) + r
| ^^^^ value used here after partial move
|
= note: partial move occurs because value has type `Box<List>`, which does not implement the `Copy` trait
-help: borrow this field in the pattern to avoid moving `node.next.0`
+help: borrow this binding in the pattern to avoid moving the value
|
LL | Some(ref right) => consume(right),
| +++
diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr
index ee7971691..0930df148 100644
--- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr
+++ b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr
@@ -9,6 +9,11 @@ LL | let _y = Foo { f:x };
LL |
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | let _y = Foo { f:x.clone() };
+ | ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11
@@ -21,6 +26,11 @@ LL | let _y = Foo { f:(((x))) };
LL |
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | let _y = Foo { f:(((x))).clone() };
+ | ++++++++
error: aborting due to 2 previous errors
diff --git a/src/test/ui/moves/moves-based-on-type-exprs.stderr b/src/test/ui/moves/moves-based-on-type-exprs.stderr
index 9bcec3674..838b1282c 100644
--- a/src/test/ui/moves/moves-based-on-type-exprs.stderr
+++ b/src/test/ui/moves/moves-based-on-type-exprs.stderr
@@ -7,6 +7,11 @@ LL | let _y = Foo { f:x };
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | let _y = Foo { f:x.clone() };
+ | ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:18:11
@@ -17,6 +22,11 @@ LL | let _y = (x, 3);
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | let _y = (x.clone(), 3);
+ | ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:35:11
@@ -29,6 +39,11 @@ LL | x
...
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | x.clone()
+ | ++++++++
error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:36:11
@@ -41,6 +56,11 @@ LL | y
...
LL | touch(&y);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | y.clone()
+ | ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:46:11
@@ -53,6 +73,11 @@ LL | true => x,
...
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | true => x.clone(),
+ | ++++++++
error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:47:11
@@ -65,6 +90,11 @@ LL | false => y
...
LL | touch(&y);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | false => y.clone()
+ | ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:58:11
@@ -77,6 +107,18 @@ LL | _ if guard(x) => 10,
...
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+note: consider changing this parameter type in function `guard` to borrow instead if owning the value isn't necessary
+ --> $DIR/moves-based-on-type-exprs.rs:6:14
+ |
+LL | fn guard(_s: String) -> bool {panic!()}
+ | ----- ^^^^^^ this parameter takes ownership of the value
+ | |
+ | in this function
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | _ if guard(x.clone()) => 10,
+ | ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:65:11
@@ -87,6 +129,11 @@ LL | let _y = [x];
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | let _y = [x.clone()];
+ | ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:71:11
@@ -97,6 +144,11 @@ LL | let _y = vec![x];
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | let _y = vec![x.clone()];
+ | ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:77:11
@@ -113,6 +165,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
+help: consider cloning the value if the performance cost is acceptable
+ |
+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
@@ -129,6 +185,10 @@ note: this function takes ownership of the receiver `self`, which moves `x`
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
+help: consider cloning the value if the performance cost is acceptable
+ |
+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.stderr b/src/test/ui/moves/moves-based-on-type-match-bindings.stderr
index ad1a2db8b..225935532 100644
--- a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr
+++ b/src/test/ui/moves/moves-based-on-type-match-bindings.stderr
@@ -8,6 +8,10 @@ LL | touch(&x);
| ^^ value borrowed here after partial move
|
= note: partial move occurs because `x.f` has type `String`, which does not implement the `Copy` trait
+help: borrow this binding in the pattern to avoid moving the value
+ |
+LL | Foo {ref f} => {}
+ | +++
error: aborting due to previous error
diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs
index 76b7aab54..490d91ac1 100644
--- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs
+++ b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs
@@ -1,6 +1,6 @@
-#![feature(unboxed_closures)]
+#![feature(unboxed_closures, tuple_trait)]
-fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
+fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f }
fn test(_x: Box<usize>) {}
diff --git a/src/test/ui/moves/moves-based-on-type-tuple.stderr b/src/test/ui/moves/moves-based-on-type-tuple.stderr
index eef8ce61f..0bcce3012 100644
--- a/src/test/ui/moves/moves-based-on-type-tuple.stderr
+++ b/src/test/ui/moves/moves-based-on-type-tuple.stderr
@@ -8,6 +8,11 @@ LL | Box::new((x, x))
| - ^ value used here after move
| |
| value moved here
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | Box::new((x.clone(), x))
+ | ++++++++
error: aborting due to previous error
diff --git a/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr b/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr
index c25981e6f..22e7951db 100644
--- a/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr
+++ b/src/test/ui/moves/use_of_moved_value_clone_suggestions.stderr
@@ -7,6 +7,11 @@ LL | (t, t)
| - ^ value used here after move
| |
| value moved here
+ |
+help: consider cloning the value if the performance cost is acceptable
+ |
+LL | (t.clone(), t)
+ | ++++++++
error: aborting due to previous error