From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../dont-suggest-ref/duplicate-suggestions.rs | 150 +++++ .../dont-suggest-ref/duplicate-suggestions.stderr | 262 ++++++++ .../dont-suggest-ref/move-into-closure.rs | 159 +++++ .../dont-suggest-ref/move-into-closure.stderr | 343 +++++++++++ src/test/ui/suggestions/dont-suggest-ref/simple.rs | 364 +++++++++++ .../ui/suggestions/dont-suggest-ref/simple.stderr | 680 +++++++++++++++++++++ 6 files changed, 1958 insertions(+) create mode 100644 src/test/ui/suggestions/dont-suggest-ref/duplicate-suggestions.rs create mode 100644 src/test/ui/suggestions/dont-suggest-ref/duplicate-suggestions.stderr create mode 100644 src/test/ui/suggestions/dont-suggest-ref/move-into-closure.rs create mode 100644 src/test/ui/suggestions/dont-suggest-ref/move-into-closure.stderr create mode 100644 src/test/ui/suggestions/dont-suggest-ref/simple.rs create mode 100644 src/test/ui/suggestions/dont-suggest-ref/simple.stderr (limited to 'src/test/ui/suggestions/dont-suggest-ref') diff --git a/src/test/ui/suggestions/dont-suggest-ref/duplicate-suggestions.rs b/src/test/ui/suggestions/dont-suggest-ref/duplicate-suggestions.rs new file mode 100644 index 000000000..bf0c1dc27 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-ref/duplicate-suggestions.rs @@ -0,0 +1,150 @@ +#[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 `&` + //~| SUGGESTION (X(_t), X(_u)) + if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { } + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { } + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + match &(e.clone(), e.clone()) { + //~^ ERROR cannot move + &(Either::One(_t), Either::Two(_u)) => (), + //~^ HELP consider removing the `&` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + &(Either::Two(_t), Either::One(_u)) => (), + //~^ HELP consider removing the `&` + //~| SUGGESTION (Either::Two(_t), Either::One(_u)) + _ => (), + } + match &(e.clone(), e.clone()) { + //~^ ERROR cannot move + &(Either::One(_t), Either::Two(_u)) + //~^ HELP consider removing the `&` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + | &(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 `&` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + &(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 `&` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + (Either::Two(_t), Either::One(_u)) => (), + _ => (), + } + fn f5(&(X(_t), X(_u)): &(X, X)) { } + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION (X(_t), X(_u)) + + let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone()); + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION (X(_t), X(_u)) + if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { } + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { } + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + match &mut (em.clone(), em.clone()) { + //~^ ERROR cannot move + &mut (Either::One(_t), Either::Two(_u)) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + &mut (Either::Two(_t), Either::One(_u)) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION (Either::Two(_t), Either::One(_u)) + _ => (), + } + match &mut (em.clone(), em.clone()) { + //~^ ERROR cannot move + &mut (Either::One(_t), Either::Two(_u)) + //~^ HELP consider removing the `&mut` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + | &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 `&mut` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + &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 `&mut` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + &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 `&mut` + //~| SUGGESTION (Either::One(_t), Either::Two(_u)) + (Either::Two(_t), Either::One(_u)) => (), + _ => (), + } + fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { } + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION (X(_t), X(_u)) +} diff --git a/src/test/ui/suggestions/dont-suggest-ref/duplicate-suggestions.stderr b/src/test/ui/suggestions/dont-suggest-ref/duplicate-suggestions.stderr new file mode 100644 index 000000000..40ad671f9 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-ref/duplicate-suggestions.stderr @@ -0,0 +1,262 @@ +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 + | help: consider removing the `&`: `(X(_t), X(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/duplicate-suggestions.rs:43:50 + | +LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { } + | ----------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/duplicate-suggestions.rs:47:53 + | +LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { } + | ----------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/duplicate-suggestions.rs:51:11 + | +LL | match &(e.clone(), e.clone()) { + | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | &(Either::One(_t), Either::Two(_u)) => (), + | -- -- ...and here + | | + | data moved here +... +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 `&` + | +LL | (Either::One(_t), Either::Two(_u)) => (), + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +help: consider removing the `&` + | +LL | (Either::Two(_t), Either::One(_u)) => (), + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error[E0507]: cannot move out of a shared reference + --> $DIR/duplicate-suggestions.rs:61: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 `&` + | +LL ~ (Either::One(_t), Either::Two(_u)) +LL + +LL + +LL ~ | &(Either::Two(_t), Either::One(_u)) => (), + | + +error[E0507]: cannot move out of a shared reference + --> $DIR/duplicate-suggestions.rs:70:11 + | +LL | match &(e.clone(), e.clone()) { + | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | &(Either::One(_t), Either::Two(_u)) => (), + | ----------------------------------- + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/duplicate-suggestions.rs:78:11 + | +LL | match &(e.clone(), e.clone()) { + | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | &(Either::One(_t), Either::Two(_u)) => (), + | ----------------------------------- + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:91:31 + | +LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone()); + | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `(X(_t), X(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:95:54 + | +LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { } + | --------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:99:57 + | +LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { } + | --------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:103:11 + | +LL | match &mut (em.clone(), em.clone()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | &mut (Either::One(_t), Either::Two(_u)) => (), + | -- -- ...and here + | | + | data moved here +... +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 `&mut` + | +LL | (Either::One(_t), Either::Two(_u)) => (), + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +help: consider removing the `&mut` + | +LL | (Either::Two(_t), Either::One(_u)) => (), + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:113: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 `&mut` + | +LL ~ (Either::One(_t), Either::Two(_u)) +LL + +LL + +LL ~ | &mut (Either::Two(_t), Either::One(_u)) => (), + | + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:122:11 + | +LL | match &mut (em.clone(), em.clone()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | &mut (Either::One(_t), Either::Two(_u)) => (), + | --------------------------------------- + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:130:11 + | +LL | match &mut (em.clone(), em.clone()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | &mut (Either::One(_t), Either::Two(_u)) => (), + | --------------------------------------- + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:138:11 + | +LL | match &mut (em.clone(), em.clone()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | &mut (Either::One(_t), Either::Two(_u)) => (), + | --------------------------------------- + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/duplicate-suggestions.rs:86:11 + | +LL | fn f5(&(X(_t), X(_u)): &(X, X)) { } + | ^^^^--^^^^^--^^ + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&`: `(X(_t), X(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a mutable reference + --> $DIR/duplicate-suggestions.rs:146:11 + | +LL | fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { } + | ^^^^^^^^--^^^^^--^^ + | | | | + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `(X(_t), X(_u))` + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error: aborting due to 17 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/suggestions/dont-suggest-ref/move-into-closure.rs b/src/test/ui/suggestions/dont-suggest-ref/move-into-closure.rs new file mode 100644 index 000000000..f1e043c30 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-ref/move-into-closure.rs @@ -0,0 +1,159 @@ +#[derive(Clone)] +enum Either { + One(X), + Two(X), +} + +#[derive(Clone)] +struct X(Y); + +#[derive(Clone)] +struct Y; + +fn consume_fn(_f: F) { } + +fn consume_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 + //~| SUGGESTION &x + if let Either::One(_t) = e { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &e + while let Either::One(_t) = e { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &e + match e { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &e + Either::One(_t) + | Either::Two(_t) => (), + } + match e { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &e + 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 + //~| SUGGESTION &x + if let Either::One(mut _t) = em { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + while let Either::One(mut _t) = em { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + Either::One(mut _t) + | Either::Two(mut _t) => (), + } + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + 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 + //~| SUGGESTION &x + if let Either::One(_t) = e { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &e + while let Either::One(_t) = e { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &e + match e { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &e + Either::One(_t) + | Either::Two(_t) => (), + } + match e { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &e + 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 + //~| SUGGESTION &x + if let Either::One(mut _t) = em { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + while let Either::One(mut _t) = em { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + Either::One(mut _t) + | Either::Two(mut _t) => (), + } + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + Either::One(mut _t) => (), + Either::Two(ref _t) => (), + // FIXME: should suggest removing `ref` too + } + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &em + Either::One(mut _t) => (), + Either::Two(ref mut _t) => (), + // FIXME: should suggest removing `ref` too + } + }); +} diff --git a/src/test/ui/suggestions/dont-suggest-ref/move-into-closure.stderr b/src/test/ui/suggestions/dont-suggest-ref/move-into-closure.stderr new file mode 100644 index 000000000..e06ee4290 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-ref/move-into-closure.stderr @@ -0,0 +1,343 @@ +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; + | -- ^ help: consider borrowing here: `&x` + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:32: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 { } + | -- ^ help: consider borrowing here: `&e` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:36: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 { } + | -- ^ help: consider borrowing here: `&e` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:40:15 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match e { + | ^ help: consider borrowing here: `&e` +... +LL | Either::One(_t) + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:47:15 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match e { + | ^ help: consider borrowing here: `&e` +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:56:25 + | +LL | let x = X(Y); + | - captured outer variable +... +LL | consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | let X(mut _t) = x; + | ------ ^ help: consider borrowing here: `&x` + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:60: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 { } + | ------ ^^ help: consider borrowing here: `&em` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:64: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 { } + | ------ ^^ help: consider borrowing here: `&em` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:68:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match em { + | ^^ help: consider borrowing here: `&em` +... +LL | Either::One(mut _t) + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:75:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match em { + | ^^ help: consider borrowing here: `&em` +... +LL | Either::One(mut _t) => (), + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:95:21 + | +LL | let x = X(Y); + | - captured outer variable +... +LL | consume_fnmut(|| { + | -- captured by this `FnMut` closure +LL | let X(_t) = x; + | -- ^ help: consider borrowing here: `&x` + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:99: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 { } + | -- ^ help: consider borrowing here: `&e` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:103: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 { } + | -- ^ help: consider borrowing here: `&e` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:107:15 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fnmut(|| { + | -- captured by this `FnMut` closure +... +LL | match e { + | ^ help: consider borrowing here: `&e` +... +LL | Either::One(_t) + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:114:15 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | consume_fnmut(|| { + | -- captured by this `FnMut` closure +... +LL | match e { + | ^ help: consider borrowing here: `&e` +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:123:25 + | +LL | let x = X(Y); + | - captured outer variable +... +LL | consume_fnmut(|| { + | -- captured by this `FnMut` closure +... +LL | let X(mut _t) = x; + | ------ ^ help: consider borrowing here: `&x` + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:127: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 { } + | ------ ^^ help: consider borrowing here: `&em` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:131: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 { } + | ------ ^^ help: consider borrowing here: `&em` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:135:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fnmut(|| { + | -- captured by this `FnMut` closure +... +LL | match em { + | ^^ help: consider borrowing here: `&em` +... +LL | Either::One(mut _t) + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:142:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fnmut(|| { + | -- captured by this `FnMut` closure +... +LL | match em { + | ^^ help: consider borrowing here: `&em` +... +LL | Either::One(mut _t) => (), + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure + --> $DIR/move-into-closure.rs:150:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | consume_fnmut(|| { + | -- captured by this `FnMut` closure +... +LL | match em { + | ^^ help: consider borrowing here: `&em` +... +LL | Either::One(mut _t) => (), + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error: aborting due to 21 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/suggestions/dont-suggest-ref/simple.rs b/src/test/ui/suggestions/dont-suggest-ref/simple.rs new file mode 100644 index 000000000..c53ac3d2c --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-ref/simple.rs @@ -0,0 +1,364 @@ +#[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 borrowing here + //~| SUGGESTION s + if let Either::One(_t) = *r { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION r + while let Either::One(_t) = *r { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION r + match *r { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION r + Either::One(_t) + | Either::Two(_t) => (), + } + match *r { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION r + Either::One(_t) => (), + Either::Two(ref _t) => (), + // FIXME: should suggest removing `ref` too + } + + let X(_t) = *sm; + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION sm + if let Either::One(_t) = *rm { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION rm + while let Either::One(_t) = *rm { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION rm + match *rm { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION rm + Either::One(_t) + | Either::Two(_t) => (), + } + match *rm { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION rm + Either::One(_t) => (), + Either::Two(ref _t) => (), + // FIXME: should suggest removing `ref` too + } + match *rm { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION rm + 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 + //~| SUGGESTION &vs[0] + if let Either::One(_t) = vr[0] { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vr[0] + while let Either::One(_t) = vr[0] { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vr[0] + match vr[0] { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vr[0] + Either::One(_t) + | Either::Two(_t) => (), + } + match vr[0] { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vr[0] + 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 + //~| SUGGESTION &vsm[0] + if let Either::One(_t) = vrm[0] { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vrm[0] + while let Either::One(_t) = vrm[0] { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vrm[0] + match vrm[0] { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vrm[0] + Either::One(_t) + | Either::Two(_t) => (), + } + match vrm[0] { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vrm[0] + Either::One(_t) => (), + Either::Two(ref _t) => (), + // FIXME: should suggest removing `ref` too + } + match vrm[0] { + //~^ ERROR cannot move + //~| HELP consider borrowing here + //~| SUGGESTION &vrm[0] + 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 the `&` + //~| SUGGESTION X(_t) + if let &Either::One(_t) = r { } + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + while let &Either::One(_t) = r { } + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + match r { + //~^ ERROR cannot move + &Either::One(_t) + //~^ HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + | &Either::Two(_t) => (), + // FIXME: would really like a suggestion here too + } + match r { + //~^ ERROR cannot move + &Either::One(_t) => (), + //~^ HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + &Either::Two(ref _t) => (), + } + match r { + //~^ ERROR cannot move + &Either::One(_t) => (), + //~^ HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + Either::Two(_t) => (), + } + fn f1(&X(_t): &X) { } + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION X(_t) + + let &mut X(_t) = sm; + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION X(_t) + if let &mut Either::One(_t) = rm { } + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + while let &mut Either::One(_t) = rm { } + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + match rm { + //~^ ERROR cannot move + &mut Either::One(_t) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + &mut Either::Two(_t) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION Either::Two(_t) + } + match rm { + //~^ ERROR cannot move + &mut Either::One(_t) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + &mut Either::Two(ref _t) => (), + } + match rm { + //~^ ERROR cannot move + &mut Either::One(_t) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + &mut Either::Two(ref mut _t) => (), + } + match rm { + //~^ ERROR cannot move + &mut Either::One(_t) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + Either::Two(_t) => (), + } + fn f2(&mut X(_t): &mut X) { } + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION X(_t) + + // move from tuple of &Either/&X + + // FIXME: These should have suggestions. + + let (&X(_t),) = (&x.clone(),); + //~^ ERROR cannot move + if let (&Either::One(_t),) = (&e.clone(),) { } + //~^ ERROR cannot move + while let (&Either::One(_t),) = (&e.clone(),) { } + //~^ ERROR cannot move + match (&e.clone(),) { + //~^ ERROR cannot move + (&Either::One(_t),) + | (&Either::Two(_t),) => (), + } + fn f3((&X(_t),): (&X,)) { } + //~^ ERROR cannot move + + let (&mut X(_t),) = (&mut xm.clone(),); + //~^ ERROR cannot move + if let (&mut Either::One(_t),) = (&mut em.clone(),) { } + //~^ ERROR cannot move + while let (&mut Either::One(_t),) = (&mut em.clone(),) { } + //~^ ERROR cannot move + match (&mut em.clone(),) { + //~^ ERROR cannot move + (&mut Either::One(_t),) => (), + (&mut Either::Two(_t),) => (), + } + fn f4((&mut X(_t),): (&mut X,)) { } + //~^ ERROR cannot move + + // move from &Either/&X value + + let &X(_t) = &x; + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION X(_t) + if let &Either::One(_t) = &e { } + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + while let &Either::One(_t) = &e { } + //~^ ERROR cannot move + //~| HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + match &e { + //~^ ERROR cannot move + &Either::One(_t) + //~^ HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + | &Either::Two(_t) => (), + // FIXME: would really like a suggestion here too + } + match &e { + //~^ ERROR cannot move + &Either::One(_t) => (), + //~^ HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + &Either::Two(ref _t) => (), + } + match &e { + //~^ ERROR cannot move + &Either::One(_t) => (), + //~^ HELP consider removing the `&` + //~| SUGGESTION Either::One(_t) + Either::Two(_t) => (), + } + + let &mut X(_t) = &mut xm; + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION X(_t) + if let &mut Either::One(_t) = &mut em { } + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + while let &mut Either::One(_t) = &mut em { } + //~^ ERROR cannot move + //~| HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + match &mut em { + //~^ ERROR cannot move + &mut Either::One(_t) + //~^ HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + | &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 the `&mut` + //~| SUGGESTION Either::One(_t) + &mut Either::Two(ref _t) => (), + } + match &mut em { + //~^ ERROR cannot move + &mut Either::One(_t) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + &mut Either::Two(ref mut _t) => (), + } + match &mut em { + //~^ ERROR cannot move + &mut Either::One(_t) => (), + //~^ HELP consider removing the `&mut` + //~| SUGGESTION Either::One(_t) + Either::Two(_t) => (), + } +} diff --git a/src/test/ui/suggestions/dont-suggest-ref/simple.stderr b/src/test/ui/suggestions/dont-suggest-ref/simple.stderr new file mode 100644 index 000000000..e5443290f --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-ref/simple.stderr @@ -0,0 +1,680 @@ +error[E0507]: cannot move out of `s` which is behind a shared reference + --> $DIR/simple.rs:38:17 + | +LL | let X(_t) = *s; + | -- ^^ help: consider borrowing here: `&*s` + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference + --> $DIR/simple.rs:42:30 + | +LL | if let Either::One(_t) = *r { } + | -- ^^ help: consider borrowing here: `&*r` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference + --> $DIR/simple.rs:46:33 + | +LL | while let Either::One(_t) = *r { } + | -- ^^ help: consider borrowing here: `&*r` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `r` as enum variant `Two` which is behind a shared reference + --> $DIR/simple.rs:50:11 + | +LL | match *r { + | ^^ help: consider borrowing here: `&*r` +... +LL | Either::One(_t) + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference + --> $DIR/simple.rs:57:11 + | +LL | match *r { + | ^^ help: consider borrowing here: `&*r` +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `sm` which is behind a mutable reference + --> $DIR/simple.rs:66:17 + | +LL | let X(_t) = *sm; + | -- ^^^ help: consider borrowing here: `&*sm` + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:70:30 + | +LL | if let Either::One(_t) = *rm { } + | -- ^^^ help: consider borrowing here: `&*rm` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:74:33 + | +LL | while let Either::One(_t) = *rm { } + | -- ^^^ help: consider borrowing here: `&*rm` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `rm` as enum variant `Two` which is behind a mutable reference + --> $DIR/simple.rs:78:11 + | +LL | match *rm { + | ^^^ help: consider borrowing here: `&*rm` +... +LL | Either::One(_t) + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:85:11 + | +LL | match *rm { + | ^^^ help: consider borrowing here: `&*rm` +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:93:11 + | +LL | match *rm { + | ^^^ help: consider borrowing here: `&*rm` +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:102:17 + | +LL | let X(_t) = vs[0]; + | -- ^^^^^ help: consider borrowing here: `&vs[0]` + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:106:30 + | +LL | if let Either::One(_t) = vr[0] { } + | -- ^^^^^ help: consider borrowing here: `&vr[0]` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:110:33 + | +LL | while let Either::One(_t) = vr[0] { } + | -- ^^^^^ help: consider borrowing here: `&vr[0]` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:114:11 + | +LL | match vr[0] { + | ^^^^^ help: consider borrowing here: `&vr[0]` +... +LL | Either::One(_t) + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:121:11 + | +LL | match vr[0] { + | ^^^^^ help: consider borrowing here: `&vr[0]` +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:130:17 + | +LL | let X(_t) = vsm[0]; + | -- ^^^^^^ help: consider borrowing here: `&vsm[0]` + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:134:30 + | +LL | if let Either::One(_t) = vrm[0] { } + | -- ^^^^^^ help: consider borrowing here: `&vrm[0]` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:138:33 + | +LL | while let Either::One(_t) = vrm[0] { } + | -- ^^^^^^ help: consider borrowing here: `&vrm[0]` + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:142:11 + | +LL | match vrm[0] { + | ^^^^^^ help: consider borrowing here: `&vrm[0]` +... +LL | Either::One(_t) + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:149:11 + | +LL | match vrm[0] { + | ^^^^^^ help: consider borrowing here: `&vrm[0]` +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of index of `Vec` + --> $DIR/simple.rs:157:11 + | +LL | match vrm[0] { + | ^^^^^^ help: consider borrowing here: `&vrm[0]` +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of `s` which is behind a shared reference + --> $DIR/simple.rs:168: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 `&`: `X(_t)` + +error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference + --> $DIR/simple.rs:172: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 `&`: `Either::One(_t)` + +error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference + --> $DIR/simple.rs:176: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 `&`: `Either::One(_t)` + +error[E0507]: cannot move out of `r` as enum variant `Two` which is behind a shared reference + --> $DIR/simple.rs:180: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 `&` + | +LL ~ Either::One(_t) +LL + +LL + +LL ~ | &Either::Two(_t) => (), + | + +error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference + --> $DIR/simple.rs:188: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 `&`: `Either::One(_t)` + +error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference + --> $DIR/simple.rs:195: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 `&`: `Either::One(_t)` + +error[E0507]: cannot move out of `sm` which is behind a mutable reference + --> $DIR/simple.rs:207: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 `&mut`: `X(_t)` + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:211: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:215: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of `rm` as enum variant `Two` which is behind a mutable reference + --> $DIR/simple.rs:219:11 + | +LL | match rm { + | ^^ +LL | +LL | &mut Either::One(_t) => (), + | -- data moved here +... +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 `&mut` + | +LL | Either::One(_t) => (), + | ~~~~~~~~~~~~~~~ +help: consider removing the `&mut` + | +LL | Either::Two(_t) => (), + | ~~~~~~~~~~~~~~~ + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:228: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:235: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference + --> $DIR/simple.rs:242: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:258:21 + | +LL | let (&X(_t),) = (&x.clone(),); + | -- ^^^^^^^^^^^^^ + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:260: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 + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:262: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 + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:264: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 + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:272: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 + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:274: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 + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:276: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 + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:278:11 + | +LL | match (&mut em.clone(),) { + | ^^^^^^^^^^^^^^^^^^ +LL | +LL | (&mut Either::One(_t),) => (), + | -- data moved here +LL | (&mut Either::Two(_t),) => (), + | -- ...and here + | + = note: move occurs because these variables have types that don't implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:288: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 `&`: `X(_t)` + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:292: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 `&`: `Either::One(_t)` + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:296: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 `&`: `Either::One(_t)` + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:300: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 `&` + | +LL ~ Either::One(_t) +LL + +LL + +LL ~ | &Either::Two(_t) => (), + | + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:308: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 `&`: `Either::One(_t)` + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:315: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 `&`: `Either::One(_t)` + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:323: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 `&mut`: `X(_t)` + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:327: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:331: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:335: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 `&mut` + | +LL ~ Either::One(_t) +LL + +LL + +LL ~ | &mut Either::Two(_t) => (), + | + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:343: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:350: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:357: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 `&mut`: `Either::One(_t)` + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:202: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 `&`: `X(_t)` + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:249: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 `&mut`: `X(_t)` + +error[E0507]: cannot move out of a shared reference + --> $DIR/simple.rs:269:11 + | +LL | fn f3((&X(_t),): (&X,)) { } + | ^^^^--^^^ + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of a mutable reference + --> $DIR/simple.rs:283: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 + +error: aborting due to 60 previous errors + +For more information about this error, try `rustc --explain E0507`. -- cgit v1.2.3