summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/dont-suggest-ref
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/suggestions/dont-suggest-ref')
-rw-r--r--tests/ui/suggestions/dont-suggest-ref/duplicate-suggestions.rs131
-rw-r--r--tests/ui/suggestions/dont-suggest-ref/duplicate-suggestions.stderr309
-rw-r--r--tests/ui/suggestions/dont-suggest-ref/move-into-closure.rs138
-rw-r--r--tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr448
-rw-r--r--tests/ui/suggestions/dont-suggest-ref/simple.rs336
-rw-r--r--tests/ui/suggestions/dont-suggest-ref/simple.stderr985
6 files changed, 2347 insertions, 0 deletions
diff --git a/tests/ui/suggestions/dont-suggest-ref/duplicate-suggestions.rs b/tests/ui/suggestions/dont-suggest-ref/duplicate-suggestions.rs
new file mode 100644
index 000000000..e19d497f2
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-ref/duplicate-suggestions.rs
@@ -0,0 +1,131 @@
+#[derive(Clone)]
+enum Either {
+ One(X),
+ Two(X),
+}
+
+#[derive(Clone)]
+struct X(Y);
+
+#[derive(Clone)]
+struct Y;
+
+
+pub fn main() {
+ let e = Either::One(X(Y));
+ let mut em = Either::One(X(Y));
+
+ let r = &e;
+ let rm = &mut Either::One(X(Y));
+
+ let x = X(Y);
+ let mut xm = X(Y);
+
+ let s = &x;
+ let sm = &mut X(Y);
+
+ let ve = vec![Either::One(X(Y))];
+
+ let vr = &ve;
+ let vrm = &mut vec![Either::One(X(Y))];
+
+ let vx = vec![X(Y)];
+
+ let vs = &vx;
+ let vsm = &mut vec![X(Y)];
+
+ // test for duplicate suggestions
+
+ let &(X(_t), X(_u)) = &(x.clone(), x.clone());
+ //~^ ERROR cannot move
+ //~| HELP consider removing the borrow
+ if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the borrow
+ while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the borrow
+ match &(e.clone(), e.clone()) {
+ //~^ ERROR cannot move
+ &(Either::One(_t), Either::Two(_u)) => (),
+ //~^ HELP consider removing the borrow
+ &(Either::Two(_t), Either::One(_u)) => (),
+ //~^ HELP consider removing the borrow
+ _ => (),
+ }
+ match &(e.clone(), e.clone()) {
+ //~^ ERROR cannot move
+ &(Either::One(_t), Either::Two(_u))
+ //~^ HELP consider removing the borrow
+ | &(Either::Two(_t), Either::One(_u)) => (),
+ // FIXME: would really like a suggestion here too
+ _ => (),
+ }
+ match &(e.clone(), e.clone()) {
+ //~^ ERROR cannot move
+ &(Either::One(_t), Either::Two(_u)) => (),
+ //~^ HELP consider removing the borrow
+ &(Either::Two(ref _t), Either::One(ref _u)) => (),
+ _ => (),
+ }
+ match &(e.clone(), e.clone()) {
+ //~^ ERROR cannot move
+ &(Either::One(_t), Either::Two(_u)) => (),
+ //~^ HELP consider removing the borrow
+ (Either::Two(_t), Either::One(_u)) => (),
+ _ => (),
+ }
+ fn f5(&(X(_t), X(_u)): &(X, X)) { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the borrow
+
+ let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
+ //~^ ERROR cannot move
+ //~| HELP consider removing the mutable borrow
+ if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the mutable borrow
+ while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the mutable borrow
+ match &mut (em.clone(), em.clone()) {
+ //~^ ERROR cannot move
+ &mut (Either::One(_t), Either::Two(_u)) => (),
+ //~^ HELP consider removing the mutable borrow
+ &mut (Either::Two(_t), Either::One(_u)) => (),
+ //~^ HELP consider removing the mutable borrow
+ _ => (),
+ }
+ match &mut (em.clone(), em.clone()) {
+ //~^ ERROR cannot move
+ &mut (Either::One(_t), Either::Two(_u))
+ //~^ HELP consider removing the mutable borrow
+ | &mut (Either::Two(_t), Either::One(_u)) => (),
+ // FIXME: would really like a suggestion here too
+ _ => (),
+ }
+ match &mut (em.clone(), em.clone()) {
+ //~^ ERROR cannot move
+ &mut (Either::One(_t), Either::Two(_u)) => (),
+ //~^ HELP consider removing the mutable borrow
+ &mut (Either::Two(ref _t), Either::One(ref _u)) => (),
+ _ => (),
+ }
+ match &mut (em.clone(), em.clone()) {
+ //~^ ERROR cannot move
+ &mut (Either::One(_t), Either::Two(_u)) => (),
+ //~^ HELP consider removing the mutable borrow
+ &mut (Either::Two(ref mut _t), Either::One(ref mut _u)) => (),
+ _ => (),
+ }
+ match &mut (em.clone(), em.clone()) {
+ //~^ ERROR cannot move
+ &mut (Either::One(_t), Either::Two(_u)) => (),
+ //~^ HELP consider removing the mutable borrow
+ (Either::Two(_t), Either::One(_u)) => (),
+ _ => (),
+ }
+ fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the mutable borrow
+}
diff --git a/tests/ui/suggestions/dont-suggest-ref/duplicate-suggestions.stderr b/tests/ui/suggestions/dont-suggest-ref/duplicate-suggestions.stderr
new file mode 100644
index 000000000..b96b3713f
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-ref/duplicate-suggestions.stderr
@@ -0,0 +1,309 @@
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/duplicate-suggestions.rs:39:27
+ |
+LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
+ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | ...and here
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the borrow
+ |
+LL - let &(X(_t), X(_u)) = &(x.clone(), x.clone());
+LL + let (X(_t), X(_u)) = &(x.clone(), x.clone());
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/duplicate-suggestions.rs:42:50
+ |
+LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
+ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | ...and here
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the borrow
+ |
+LL - if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
+LL + if let (Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/duplicate-suggestions.rs:45:53
+ |
+LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
+ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | ...and here
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the borrow
+ |
+LL - while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
+LL + while let (Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/duplicate-suggestions.rs:48:11
+ |
+LL | match &(e.clone(), e.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &(Either::One(_t), Either::Two(_u)) => (),
+ | -- -- ...and here
+ | |
+ | data moved here
+LL |
+LL | &(Either::Two(_t), Either::One(_u)) => (),
+ | -- ...and here -- ...and here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the borrow
+ |
+LL - &(Either::One(_t), Either::Two(_u)) => (),
+LL + (Either::One(_t), Either::Two(_u)) => (),
+ |
+help: consider removing the borrow
+ |
+LL - &(Either::Two(_t), Either::One(_u)) => (),
+LL + (Either::Two(_t), Either::One(_u)) => (),
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/duplicate-suggestions.rs:56:11
+ |
+LL | match &(e.clone(), e.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &(Either::One(_t), Either::Two(_u))
+ | -- -- ...and here
+ | |
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the borrow
+ |
+LL - &(Either::One(_t), Either::Two(_u))
+LL + (Either::One(_t), Either::Two(_u))
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/duplicate-suggestions.rs:64:11
+ |
+LL | match &(e.clone(), e.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &(Either::One(_t), Either::Two(_u)) => (),
+ | -- -- ...and here
+ | |
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the borrow
+ |
+LL - &(Either::One(_t), Either::Two(_u)) => (),
+LL + (Either::One(_t), Either::Two(_u)) => (),
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/duplicate-suggestions.rs:71:11
+ |
+LL | match &(e.clone(), e.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &(Either::One(_t), Either::Two(_u)) => (),
+ | -- -- ...and here
+ | |
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the borrow
+ |
+LL - &(Either::One(_t), Either::Two(_u)) => (),
+LL + (Either::One(_t), Either::Two(_u)) => (),
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:82:31
+ |
+LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
+ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | ...and here
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
+LL + let (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:85:54
+ |
+LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
+ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | ...and here
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
+LL + if let (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:88:57
+ |
+LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
+ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | ...and here
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
+LL + while let (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:91:11
+ |
+LL | match &mut (em.clone(), em.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &mut (Either::One(_t), Either::Two(_u)) => (),
+ | -- -- ...and here
+ | |
+ | data moved here
+LL |
+LL | &mut (Either::Two(_t), Either::One(_u)) => (),
+ | -- ...and here -- ...and here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - &mut (Either::One(_t), Either::Two(_u)) => (),
+LL + (Either::One(_t), Either::Two(_u)) => (),
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut (Either::Two(_t), Either::One(_u)) => (),
+LL + (Either::Two(_t), Either::One(_u)) => (),
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:99:11
+ |
+LL | match &mut (em.clone(), em.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &mut (Either::One(_t), Either::Two(_u))
+ | -- -- ...and here
+ | |
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - &mut (Either::One(_t), Either::Two(_u))
+LL + (Either::One(_t), Either::Two(_u))
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:107:11
+ |
+LL | match &mut (em.clone(), em.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &mut (Either::One(_t), Either::Two(_u)) => (),
+ | -- -- ...and here
+ | |
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - &mut (Either::One(_t), Either::Two(_u)) => (),
+LL + (Either::One(_t), Either::Two(_u)) => (),
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:114:11
+ |
+LL | match &mut (em.clone(), em.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &mut (Either::One(_t), Either::Two(_u)) => (),
+ | -- -- ...and here
+ | |
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - &mut (Either::One(_t), Either::Two(_u)) => (),
+LL + (Either::One(_t), Either::Two(_u)) => (),
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:121:11
+ |
+LL | match &mut (em.clone(), em.clone()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | &mut (Either::One(_t), Either::Two(_u)) => (),
+ | -- -- ...and here
+ | |
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - &mut (Either::One(_t), Either::Two(_u)) => (),
+LL + (Either::One(_t), Either::Two(_u)) => (),
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/duplicate-suggestions.rs:78:11
+ |
+LL | fn f5(&(X(_t), X(_u)): &(X, X)) { }
+ | ^^^^--^^^^^--^^
+ | | |
+ | | ...and here
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the borrow
+ |
+LL - fn f5(&(X(_t), X(_u)): &(X, X)) { }
+LL + fn f5((X(_t), X(_u)): &(X, X)) { }
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/duplicate-suggestions.rs:128:11
+ |
+LL | fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
+ | ^^^^^^^^--^^^^^--^^
+ | | |
+ | | ...and here
+ | data moved here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
+LL + fn f6((X(_t), X(_u)): &mut (X, X)) { }
+ |
+
+error: aborting due to 17 previous errors
+
+For more information about this error, try `rustc --explain E0507`.
diff --git a/tests/ui/suggestions/dont-suggest-ref/move-into-closure.rs b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.rs
new file mode 100644
index 000000000..44eac3691
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.rs
@@ -0,0 +1,138 @@
+#[derive(Clone)]
+enum Either {
+ One(X),
+ Two(X),
+}
+
+#[derive(Clone)]
+struct X(Y);
+
+#[derive(Clone)]
+struct Y;
+
+fn consume_fn<F: Fn()>(_f: F) { }
+
+fn consume_fnmut<F: FnMut()>(_f: F) { }
+
+pub fn main() { }
+
+fn move_into_fn() {
+ let e = Either::One(X(Y));
+ let mut em = Either::One(X(Y));
+
+ let x = X(Y);
+
+ // move into Fn
+
+ consume_fn(|| {
+ let X(_t) = x;
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ if let Either::One(_t) = e { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ while let Either::One(_t) = e { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ match e {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t)
+ | Either::Two(_t) => (),
+ }
+ match e {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t) => (),
+ Either::Two(ref _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+
+ let X(mut _t) = x;
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ if let Either::One(mut _t) = em { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ while let Either::One(mut _t) = em { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ match em {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(mut _t)
+ | Either::Two(mut _t) => (),
+ }
+ match em {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(mut _t) => (),
+ Either::Two(ref _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+ });
+}
+
+fn move_into_fnmut() {
+ let e = Either::One(X(Y));
+ let mut em = Either::One(X(Y));
+
+ let x = X(Y);
+
+ // move into FnMut
+
+ consume_fnmut(|| {
+ let X(_t) = x;
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ if let Either::One(_t) = e { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ while let Either::One(_t) = e { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ match e {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t)
+ | Either::Two(_t) => (),
+ }
+ match e {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t) => (),
+ Either::Two(ref _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+
+ let X(mut _t) = x;
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ if let Either::One(mut _t) = em { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ while let Either::One(mut _t) = em { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ match em {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(mut _t)
+ | Either::Two(mut _t) => (),
+ }
+ match em {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(mut _t) => (),
+ Either::Two(ref _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+ match em {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(mut _t) => (),
+ Either::Two(ref mut _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+ });
+}
diff --git a/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr
new file mode 100644
index 000000000..edda2cbc7
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr
@@ -0,0 +1,448 @@
+error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:28:21
+ |
+LL | let x = X(Y);
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+LL | let X(_t) = x;
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | let X(_t) = &x;
+ | +
+
+error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:31:34
+ |
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | if let Either::One(_t) = e { }
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | if let Either::One(_t) = &e { }
+ | +
+
+error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:34:37
+ |
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | while let Either::One(_t) = e { }
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | while let Either::One(_t) = &e { }
+ | +
+
+error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:37:15
+ |
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | match e {
+ | ^
+...
+LL | Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &e {
+ | +
+
+error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:43:15
+ |
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | match e {
+ | ^
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &e {
+ | +
+
+error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:51:25
+ |
+LL | let x = X(Y);
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | let X(mut _t) = x;
+ | ------ ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | let X(mut _t) = &x;
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:54:38
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | if let Either::One(mut _t) = em { }
+ | ------ ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | if let Either::One(mut _t) = &em { }
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:57:41
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | while let Either::One(mut _t) = em { }
+ | ------ ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | while let Either::One(mut _t) = &em { }
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:60:15
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | match em {
+ | ^^
+...
+LL | Either::One(mut _t)
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &em {
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
+ --> $DIR/move-into-closure.rs:66:15
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | match em {
+ | ^^
+...
+LL | Either::One(mut _t) => (),
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &em {
+ | +
+
+error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:85:21
+ |
+LL | let x = X(Y);
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+LL | let X(_t) = x;
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | let X(_t) = &x;
+ | +
+
+error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:88:34
+ |
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | if let Either::One(_t) = e { }
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | if let Either::One(_t) = &e { }
+ | +
+
+error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:91:37
+ |
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | while let Either::One(_t) = e { }
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | while let Either::One(_t) = &e { }
+ | +
+
+error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:94:15
+ |
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match e {
+ | ^
+...
+LL | Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &e {
+ | +
+
+error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:100:15
+ |
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match e {
+ | ^
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &e {
+ | +
+
+error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:108:25
+ |
+LL | let x = X(Y);
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | let X(mut _t) = x;
+ | ------ ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | let X(mut _t) = &x;
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:111:38
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | if let Either::One(mut _t) = em { }
+ | ------ ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | if let Either::One(mut _t) = &em { }
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:114:41
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | while let Either::One(mut _t) = em { }
+ | ------ ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | while let Either::One(mut _t) = &em { }
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:117:15
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match em {
+ | ^^
+...
+LL | Either::One(mut _t)
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &em {
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:123:15
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match em {
+ | ^^
+...
+LL | Either::One(mut _t) => (),
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &em {
+ | +
+
+error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
+ --> $DIR/move-into-closure.rs:130:15
+ |
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match em {
+ | ^^
+...
+LL | Either::One(mut _t) => (),
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &em {
+ | +
+
+error: aborting due to 21 previous errors
+
+For more information about this error, try `rustc --explain E0507`.
diff --git a/tests/ui/suggestions/dont-suggest-ref/simple.rs b/tests/ui/suggestions/dont-suggest-ref/simple.rs
new file mode 100644
index 000000000..1e40e60a1
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-ref/simple.rs
@@ -0,0 +1,336 @@
+#[derive(Clone)]
+enum Either {
+ One(X),
+ Two(X),
+}
+
+#[derive(Clone)]
+struct X(Y);
+
+#[derive(Clone)]
+struct Y;
+
+pub fn main() {
+ let e = Either::One(X(Y));
+ let mut em = Either::One(X(Y));
+
+ let r = &e;
+ let rm = &mut Either::One(X(Y));
+
+ let x = X(Y);
+ let mut xm = X(Y);
+
+ let s = &x;
+ let sm = &mut X(Y);
+
+ let ve = vec![Either::One(X(Y))];
+
+ let vr = &ve;
+ let vrm = &mut vec![Either::One(X(Y))];
+
+ let vx = vec![X(Y)];
+
+ let vs = &vx;
+ let vsm = &mut vec![X(Y)];
+
+ // move from Either/X place
+
+ let X(_t) = *s;
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ if let Either::One(_t) = *r { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ while let Either::One(_t) = *r { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ match *r {
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ Either::One(_t)
+ | Either::Two(_t) => (),
+ }
+ match *r {
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ Either::One(_t) => (),
+ Either::Two(ref _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+
+ let X(_t) = *sm;
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ if let Either::One(_t) = *rm { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ while let Either::One(_t) = *rm { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ match *rm {
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ Either::One(_t)
+ | Either::Two(_t) => (),
+ }
+ match *rm {
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ Either::One(_t) => (),
+ Either::Two(ref _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+ match *rm {
+ //~^ ERROR cannot move
+ //~| HELP consider removing the dereference here
+ Either::One(_t) => (),
+ Either::Two(ref mut _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+
+ let X(_t) = vs[0];
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ if let Either::One(_t) = vr[0] { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ while let Either::One(_t) = vr[0] { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ match vr[0] {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t)
+ | Either::Two(_t) => (),
+ }
+ match vr[0] {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t) => (),
+ Either::Two(ref _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+
+ let X(_t) = vsm[0];
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ if let Either::One(_t) = vrm[0] { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ while let Either::One(_t) = vrm[0] { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ match vrm[0] {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t)
+ | Either::Two(_t) => (),
+ }
+ match vrm[0] {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t) => (),
+ Either::Two(ref _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+ match vrm[0] {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing here
+ Either::One(_t) => (),
+ Either::Two(ref mut _t) => (),
+ // FIXME: should suggest removing `ref` too
+ }
+
+ // move from &Either/&X place
+
+ let &X(_t) = s;
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ if let &Either::One(_t) = r { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ while let &Either::One(_t) = r { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ match r {
+ //~^ ERROR cannot move
+ &Either::One(_t)
+ //~^ HELP consider removing
+ | &Either::Two(_t) => (),
+ // FIXME: would really like a suggestion here too
+ }
+ match r {
+ //~^ ERROR cannot move
+ &Either::One(_t) => (),
+ //~^ HELP consider removing
+ &Either::Two(ref _t) => (),
+ }
+ match r {
+ //~^ ERROR cannot move
+ &Either::One(_t) => (),
+ //~^ HELP consider removing
+ Either::Two(_t) => (),
+ }
+ fn f1(&X(_t): &X) { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+
+ let &mut X(_t) = sm;
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ if let &mut Either::One(_t) = rm { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ while let &mut Either::One(_t) = rm { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ match rm {
+ //~^ ERROR cannot move
+ &mut Either::One(_t) => (),
+ //~^ HELP consider removing
+ &mut Either::Two(_t) => (),
+ //~^ HELP consider removing
+ }
+ match rm {
+ //~^ ERROR cannot move
+ &mut Either::One(_t) => (),
+ //~^ HELP consider removing
+ &mut Either::Two(ref _t) => (),
+ }
+ match rm {
+ //~^ ERROR cannot move
+ &mut Either::One(_t) => (),
+ //~^ HELP consider removing
+ &mut Either::Two(ref mut _t) => (),
+ }
+ match rm {
+ //~^ ERROR cannot move
+ &mut Either::One(_t) => (),
+ //~^ HELP consider removing
+ Either::Two(_t) => (),
+ }
+ fn f2(&mut X(_t): &mut X) { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+
+ // move from tuple of &Either/&X
+
+ // FIXME: These should have suggestions.
+
+ let (&X(_t),) = (&x.clone(),);
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+ if let (&Either::One(_t),) = (&e.clone(),) { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+ while let (&Either::One(_t),) = (&e.clone(),) { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+ match (&e.clone(),) {
+ //~^ ERROR cannot move
+ (&Either::One(_t),)
+ //~^ HELP consider borrowing the pattern binding
+ | (&Either::Two(_t),) => (),
+ }
+ fn f3((&X(_t),): (&X,)) { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+
+ let (&mut X(_t),) = (&mut xm.clone(),);
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+ if let (&mut Either::One(_t),) = (&mut em.clone(),) { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+ while let (&mut Either::One(_t),) = (&mut em.clone(),) { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+ match (&mut em.clone(),) {
+ //~^ ERROR cannot move
+ (&mut Either::One(_t),) => (),
+ //~^ HELP consider borrowing the pattern binding
+ (&mut Either::Two(_t),) => (),
+ //~^ HELP consider borrowing the pattern binding
+ }
+ fn f4((&mut X(_t),): (&mut X,)) { }
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+
+ // move from &Either/&X value
+
+ let &X(_t) = &x;
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ if let &Either::One(_t) = &e { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ while let &Either::One(_t) = &e { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ match &e {
+ //~^ ERROR cannot move
+ &Either::One(_t)
+ //~^ HELP consider removing
+ | &Either::Two(_t) => (),
+ // FIXME: would really like a suggestion here too
+ }
+ match &e {
+ //~^ ERROR cannot move
+ &Either::One(_t) => (),
+ //~^ HELP consider removing
+ &Either::Two(ref _t) => (),
+ }
+ match &e {
+ //~^ ERROR cannot move
+ &Either::One(_t) => (),
+ //~^ HELP consider removing
+ Either::Two(_t) => (),
+ }
+
+ let &mut X(_t) = &mut xm;
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ if let &mut Either::One(_t) = &mut em { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ while let &mut Either::One(_t) = &mut em { }
+ //~^ ERROR cannot move
+ //~| HELP consider removing
+ match &mut em {
+ //~^ ERROR cannot move
+ &mut Either::One(_t)
+ //~^ HELP consider removing
+ | &mut Either::Two(_t) => (),
+ // FIXME: would really like a suggestion here too
+ }
+ match &mut em {
+ //~^ ERROR cannot move
+ &mut Either::One(_t) => (),
+ //~^ HELP consider removing
+ &mut Either::Two(ref _t) => (),
+ }
+ match &mut em {
+ //~^ ERROR cannot move
+ &mut Either::One(_t) => (),
+ //~^ HELP consider removing
+ &mut Either::Two(ref mut _t) => (),
+ }
+ match &mut em {
+ //~^ ERROR cannot move
+ &mut Either::One(_t) => (),
+ //~^ HELP consider removing
+ Either::Two(_t) => (),
+ }
+}
+
+struct Testing {
+ a: Option<String>
+}
+
+fn testing(a: &Testing) {
+ let Some(_s) = a.a else {
+ //~^ ERROR cannot move
+ //~| HELP consider borrowing the pattern binding
+ return;
+ };
+}
diff --git a/tests/ui/suggestions/dont-suggest-ref/simple.stderr b/tests/ui/suggestions/dont-suggest-ref/simple.stderr
new file mode 100644
index 000000000..526326524
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-ref/simple.stderr
@@ -0,0 +1,985 @@
+error[E0507]: cannot move out of `s` which is behind a shared reference
+ --> $DIR/simple.rs:38:17
+ |
+LL | let X(_t) = *s;
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - let X(_t) = *s;
+LL + let X(_t) = s;
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
+ --> $DIR/simple.rs:41:30
+ |
+LL | if let Either::One(_t) = *r { }
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - if let Either::One(_t) = *r { }
+LL + if let Either::One(_t) = r { }
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
+ --> $DIR/simple.rs:44:33
+ |
+LL | while let Either::One(_t) = *r { }
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - while let Either::One(_t) = *r { }
+LL + while let Either::One(_t) = r { }
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `Two` which is behind a shared reference
+ --> $DIR/simple.rs:47:11
+ |
+LL | match *r {
+ | ^^
+...
+LL | Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - match *r {
+LL + match r {
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
+ --> $DIR/simple.rs:53:11
+ |
+LL | match *r {
+ | ^^
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - match *r {
+LL + match r {
+ |
+
+error[E0507]: cannot move out of `sm` which is behind a mutable reference
+ --> $DIR/simple.rs:61:17
+ |
+LL | let X(_t) = *sm;
+ | -- ^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - let X(_t) = *sm;
+LL + let X(_t) = sm;
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:64:30
+ |
+LL | if let Either::One(_t) = *rm { }
+ | -- ^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - if let Either::One(_t) = *rm { }
+LL + if let Either::One(_t) = rm { }
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:67:33
+ |
+LL | while let Either::One(_t) = *rm { }
+ | -- ^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - while let Either::One(_t) = *rm { }
+LL + while let Either::One(_t) = rm { }
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `Two` which is behind a mutable reference
+ --> $DIR/simple.rs:70:11
+ |
+LL | match *rm {
+ | ^^^
+...
+LL | Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - match *rm {
+LL + match rm {
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:76:11
+ |
+LL | match *rm {
+ | ^^^
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - match *rm {
+LL + match rm {
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:83:11
+ |
+LL | match *rm {
+ | ^^^
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the dereference here
+ |
+LL - match *rm {
+LL + match rm {
+ |
+
+error[E0507]: cannot move out of index of `Vec<X>`
+ --> $DIR/simple.rs:91:17
+ |
+LL | let X(_t) = vs[0];
+ | -- ^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | let X(_t) = &vs[0];
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:94:30
+ |
+LL | if let Either::One(_t) = vr[0] { }
+ | -- ^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | if let Either::One(_t) = &vr[0] { }
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:97:33
+ |
+LL | while let Either::One(_t) = vr[0] { }
+ | -- ^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | while let Either::One(_t) = &vr[0] { }
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:100:11
+ |
+LL | match vr[0] {
+ | ^^^^^
+...
+LL | Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &vr[0] {
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:106:11
+ |
+LL | match vr[0] {
+ | ^^^^^
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &vr[0] {
+ | +
+
+error[E0507]: cannot move out of index of `Vec<X>`
+ --> $DIR/simple.rs:114:17
+ |
+LL | let X(_t) = vsm[0];
+ | -- ^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | let X(_t) = &vsm[0];
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:117:30
+ |
+LL | if let Either::One(_t) = vrm[0] { }
+ | -- ^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | if let Either::One(_t) = &vrm[0] { }
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:120:33
+ |
+LL | while let Either::One(_t) = vrm[0] { }
+ | -- ^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | while let Either::One(_t) = &vrm[0] { }
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:123:11
+ |
+LL | match vrm[0] {
+ | ^^^^^^
+...
+LL | Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &vrm[0] {
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:129:11
+ |
+LL | match vrm[0] {
+ | ^^^^^^
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &vrm[0] {
+ | +
+
+error[E0507]: cannot move out of index of `Vec<Either>`
+ --> $DIR/simple.rs:136:11
+ |
+LL | match vrm[0] {
+ | ^^^^^^
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing here
+ |
+LL | match &vrm[0] {
+ | +
+
+error[E0507]: cannot move out of `s` which is behind a shared reference
+ --> $DIR/simple.rs:146:18
+ |
+LL | let &X(_t) = s;
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - let &X(_t) = s;
+LL + let X(_t) = s;
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
+ --> $DIR/simple.rs:149:31
+ |
+LL | if let &Either::One(_t) = r { }
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - if let &Either::One(_t) = r { }
+LL + if let Either::One(_t) = r { }
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
+ --> $DIR/simple.rs:152:34
+ |
+LL | while let &Either::One(_t) = r { }
+ | -- ^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - while let &Either::One(_t) = r { }
+LL + while let Either::One(_t) = r { }
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `Two` which is behind a shared reference
+ --> $DIR/simple.rs:155:11
+ |
+LL | match r {
+ | ^
+LL |
+LL | &Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - &Either::One(_t)
+LL + Either::One(_t)
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
+ --> $DIR/simple.rs:162:11
+ |
+LL | match r {
+ | ^
+LL |
+LL | &Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - &Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
+ --> $DIR/simple.rs:168:11
+ |
+LL | match r {
+ | ^
+LL |
+LL | &Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - &Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of `sm` which is behind a mutable reference
+ --> $DIR/simple.rs:178:22
+ |
+LL | let &mut X(_t) = sm;
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - let &mut X(_t) = sm;
+LL + let X(_t) = sm;
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:181:35
+ |
+LL | if let &mut Either::One(_t) = rm { }
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - if let &mut Either::One(_t) = rm { }
+LL + if let Either::One(_t) = rm { }
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:184:38
+ |
+LL | while let &mut Either::One(_t) = rm { }
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - while let &mut Either::One(_t) = rm { }
+LL + while let Either::One(_t) = rm { }
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `Two` which is behind a mutable reference
+ --> $DIR/simple.rs:187:11
+ |
+LL | match rm {
+ | ^^
+LL |
+LL | &mut Either::One(_t) => (),
+ | -- data moved here
+LL |
+LL | &mut Either::Two(_t) => (),
+ | -- ...and here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::Two(_t) => (),
+LL + Either::Two(_t) => (),
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:194:11
+ |
+LL | match rm {
+ | ^^
+LL |
+LL | &mut Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:200:11
+ |
+LL | match rm {
+ | ^^
+LL |
+LL | &mut Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
+ --> $DIR/simple.rs:206:11
+ |
+LL | match rm {
+ | ^^
+LL |
+LL | &mut Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:220:21
+ |
+LL | let (&X(_t),) = (&x.clone(),);
+ | -- ^^^^^^^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | let (&X(ref _t),) = (&x.clone(),);
+ | +++
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:223:34
+ |
+LL | if let (&Either::One(_t),) = (&e.clone(),) { }
+ | -- ^^^^^^^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | if let (&Either::One(ref _t),) = (&e.clone(),) { }
+ | +++
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:226:37
+ |
+LL | while let (&Either::One(_t),) = (&e.clone(),) { }
+ | -- ^^^^^^^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | while let (&Either::One(ref _t),) = (&e.clone(),) { }
+ | +++
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:229:11
+ |
+LL | match (&e.clone(),) {
+ | ^^^^^^^^^^^^^
+LL |
+LL | (&Either::One(_t),)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | (&Either::One(ref _t),)
+ | +++
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:239:25
+ |
+LL | let (&mut X(_t),) = (&mut xm.clone(),);
+ | -- ^^^^^^^^^^^^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | let (&mut X(ref _t),) = (&mut xm.clone(),);
+ | +++
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:242:38
+ |
+LL | if let (&mut Either::One(_t),) = (&mut em.clone(),) { }
+ | -- ^^^^^^^^^^^^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | if let (&mut Either::One(ref _t),) = (&mut em.clone(),) { }
+ | +++
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:245:41
+ |
+LL | while let (&mut Either::One(_t),) = (&mut em.clone(),) { }
+ | -- ^^^^^^^^^^^^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | while let (&mut Either::One(ref _t),) = (&mut em.clone(),) { }
+ | +++
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:248:11
+ |
+LL | match (&mut em.clone(),) {
+ | ^^^^^^^^^^^^^^^^^^
+LL |
+LL | (&mut Either::One(_t),) => (),
+ | -- data moved here
+LL |
+LL | (&mut Either::Two(_t),) => (),
+ | -- ...and here
+ |
+ = note: move occurs because these variables have types that don't implement the `Copy` trait
+help: consider borrowing the pattern binding
+ |
+LL | (&mut Either::One(ref _t),) => (),
+ | +++
+help: consider borrowing the pattern binding
+ |
+LL | (&mut Either::Two(ref _t),) => (),
+ | +++
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:261:18
+ |
+LL | let &X(_t) = &x;
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - let &X(_t) = &x;
+LL + let X(_t) = &x;
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:264:31
+ |
+LL | if let &Either::One(_t) = &e { }
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - if let &Either::One(_t) = &e { }
+LL + if let Either::One(_t) = &e { }
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:267:34
+ |
+LL | while let &Either::One(_t) = &e { }
+ | -- ^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - while let &Either::One(_t) = &e { }
+LL + while let Either::One(_t) = &e { }
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:270:11
+ |
+LL | match &e {
+ | ^^
+LL |
+LL | &Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - &Either::One(_t)
+LL + Either::One(_t)
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:277:11
+ |
+LL | match &e {
+ | ^^
+LL |
+LL | &Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - &Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:283:11
+ |
+LL | match &e {
+ | ^^
+LL |
+LL | &Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - &Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:290:22
+ |
+LL | let &mut X(_t) = &mut xm;
+ | -- ^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - let &mut X(_t) = &mut xm;
+LL + let X(_t) = &mut xm;
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:293:35
+ |
+LL | if let &mut Either::One(_t) = &mut em { }
+ | -- ^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - if let &mut Either::One(_t) = &mut em { }
+LL + if let Either::One(_t) = &mut em { }
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:296:38
+ |
+LL | while let &mut Either::One(_t) = &mut em { }
+ | -- ^^^^^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - while let &mut Either::One(_t) = &mut em { }
+LL + while let Either::One(_t) = &mut em { }
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:299:11
+ |
+LL | match &mut em {
+ | ^^^^^^^
+LL |
+LL | &mut Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::One(_t)
+LL + Either::One(_t)
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:306:11
+ |
+LL | match &mut em {
+ | ^^^^^^^
+LL |
+LL | &mut Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:312:11
+ |
+LL | match &mut em {
+ | ^^^^^^^
+LL |
+LL | &mut Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:318:11
+ |
+LL | match &mut em {
+ | ^^^^^^^
+LL |
+LL | &mut Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - &mut Either::One(_t) => (),
+LL + Either::One(_t) => (),
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:174:11
+ |
+LL | fn f1(&X(_t): &X) { }
+ | ^^^--^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider removing the borrow
+ |
+LL - fn f1(&X(_t): &X) { }
+LL + fn f1(X(_t): &X) { }
+ |
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:212:11
+ |
+LL | fn f2(&mut X(_t): &mut X) { }
+ | ^^^^^^^--^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider removing the mutable borrow
+ |
+LL - fn f2(&mut X(_t): &mut X) { }
+LL + fn f2(X(_t): &mut X) { }
+ |
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/simple.rs:235:11
+ |
+LL | fn f3((&X(_t),): (&X,)) { }
+ | ^^^^--^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | fn f3((&X(ref _t),): (&X,)) { }
+ | +++
+
+error[E0507]: cannot move out of a mutable reference
+ --> $DIR/simple.rs:255:11
+ |
+LL | fn f4((&mut X(_t),): (&mut X,)) { }
+ | ^^^^^^^^--^^^
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | fn f4((&mut X(ref _t),): (&mut X,)) { }
+ | +++
+
+error[E0507]: cannot move out of `a.a` as enum variant `Some` which is behind a shared reference
+ --> $DIR/simple.rs:331:20
+ |
+LL | let Some(_s) = a.a else {
+ | -- ^^^
+ | |
+ | data moved here
+ | move occurs because `_s` has type `String`, which does not implement the `Copy` trait
+ |
+help: consider borrowing the pattern binding
+ |
+LL | let Some(ref _s) = a.a else {
+ | +++
+
+error: aborting due to 61 previous errors
+
+For more information about this error, try `rustc --explain E0507`.