Auto merge of #53147 - ashtneoi:dont-suggest-ref, r=estebank

For move errors, suggest match ergonomics instead of `ref`

Partially fixes issue #52423. Also makes errors and suggestions more consistent between move-from-place and move-from-value errors.

Limitations:
- Only the first pattern in a match arm can have a "consider removing this borrow operator" suggestion.
- Suggestions don't always compile as-is (see the TODOs in the test for details).

Sorry for the really long test. I wanted to make sure I handled every case I could think of, and it turned out there were a lot of them.

Questions:
- Is there any particular applicability I should set on those suggestions?
- Are the notes about the `Copy` trait excessive?
This commit is contained in:
bors 2018-08-16 08:45:32 +00:00
commit 142bb27373
49 changed files with 3108 additions and 283 deletions

View file

@ -0,0 +1,12 @@
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
--> $DIR/E0508-fail.rs:18:18
|
LL | let _value = array[0]; //[ast]~ ERROR [E0508]
| ^^^^^^^^
| |
| cannot move out of here
| help: consider borrowing here: `&array[0]`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0508`.

View file

@ -5,7 +5,7 @@ LL | let _value = array[0]; //[ast]~ ERROR [E0508]
| ^^^^^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&array[0]`
| help: consider borrowing here: `&array[0]`
error: aborting due to previous error

View file

@ -0,0 +1,12 @@
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
--> $DIR/E0508.rs:15:18
|
LL | let _value = array[0]; //~ ERROR [E0508]
| ^^^^^^^^
| |
| cannot move out of here
| help: consider borrowing here: `&array[0]`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0508`.

View file

@ -2,10 +2,16 @@ error[E0507]: cannot move out of borrowed content
--> $DIR/access-mode-in-closures.rs:19:15
|
LL | match *s { sty(v) => v } //~ ERROR cannot move out
| ^^ - move occurs because v has type `std::vec::Vec<isize>`, which does not implement the `Copy` trait
| ^^ - data moved here
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `s`
| help: consider removing the `*`: `s`
|
note: move occurs because `v` has type `std::vec::Vec<isize>`, which does not implement the `Copy` trait
--> $DIR/access-mode-in-closures.rs:19:24
|
LL | match *s { sty(v) => v } //~ ERROR cannot move out
| ^
error: aborting due to previous error

View file

@ -2,28 +2,46 @@ error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15
|
LL | for &a in x.iter() { //~ ERROR cannot move out
| - ^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref a`
| -- ^^^^^^^^ cannot move out of borrowed content
| ||
| |data moved here
| help: consider removing the `&`: `a`
|
note: move occurs because `a` has type `&mut i32`, which does not implement the `Copy` trait
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:10
|
LL | for &a in x.iter() { //~ ERROR cannot move out
| ^
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:15
|
LL | for &a in &f.a { //~ ERROR cannot move out
| - ^^^^ cannot move out of borrowed content
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref a`
| -- ^^^^ cannot move out of borrowed content
| ||
| |data moved here
| help: consider removing the `&`: `a`
|
note: move occurs because `a` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:10
|
LL | for &a in &f.a { //~ ERROR cannot move out
| ^
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:15
|
LL | for &a in x.iter() { //~ ERROR cannot move out
| - ^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref a`
| -- ^^^^^^^^ cannot move out of borrowed content
| ||
| |data moved here
| help: consider removing the `&`: `a`
|
note: move occurs because `a` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:10
|
LL | for &a in x.iter() { //~ ERROR cannot move out
| ^
error: aborting due to 3 previous errors

View file

@ -5,7 +5,7 @@ LL | let _b = *y; //~ ERROR cannot move out
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `y`
| help: consider removing the `*`: `y`
error: aborting due to previous error

View file

@ -5,14 +5,24 @@ LL | match *f { //~ ERROR cannot move out of
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `f`
| help: consider removing the `*`: `f`
LL | //~| cannot move out
LL | Foo::Foo1(num1,
| ---- move occurs because num1 has type `std::boxed::Box<u32>`, which does not implement the `Copy` trait
| ---- data moved here
LL | num2) => (),
| ---- move occurs because num2 has type `std::boxed::Box<u32>`, which does not implement the `Copy` trait
| ---- ...and here
LL | Foo::Foo2(num) => (),
| --- move occurs because num has type `std::boxed::Box<u32>`, which does not implement the `Copy` trait
| --- ...and here
|
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/borrowck-move-error-with-note.rs:23:19
|
LL | Foo::Foo1(num1,
| ^^^^
LL | num2) => (),
| ^^^^
LL | Foo::Foo2(num) => (),
| ^^^
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-error-with-note.rs:39:11
@ -23,12 +33,15 @@ LL | match (S {f: "foo".to_string(), g: "bar".to_string()}) {
LL | f: _s,
| -- data moved here
LL | g: _t
| -- ... and here
help: to prevent move, use ref or ref mut
| -- ...and here
|
LL | f: ref _s,
LL | g: ref _t
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/borrowck-move-error-with-note.rs:42:16
|
LL | f: _s,
| ^^
LL | g: _t
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-move-error-with-note.rs:57:11
@ -37,10 +50,16 @@ LL | match a.a { //~ ERROR cannot move out of
| ^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&a.a`
| help: consider borrowing here: `&a.a`
LL | //~| cannot move out
LL | n => {
| - move occurs because n has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
| - data moved here
|
note: move occurs because `n` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-error-with-note.rs:59:9
|
LL | n => {
| ^
error: aborting due to 3 previous errors

View file

@ -5,7 +5,7 @@ LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer
| ^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&*x`
| help: consider removing the `*`: `x`
error: aborting due to previous error

View file

@ -5,8 +5,14 @@ LL | fn arg_item(&_x: &String) {}
| ^--
| ||
| |data moved here
| |help: to prevent move, use ref or ref mut: `ref _x`
| cannot move out of borrowed content
| help: consider removing the `&`: `_x`
|
note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-in-irrefut-pat.rs:16:14
|
LL | fn arg_item(&_x: &String) {}
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-move-in-irrefut-pat.rs:21:11
@ -15,17 +21,29 @@ LL | with(|&_x| ())
| ^--
| ||
| |data moved here
| |help: to prevent move, use ref or ref mut: `ref _x`
| cannot move out of borrowed content
| help: consider removing the `&`: `_x`
|
note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-in-irrefut-pat.rs:21:12
|
LL | with(|&_x| ())
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-move-in-irrefut-pat.rs:27:15
|
LL | let &_x = &"hi".to_string();
| -- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _x`
| --- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| ||
| |data moved here
| help: consider removing the `&`: `_x`
|
note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-in-irrefut-pat.rs:27:10
|
LL | let &_x = &"hi".to_string();
| ^^
error: aborting due to 3 previous errors

View file

@ -5,8 +5,14 @@ LL | fn arg_item(&_x: &String) {}
| ^--
| ||
| |data moved here
| |help: to prevent move, use ref or ref mut: `ref _x`
| cannot move out of borrowed content
| help: consider removing the `&`: `_x`
|
note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-in-irrefut-pat.rs:16:14
|
LL | fn arg_item(&_x: &String) {}
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-move-in-irrefut-pat.rs:21:11
@ -15,17 +21,29 @@ LL | with(|&_x| ())
| ^--
| ||
| |data moved here
| |help: to prevent move, use ref or ref mut: `ref _x`
| cannot move out of borrowed content
| help: consider removing the `&`: `_x`
|
note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-in-irrefut-pat.rs:21:12
|
LL | with(|&_x| ())
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-move-in-irrefut-pat.rs:27:15
|
LL | let &_x = &"hi".to_string();
| -- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _x`
| --- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| ||
| |data moved here
| help: consider removing the `&`: `_x`
|
note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-in-irrefut-pat.rs:27:10
|
LL | let &_x = &"hi".to_string();
| ^^
error: aborting due to 3 previous errors

View file

@ -0,0 +1,12 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-move-out-of-overloaded-deref.rs:14:14
|
LL | let _x = *Rc::new("hi".to_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `Rc::new("hi".to_string())`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.

View file

@ -5,10 +5,13 @@ LL | match (S {f:"foo".to_string()}) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
LL | //[mir]~^ ERROR [E0509]
LL | S {f:_s} => {}
| --
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _s`
| -- data moved here
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:22:14
|
LL | S {f:_s} => {}
| ^^
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:28:20
@ -17,7 +20,12 @@ LL | let S {f:_s} = S {f:"foo".to_string()};
| -- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _s`
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:28:14
|
LL | let S {f:_s} = S {f:"foo".to_string()};
| ^^
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:33:19
@ -26,8 +34,13 @@ LL | fn move_in_fn_arg(S {f:_s}: S) {
| ^^^^^--^
| | |
| | data moved here
| | help: to prevent move, use ref or ref mut: `ref _s`
| cannot move out of here
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:33:24
|
LL | fn move_in_fn_arg(S {f:_s}: S) {
| ^^
error: aborting due to 3 previous errors

View file

@ -5,10 +5,13 @@ LL | match (S {f:"foo".to_string()}) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
LL | //[mir]~^ ERROR [E0509]
LL | S {f:_s} => {}
| --
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _s`
| -- data moved here
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:22:14
|
LL | S {f:_s} => {}
| ^^
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:28:20
@ -17,7 +20,12 @@ LL | let S {f:_s} = S {f:"foo".to_string()};
| -- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _s`
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:28:14
|
LL | let S {f:_s} = S {f:"foo".to_string()};
| ^^
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:33:19
@ -26,8 +34,13 @@ LL | fn move_in_fn_arg(S {f:_s}: S) {
| ^^^^^--^
| | |
| | data moved here
| | help: to prevent move, use ref or ref mut: `ref _s`
| cannot move out of here
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-struct-with-dtor.rs:33:24
|
LL | fn move_in_fn_arg(S {f:_s}: S) {
| ^^
error: aborting due to 3 previous errors

View file

@ -4,10 +4,13 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
LL | match S("foo".to_string()) {
| ^^^^^^^^^^^^^^^^^^^^ cannot move out of here
LL | S(_s) => {}
| --
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _s`
| -- data moved here
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:11
|
LL | S(_s) => {}
| ^^
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:24:17
@ -16,7 +19,12 @@ LL | let S(_s) = S("foo".to_string());
| -- ^^^^^^^^^^^^^^^^^^^^ cannot move out of here
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _s`
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:24:11
|
LL | let S(_s) = S("foo".to_string());
| ^^
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:28:19
@ -25,8 +33,13 @@ LL | fn move_in_fn_arg(S(_s): S) {
| ^^--^
| | |
| | data moved here
| | help: to prevent move, use ref or ref mut: `ref _s`
| cannot move out of here
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:28:21
|
LL | fn move_in_fn_arg(S(_s): S) {
| ^^
error: aborting due to 3 previous errors

View file

@ -7,14 +7,23 @@ LL | &[Foo { string: a },
| - data moved here
...
LL | Foo { string: b }] => {
| - ... and here
help: to prevent move, use ref or ref mut
| - ...and here
|
LL | &[Foo { string: ref a },
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/borrowck-move-out-of-vec-tail.rs:30:33
|
LL | &[Foo { string: a },
| ^
...
LL | Foo { string: b }] => {
| ^
help: consider removing the `&`
|
LL | [Foo { string: a },
LL | //~^ ERROR cannot move out of type `[Foo]`
LL | //~| cannot move out
LL | //~| to prevent move
LL | Foo { string: ref b }] => {
LL | Foo { string: b }] => {
|
error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | let bad = v[0];
| ^^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&v[0]`
| help: consider borrowing here: `&v[0]`
error: aborting due to previous error

View file

@ -28,10 +28,21 @@ error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy sli
LL | match vec {
| ^^^ cannot move out of here
LL | &mut [_a, //~ ERROR cannot move out
| --
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _a`
| -- data moved here
|
note: move occurs because `_a` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
--> $DIR/borrowck-vec-pattern-nesting.rs:44:15
|
LL | &mut [_a, //~ ERROR cannot move out
| ^^
help: consider removing the `&mut`
|
LL | [_a, //~ ERROR cannot move out
LL | //~| cannot move out
LL | //~| to prevent move
LL | ..
LL | ] => {
|
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:57:13
@ -40,7 +51,7 @@ LL | let a = vec[0]; //~ ERROR cannot move out
| ^^^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&vec[0]`
| help: consider borrowing here: `&vec[0]`
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:64:11
@ -49,10 +60,19 @@ LL | match vec {
| ^^^ cannot move out of here
...
LL | _b] => {}
| --
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _b`
| -- data moved here
|
note: move occurs because `_b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
--> $DIR/borrowck-vec-pattern-nesting.rs:67:10
|
LL | _b] => {}
| ^^
help: consider removing the `&mut`
|
LL | [ //~ ERROR cannot move out
LL | //~^ cannot move out
LL | _b] => {}
|
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:70:13
@ -61,7 +81,7 @@ LL | let a = vec[0]; //~ ERROR cannot move out
| ^^^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&vec[0]`
| help: consider borrowing here: `&vec[0]`
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:77:11
@ -69,14 +89,18 @@ error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy sli
LL | match vec {
| ^^^ cannot move out of here
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out
| -- -- -- ... and here
| | |
| | ... and here
| data moved here
help: to prevent move, use ref or ref mut
| -----------------
| | | | |
| | | | ...and here
| | | ...and here
| | data moved here
| help: consider removing the `&mut`: `[_a, _b, _c]`
|
LL | &mut [ref _a, ref _b, ref _c] => {} //~ ERROR cannot move out
| ^^^^^^ ^^^^^^ ^^^^^^
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/borrowck-vec-pattern-nesting.rs:78:15
|
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out
| ^^ ^^ ^^
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:82:13
@ -85,7 +109,7 @@ LL | let a = vec[0]; //~ ERROR cannot move out
| ^^^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&vec[0]`
| help: consider borrowing here: `&vec[0]`
error: aborting due to 8 previous errors

View file

@ -5,8 +5,13 @@ LL | let opt = a.iter().enumerate().find(|(_, &s)| {
| ^^^^^-^
| | |
| | data moved here
| | help: to prevent move, use ref or ref mut: `ref s`
| cannot move out of borrowed content
|
note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/issue-51415.rs:16:47
|
LL | let opt = a.iter().enumerate().find(|(_, &s)| {
| ^
error: aborting due to previous error

View file

@ -5,10 +5,16 @@ LL | match &s.x {
| ^^^^ cannot move out of borrowed content
LL | &E::Foo => {}
LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
| ----------
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref identifier`
| -------------------
| | |
| | data moved here
| help: consider removing the `&`: `E::Bar(identifier)`
|
note: move occurs because `identifier` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/by-move-pattern-binding.rs:26:17
|
LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
| ^^^^^^^^^^
error: aborting due to previous error

View file

@ -56,7 +56,7 @@ LL | let y = { static x: Box<isize> = box 3; x };
| ^
| |
| cannot move out of static item
| help: consider using a reference instead: `&x`
| help: consider borrowing here: `&x`
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:120:38

View file

@ -4,10 +4,13 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
LL | match (S {f:"foo".to_string()}) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
LL | S {f:_s} => {} //~ ERROR cannot move out
| --
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref _s`
| -- data moved here
|
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/overlapping_spans.rs:21:14
|
LL | S {f:_s} => {} //~ ERROR cannot move out
| ^^
error: aborting due to previous error

View file

@ -5,7 +5,12 @@ LL | let X { x: y } = x; //~ ERROR cannot move out of type
| - ^ cannot move out of here
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref y`
|
note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/disallowed-deconstructing-destructing-struct-let.rs:22:16
|
LL | let X { x: y } = x; //~ ERROR cannot move out of type
| ^
error: aborting due to previous error

View file

@ -4,10 +4,13 @@ error[E0509]: cannot move out of type `X`, which implements the `Drop` trait
LL | match x {
| ^ cannot move out of here
LL | X { x: y } => println!("contents: {}", y)
| -
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref y`
| - data moved here
|
note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/disallowed-deconstructing-destructing-struct-match.rs:25:16
|
LL | X { x: y } => println!("contents: {}", y)
| ^
error: aborting due to previous error

View file

@ -0,0 +1,12 @@
error[E0509]: cannot move out of type `DropStruct`, which implements the `Drop` trait
--> $DIR/E0509.rs:26:23
|
LL | let fancy_field = drop_struct.fancy; //~ ERROR E0509
| ^^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| help: consider borrowing here: `&drop_struct.fancy`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0509`.

View file

@ -8,15 +8,16 @@ LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| -- data moved here
...
LL | (&[hd1, ..], &[hd2, ..])
| --- ... and here
help: to prevent move, use ref or ref mut
| --- ...and here
|
LL | (&[], &[ref hd, ..]) | (&[hd, ..], &[])
LL | => println!("one empty"),
LL | //~^^ ERROR: cannot move out of type `[T]`, a non-copy slice
LL | //~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice
LL | (&[hd1, ..], &[ref hd2, ..])
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/issue-12567.rs:16:17
|
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| ^^
...
LL | (&[hd1, ..], &[hd2, ..])
| ^^^
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:14:11
@ -28,15 +29,16 @@ LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| -- data moved here
...
LL | (&[hd1, ..], &[hd2, ..])
| --- ... and here
help: to prevent move, use ref or ref mut
| --- ...and here
|
LL | (&[], &[ref hd, ..]) | (&[hd, ..], &[])
LL | => println!("one empty"),
LL | //~^^ ERROR: cannot move out of type `[T]`, a non-copy slice
LL | //~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice
LL | (&[ref hd1, ..], &[hd2, ..])
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/issue-12567.rs:16:17
|
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| ^^
...
LL | (&[hd1, ..], &[hd2, ..])
| ^^^
error: aborting due to 2 previous errors

View file

@ -0,0 +1,12 @@
error[E0507]: cannot move out of static item
--> $DIR/issue-17718-static-move.rs:16:14
|
LL | let _a = FOO; //~ ERROR: cannot move out of static item
| ^^^
| |
| cannot move out of static item
| help: consider borrowing here: `&FOO`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.

View file

@ -5,7 +5,7 @@ LL | let a = unsafe { *mut_ref() };
| ^^^^^^^^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&*mut_ref()`
| help: consider removing the `*`: `mut_ref()`
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-20801.rs:39:22
@ -14,7 +14,7 @@ LL | let b = unsafe { *imm_ref() };
| ^^^^^^^^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&*imm_ref()`
| help: consider removing the `*`: `imm_ref()`
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-20801.rs:42:22
@ -23,7 +23,7 @@ LL | let c = unsafe { *mut_ptr() };
| ^^^^^^^^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&*mut_ptr()`
| help: consider removing the `*`: `mut_ptr()`
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-20801.rs:45:22
@ -32,7 +32,7 @@ LL | let d = unsafe { *const_ptr() };
| ^^^^^^^^^^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&*const_ptr()`
| help: consider removing the `*`: `const_ptr()`
error: aborting due to 4 previous errors

View file

@ -5,7 +5,7 @@ LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content
| ^^^^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&f.v[0]`
| help: consider borrowing here: `&f.v[0]`
error: aborting due to previous error

View file

@ -5,9 +5,15 @@ LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
| - - ^^^^
| | | |
| | | cannot move out of borrowed content
| | | help: consider using a reference instead: `&x[0]`
| | move occurs because b has type `std::string::String`, which does not implement the `Copy` trait
| move occurs because a has type `std::string::String`, which does not implement the `Copy` trait
| | | help: consider borrowing here: `&x[0]`
| | ...and here
| data moved here
|
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/issue-40402-2.rs:15:10
|
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
| ^ ^
error: aborting due to previous error

View file

@ -4,10 +4,13 @@ error[E0508]: cannot move out of type `[A]`, a non-copy slice
LL | match a {
| ^ cannot move out of here
LL | box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice
| -
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref a`
| - data moved here
|
note: move occurs because `a` has type `A`, which does not implement the `Copy` trait
--> $DIR/move-out-of-slice-1.rs:18:14
|
LL | box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice
| ^
error: aborting due to previous error

View file

@ -5,10 +5,16 @@ LL | match hellothere.x { //~ ERROR cannot move out
| ^^^^^^^^^^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&hellothere.x`
| help: consider borrowing here: `&hellothere.x`
...
LL | box E::Bar(x) => println!("{}", x.to_string()),
| - move occurs because x has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
| - data moved here
|
note: move occurs because `x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
--> $DIR/moves-based-on-type-block-bad.rs:37:28
|
LL | box E::Bar(x) => println!("{}", x.to_string()),
| ^
error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | let x = { *r }; //~ ERROR
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `r`
| help: consider removing the `*`: `r`
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:16:22
@ -14,7 +14,7 @@ LL | let y = unsafe { *r }; //~ ERROR
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `r`
| help: consider removing the `*`: `r`
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:17:26
@ -23,7 +23,7 @@ LL | let z = loop { break *r; }; //~ ERROR
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `r`
| help: consider removing the `*`: `r`
error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:21:15
@ -32,7 +32,7 @@ LL | let x = { arr[0] }; //~ ERROR
| ^^^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&arr[0]`
| help: consider borrowing here: `&arr[0]`
error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:22:22
@ -41,7 +41,7 @@ LL | let y = unsafe { arr[0] }; //~ ERROR
| ^^^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&arr[0]`
| help: consider borrowing here: `&arr[0]`
error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:23:26
@ -50,7 +50,7 @@ LL | let z = loop { break arr[0]; }; //~ ERROR
| ^^^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&arr[0]`
| help: consider borrowing here: `&arr[0]`
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:27:38
@ -59,7 +59,7 @@ LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `r`
| help: consider removing the `*`: `r`
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:28:45
@ -68,7 +68,7 @@ LL | let y = unsafe { let mut u = 0; u += 1; *r }; //~ ERROR
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `r`
| help: consider removing the `*`: `r`
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:29:49
@ -77,7 +77,7 @@ LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; //~ ERROR
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `r`
| help: consider removing the `*`: `r`
error: aborting due to 9 previous errors

View file

@ -5,7 +5,7 @@ LL | let b = *a;
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `a`
| help: consider removing the `*`: `a`
error[E0508]: cannot move out of type `[A; 1]`, a non-copy array
--> $DIR/move-errors.rs:25:13
@ -14,7 +14,7 @@ LL | let b = a[0];
| ^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&a[0]`
| help: consider borrowing here: `&a[0]`
error[E0507]: cannot move out of borrowed content
--> $DIR/move-errors.rs:32:13
@ -23,7 +23,7 @@ LL | let s = **r;
| ^^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&**r`
| help: consider removing the `*`: `*r`
error[E0507]: cannot move out of borrowed content
--> $DIR/move-errors.rs:40:13
@ -32,7 +32,7 @@ LL | let s = *r;
| ^^
| |
| cannot move out of borrowed content
| help: consider using a reference instead: `&*r`
| help: consider removing the `*`: `r`
error[E0508]: cannot move out of type `[A; 1]`, a non-copy array
--> $DIR/move-errors.rs:45:13
@ -41,7 +41,7 @@ LL | let a = [A("".to_string())][0];
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&[A("".to_string())][0]`
| help: consider borrowing here: `&[A("".to_string())][0]`
error[E0507]: cannot move out of borrowed content
--> $DIR/move-errors.rs:51:16
@ -50,8 +50,14 @@ LL | let A(s) = *a;
| - ^^
| | |
| | cannot move out of borrowed content
| | help: consider removing this dereference operator: `a`
| move occurs because s has type `std::string::String`, which does not implement the `Copy` trait
| | help: consider removing the `*`: `a`
| data moved here
|
note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/move-errors.rs:51:11
|
LL | let A(s) = *a;
| ^
error[E0509]: cannot move out of type `D`, which implements the `Drop` trait
--> $DIR/move-errors.rs:57:19
@ -60,7 +66,12 @@ LL | let C(D(s)) = c;
| - ^ cannot move out of here
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref s`
|
note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/move-errors.rs:57:13
|
LL | let C(D(s)) = c;
| ^
error[E0507]: cannot move out of borrowed content
--> $DIR/move-errors.rs:64:9
@ -75,12 +86,20 @@ LL | match x[0] {
| ^^^^
| |
| cannot move out of here
| help: consider using a reference instead: `&x[0]`
| help: consider borrowing here: `&x[0]`
LL | //~^ ERROR
LL | B::U(d) => (),
| - move occurs because d has type `D`, which does not implement the `Copy` trait
| - data moved here
LL | B::V(s) => (),
| - move occurs because s has type `std::string::String`, which does not implement the `Copy` trait
| - ...and here
|
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/move-errors.rs:89:14
|
LL | B::U(d) => (),
| ^
LL | B::V(s) => (),
| ^
error[E0509]: cannot move out of type `D`, which implements the `Drop` trait
--> $DIR/move-errors.rs:96:11
@ -89,10 +108,13 @@ LL | match x {
| ^ cannot move out of here
...
LL | B::U(D(s)) => (),
| -
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref s`
| - data moved here
|
note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/move-errors.rs:99:16
|
LL | B::U(D(s)) => (),
| ^
error[E0509]: cannot move out of type `D`, which implements the `Drop` trait
--> $DIR/move-errors.rs:105:11
@ -101,10 +123,13 @@ LL | match x {
| ^ cannot move out of here
...
LL | (D(s), &t) => (),
| -
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref s`
| - data moved here
|
note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/move-errors.rs:108:12
|
LL | (D(s), &t) => (),
| ^
error[E0507]: cannot move out of borrowed content
--> $DIR/move-errors.rs:105:11
@ -113,10 +138,13 @@ LL | match x {
| ^ cannot move out of borrowed content
...
LL | (D(s), &t) => (),
| -
| |
| data moved here
| help: to prevent move, use ref or ref mut: `ref t`
| - data moved here
|
note: move occurs because `t` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/move-errors.rs:108:17
|
LL | (D(s), &t) => (),
| ^
error[E0509]: cannot move out of type `F`, which implements the `Drop` trait
--> $DIR/move-errors.rs:115:11
@ -125,13 +153,15 @@ LL | match x {
| ^ cannot move out of here
LL | //~^ ERROR
LL | F(s, mut t) => (),
| - ----- ... and here
| - ----- ...and here
| |
| data moved here
help: to prevent move, use ref or ref mut
|
LL | F(ref s, ref mut t) => (),
| ^^^^^ ^^^^^^^^^
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/move-errors.rs:117:11
|
LL | F(s, mut t) => (),
| ^ ^^^^^
error[E0507]: cannot move out of borrowed content
--> $DIR/move-errors.rs:123:11
@ -140,10 +170,16 @@ LL | match *x {
| ^^
| |
| cannot move out of borrowed content
| help: consider removing this dereference operator: `x`
| help: consider removing the `*`: `x`
LL | //~^ ERROR
LL | Ok(s) | Err(s) => (),
| - move occurs because s has type `std::string::String`, which does not implement the `Copy` trait
| - data moved here
|
note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/move-errors.rs:125:12
|
LL | Ok(s) | Err(s) => (),
| ^
error: aborting due to 14 previous errors

View file

@ -0,0 +1,39 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/std-uncopyable-atomics.rs:19:13
|
LL | let x = *&x; //~ ERROR: cannot move out of borrowed content
| ^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `&x`
error[E0507]: cannot move out of borrowed content
--> $DIR/std-uncopyable-atomics.rs:21:13
|
LL | let x = *&x; //~ ERROR: cannot move out of borrowed content
| ^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `&x`
error[E0507]: cannot move out of borrowed content
--> $DIR/std-uncopyable-atomics.rs:23:13
|
LL | let x = *&x; //~ ERROR: cannot move out of borrowed content
| ^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `&x`
error[E0507]: cannot move out of borrowed content
--> $DIR/std-uncopyable-atomics.rs:25:13
|
LL | let x = *&x; //~ ERROR: cannot move out of borrowed content
| ^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `&x`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0507`.

View file

@ -0,0 +1,162 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(nll)]
#[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))
}

View file

@ -0,0 +1,328 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:51:27
|
LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
| --------------- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| | | |
| | | ...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
--> $DIR/duplicate-suggestions.rs:51:13
|
LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:55:50
|
LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ----------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| | | |
| | | ...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
--> $DIR/duplicate-suggestions.rs:55:26
|
LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:59:53
|
LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ----------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| | | |
| | | ...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
--> $DIR/duplicate-suggestions.rs:59:29
|
LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:63:11
|
LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:65:23
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^ ^^
...
LL | &(Either::Two(_t), Either::One(_u)) => (),
| ^^ ^^
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 borrowed content
--> $DIR/duplicate-suggestions.rs:73:11
|
LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:75:23
|
LL | &(Either::One(_t), Either::Two(_u))
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:82:11
|
LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:84:23
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:90:11
|
LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:92:23
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:103:31
|
LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| | | |
| | | ...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
--> $DIR/duplicate-suggestions.rs:103:17
|
LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:107:54
|
LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| --------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| | | |
| | | ...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
--> $DIR/duplicate-suggestions.rs:107:30
|
LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:111:57
|
LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| --------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| | | |
| | | ...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
--> $DIR/duplicate-suggestions.rs:111:33
|
LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:115:11
|
LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:117:27
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^ ^^
...
LL | &mut (Either::Two(_t), Either::One(_u)) => (),
| ^^ ^^
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 borrowed content
--> $DIR/duplicate-suggestions.rs:125:11
|
LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:127:27
|
LL | &mut (Either::One(_t), Either::Two(_u))
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:134:11
|
LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:136:27
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:142:11
|
LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:144:27
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:150:11
|
LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/duplicate-suggestions.rs:152:27
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:98:11
|
LL | fn f5(&(X(_t), X(_u)): &(X, X)) { }
| ^^^^--^^^^^--^^
| | | |
| | | ...and here
| | data moved here
| cannot move out of borrowed content
| help: consider removing the `&`: `(X(_t), X(_u))`
|
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/duplicate-suggestions.rs:98:15
|
LL | fn f5(&(X(_t), X(_u)): &(X, X)) { }
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/duplicate-suggestions.rs:158:11
|
LL | fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
| ^^^^^^^^--^^^^^--^^
| | | |
| | | ...and here
| | data moved here
| cannot move out of borrowed content
| help: consider removing the `&mut`: `(X(_t), X(_u))`
|
note: move occurs because these variables have types that don't implement the `Copy` trait
--> $DIR/duplicate-suggestions.rs:158:19
|
LL | fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
| ^^ ^^
error: aborting due to 17 previous errors
For more information about this error, try `rustc --explain E0507`.

View file

@ -0,0 +1,171 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(nll)]
#[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
//~| 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
}
});
}

View file

@ -0,0 +1,420 @@
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:40:21
|
LL | let x = X(Y);
| - captured outer variable
...
LL | let X(_t) = x;
| -- ^
| | |
| | cannot move out of captured variable in an `Fn` closure
| | help: consider borrowing here: `&x`
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:40:15
|
LL | let X(_t) = x;
| ^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:44:34
|
LL | let e = Either::One(X(Y));
| - captured outer variable
...
LL | if let Either::One(_t) = e { }
| -- ^
| | |
| | cannot move out of captured variable in an `Fn` closure
| | help: consider borrowing here: `&e`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:44:28
|
LL | if let Either::One(_t) = e { }
| ^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:48:37
|
LL | let e = Either::One(X(Y));
| - captured outer variable
...
LL | while let Either::One(_t) = e { }
| -- ^
| | |
| | cannot move out of captured variable in an `Fn` closure
| | help: consider borrowing here: `&e`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:48:31
|
LL | while let Either::One(_t) = e { }
| ^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:52:15
|
LL | let e = Either::One(X(Y));
| - captured outer variable
...
LL | match e {
| ^
| |
| cannot move out of captured variable in an `Fn` closure
| help: consider borrowing here: `&e`
...
LL | Either::One(_t)
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:56:25
|
LL | Either::One(_t)
| ^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:59:15
|
LL | let e = Either::One(X(Y));
| - captured outer variable
...
LL | match e {
| ^
| |
| cannot move out of captured variable in an `Fn` closure
| help: consider borrowing here: `&e`
...
LL | Either::One(_t) => (),
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:63:25
|
LL | Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:68:25
|
LL | let x = X(Y);
| - captured outer variable
...
LL | let X(mut _t) = x;
| ------ ^
| | |
| | cannot move out of captured variable in an `Fn` closure
| | help: consider borrowing here: `&x`
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:68:15
|
LL | let X(mut _t) = x;
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:72:38
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | if let Either::One(mut _t) = em { }
| ------ ^^
| | |
| | cannot move out of captured variable in an `Fn` closure
| | help: consider borrowing here: `&em`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:72:28
|
LL | if let Either::One(mut _t) = em { }
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:76:41
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | while let Either::One(mut _t) = em { }
| ------ ^^
| | |
| | cannot move out of captured variable in an `Fn` closure
| | help: consider borrowing here: `&em`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:76:31
|
LL | while let Either::One(mut _t) = em { }
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:80:15
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | match em {
| ^^
| |
| cannot move out of captured variable in an `Fn` closure
| help: consider borrowing here: `&em`
...
LL | Either::One(mut _t)
| ------ data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:84:25
|
LL | Either::One(mut _t)
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:87:15
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | match em {
| ^^
| |
| cannot move out of captured variable in an `Fn` closure
| help: consider borrowing here: `&em`
...
LL | Either::One(mut _t) => (),
| ------ data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:91:25
|
LL | Either::One(mut _t) => (),
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:107:21
|
LL | let x = X(Y);
| - captured outer variable
...
LL | let X(_t) = x;
| -- ^
| | |
| | cannot move out of captured variable in an `FnMut` closure
| | help: consider borrowing here: `&x`
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:107:15
|
LL | let X(_t) = x;
| ^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:111:34
|
LL | let e = Either::One(X(Y));
| - captured outer variable
...
LL | if let Either::One(_t) = e { }
| -- ^
| | |
| | cannot move out of captured variable in an `FnMut` closure
| | help: consider borrowing here: `&e`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:111:28
|
LL | if let Either::One(_t) = e { }
| ^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:115:37
|
LL | let e = Either::One(X(Y));
| - captured outer variable
...
LL | while let Either::One(_t) = e { }
| -- ^
| | |
| | cannot move out of captured variable in an `FnMut` closure
| | help: consider borrowing here: `&e`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:115:31
|
LL | while let Either::One(_t) = e { }
| ^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:119:15
|
LL | let e = Either::One(X(Y));
| - captured outer variable
...
LL | match e {
| ^
| |
| cannot move out of captured variable in an `FnMut` closure
| help: consider borrowing here: `&e`
...
LL | Either::One(_t)
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:123:25
|
LL | Either::One(_t)
| ^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:126:15
|
LL | let e = Either::One(X(Y));
| - captured outer variable
...
LL | match e {
| ^
| |
| cannot move out of captured variable in an `FnMut` closure
| help: consider borrowing here: `&e`
...
LL | Either::One(_t) => (),
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:130:25
|
LL | Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:135:25
|
LL | let x = X(Y);
| - captured outer variable
...
LL | let X(mut _t) = x;
| ------ ^
| | |
| | cannot move out of captured variable in an `FnMut` closure
| | help: consider borrowing here: `&x`
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:135:15
|
LL | let X(mut _t) = x;
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:139:38
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | if let Either::One(mut _t) = em { }
| ------ ^^
| | |
| | cannot move out of captured variable in an `FnMut` closure
| | help: consider borrowing here: `&em`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:139:28
|
LL | if let Either::One(mut _t) = em { }
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:143:41
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | while let Either::One(mut _t) = em { }
| ------ ^^
| | |
| | cannot move out of captured variable in an `FnMut` closure
| | help: consider borrowing here: `&em`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:143:31
|
LL | while let Either::One(mut _t) = em { }
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:147:15
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | match em {
| ^^
| |
| cannot move out of captured variable in an `FnMut` closure
| help: consider borrowing here: `&em`
...
LL | Either::One(mut _t)
| ------ data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:151:25
|
LL | Either::One(mut _t)
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:154:15
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | match em {
| ^^
| |
| cannot move out of captured variable in an `FnMut` closure
| help: consider borrowing here: `&em`
...
LL | Either::One(mut _t) => (),
| ------ data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:158:25
|
LL | Either::One(mut _t) => (),
| ^^^^^^
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:162:15
|
LL | let mut em = Either::One(X(Y));
| ------ captured outer variable
...
LL | match em {
| ^^
| |
| cannot move out of captured variable in an `FnMut` closure
| help: consider borrowing here: `&em`
...
LL | Either::One(mut _t) => (),
| ------ data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/move-into-closure.rs:166:25
|
LL | Either::One(mut _t) => (),
| ^^^^^^
error: aborting due to 21 previous errors
For more information about this error, try `rustc --explain E0507`.

View file

@ -0,0 +1,376 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(nll)]
#[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 `*`
//~| SUGGESTION s
if let Either::One(_t) = *r { }
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION r
while let Either::One(_t) = *r { }
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION r
match *r {
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION r
Either::One(_t)
| Either::Two(_t) => (),
}
match *r {
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION r
Either::One(_t) => (),
Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too
}
let X(_t) = *sm;
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION sm
if let Either::One(_t) = *rm { }
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION rm
while let Either::One(_t) = *rm { }
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION rm
match *rm {
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION rm
Either::One(_t)
| Either::Two(_t) => (),
}
match *rm {
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| SUGGESTION rm
Either::One(_t) => (),
Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too
}
match *rm {
//~^ ERROR cannot move
//~| HELP consider removing the `*`
//~| 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) => (),
}
}

View file

@ -0,0 +1,998 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:50:17
|
LL | let X(_t) = *s;
| -- ^^
| | |
| | cannot move out of borrowed content
| | help: consider removing the `*`: `s`
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:50:11
|
LL | let X(_t) = *s;
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:54:30
|
LL | if let Either::One(_t) = *r { }
| -- ^^
| | |
| | cannot move out of borrowed content
| | help: consider removing the `*`: `r`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:54:24
|
LL | if let Either::One(_t) = *r { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:58:33
|
LL | while let Either::One(_t) = *r { }
| -- ^^
| | |
| | cannot move out of borrowed content
| | help: consider removing the `*`: `r`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:58:27
|
LL | while let Either::One(_t) = *r { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:62:11
|
LL | match *r {
| ^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `r`
...
LL | Either::One(_t)
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:66:21
|
LL | Either::One(_t)
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:69:11
|
LL | match *r {
| ^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `r`
...
LL | Either::One(_t) => (),
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:73:21
|
LL | Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:78:17
|
LL | let X(_t) = *sm;
| -- ^^^
| | |
| | cannot move out of borrowed content
| | help: consider removing the `*`: `sm`
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:78:11
|
LL | let X(_t) = *sm;
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:82:30
|
LL | if let Either::One(_t) = *rm { }
| -- ^^^
| | |
| | cannot move out of borrowed content
| | help: consider removing the `*`: `rm`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:82:24
|
LL | if let Either::One(_t) = *rm { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:86:33
|
LL | while let Either::One(_t) = *rm { }
| -- ^^^
| | |
| | cannot move out of borrowed content
| | help: consider removing the `*`: `rm`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:86:27
|
LL | while let Either::One(_t) = *rm { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:90:11
|
LL | match *rm {
| ^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `rm`
...
LL | Either::One(_t)
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:94:21
|
LL | Either::One(_t)
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:97:11
|
LL | match *rm {
| ^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `rm`
...
LL | Either::One(_t) => (),
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:101:21
|
LL | Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:105:11
|
LL | match *rm {
| ^^^
| |
| cannot move out of borrowed content
| help: consider removing the `*`: `rm`
...
LL | Either::One(_t) => (),
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:109:21
|
LL | Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:114:17
|
LL | let X(_t) = vs[0];
| -- ^^^^^
| | |
| | cannot move out of borrowed content
| | help: consider borrowing here: `&vs[0]`
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:114:11
|
LL | let X(_t) = vs[0];
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:118:30
|
LL | if let Either::One(_t) = vr[0] { }
| -- ^^^^^
| | |
| | cannot move out of borrowed content
| | help: consider borrowing here: `&vr[0]`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:118:24
|
LL | if let Either::One(_t) = vr[0] { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:122:33
|
LL | while let Either::One(_t) = vr[0] { }
| -- ^^^^^
| | |
| | cannot move out of borrowed content
| | help: consider borrowing here: `&vr[0]`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:122:27
|
LL | while let Either::One(_t) = vr[0] { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:126:11
|
LL | match vr[0] {
| ^^^^^
| |
| cannot move out of borrowed content
| help: consider borrowing here: `&vr[0]`
...
LL | Either::One(_t)
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:130:21
|
LL | Either::One(_t)
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:133:11
|
LL | match vr[0] {
| ^^^^^
| |
| cannot move out of borrowed content
| help: consider borrowing here: `&vr[0]`
...
LL | Either::One(_t) => (),
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:137:21
|
LL | Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:142:17
|
LL | let X(_t) = vsm[0];
| -- ^^^^^^
| | |
| | cannot move out of borrowed content
| | help: consider borrowing here: `&vsm[0]`
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:142:11
|
LL | let X(_t) = vsm[0];
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:146:30
|
LL | if let Either::One(_t) = vrm[0] { }
| -- ^^^^^^
| | |
| | cannot move out of borrowed content
| | help: consider borrowing here: `&vrm[0]`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:146:24
|
LL | if let Either::One(_t) = vrm[0] { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:150:33
|
LL | while let Either::One(_t) = vrm[0] { }
| -- ^^^^^^
| | |
| | cannot move out of borrowed content
| | help: consider borrowing here: `&vrm[0]`
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:150:27
|
LL | while let Either::One(_t) = vrm[0] { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:154:11
|
LL | match vrm[0] {
| ^^^^^^
| |
| cannot move out of borrowed content
| help: consider borrowing here: `&vrm[0]`
...
LL | Either::One(_t)
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:158:21
|
LL | Either::One(_t)
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:161:11
|
LL | match vrm[0] {
| ^^^^^^
| |
| cannot move out of borrowed content
| help: consider borrowing here: `&vrm[0]`
...
LL | Either::One(_t) => (),
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:165:21
|
LL | Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:169:11
|
LL | match vrm[0] {
| ^^^^^^
| |
| cannot move out of borrowed content
| help: consider borrowing here: `&vrm[0]`
...
LL | Either::One(_t) => (),
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:173:21
|
LL | Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:180:18
|
LL | let &X(_t) = s;
| ------ ^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&`: `X(_t)`
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:180:12
|
LL | let &X(_t) = s;
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:184:31
|
LL | if let &Either::One(_t) = r { }
| ---------------- ^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:184:25
|
LL | if let &Either::One(_t) = r { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:188:34
|
LL | while let &Either::One(_t) = r { }
| ---------------- ^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:188:28
|
LL | while let &Either::One(_t) = r { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:192:11
|
LL | match r {
| ^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &Either::One(_t)
| ----------------
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:194:22
|
LL | &Either::One(_t)
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:200:11
|
LL | match r {
| ^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &Either::One(_t) => (),
| ----------------
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:202:22
|
LL | &Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:207:11
|
LL | match r {
| ^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &Either::One(_t) => (),
| ----------------
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:209:22
|
LL | &Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:219:22
|
LL | let &mut X(_t) = sm;
| ---------- ^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&mut`: `X(_t)`
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:219:16
|
LL | let &mut X(_t) = sm;
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:223:35
|
LL | if let &mut Either::One(_t) = rm { }
| -------------------- ^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:223:29
|
LL | if let &mut Either::One(_t) = rm { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:227:38
|
LL | while let &mut Either::One(_t) = rm { }
| -------------------- ^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:227:32
|
LL | while let &mut Either::One(_t) = rm { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:231:11
|
LL | match rm {
| ^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/simple.rs:233:26
|
LL | &mut Either::One(_t) => (),
| ^^
...
LL | &mut Either::Two(_t) => (),
| ^^
help: consider removing the `&mut`
|
LL | Either::One(_t) => (),
| ^^^^^^^^^^^^^^^
help: consider removing the `&mut`
|
LL | Either::Two(_t) => (),
| ^^^^^^^^^^^^^^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:240:11
|
LL | match rm {
| ^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &mut Either::One(_t) => (),
| --------------------
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:242:26
|
LL | &mut Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:247:11
|
LL | match rm {
| ^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &mut Either::One(_t) => (),
| --------------------
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:249:26
|
LL | &mut Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:254:11
|
LL | match rm {
| ^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &mut Either::One(_t) => (),
| --------------------
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:256:26
|
LL | &mut Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:270:21
|
LL | let (&X(_t),) = (&x.clone(),);
| -- ^^^^^^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:270:13
|
LL | let (&X(_t),) = (&x.clone(),);
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:272:34
|
LL | if let (&Either::One(_t),) = (&e.clone(),) { }
| -- ^^^^^^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:272:26
|
LL | if let (&Either::One(_t),) = (&e.clone(),) { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:274:37
|
LL | while let (&Either::One(_t),) = (&e.clone(),) { }
| -- ^^^^^^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:274:29
|
LL | while let (&Either::One(_t),) = (&e.clone(),) { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:276:11
|
LL | match (&e.clone(),) {
| ^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | (&Either::One(_t),)
| -- data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:278:23
|
LL | (&Either::One(_t),)
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:284:25
|
LL | let (&mut X(_t),) = (&mut xm.clone(),);
| -- ^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:284:17
|
LL | let (&mut X(_t),) = (&mut xm.clone(),);
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:286:38
|
LL | if let (&mut Either::One(_t),) = (&mut em.clone(),) { }
| -- ^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:286:30
|
LL | if let (&mut Either::One(_t),) = (&mut em.clone(),) { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:288:41
|
LL | while let (&mut Either::One(_t),) = (&mut em.clone(),) { }
| -- ^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| |
| data moved here
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:288:33
|
LL | while let (&mut Either::One(_t),) = (&mut em.clone(),) { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:290:11
|
LL | match (&mut em.clone(),) {
| ^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
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
--> $DIR/simple.rs:292:27
|
LL | (&mut Either::One(_t),) => (),
| ^^
LL | (&mut Either::Two(_t),) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:300:18
|
LL | let &X(_t) = &x;
| ------ ^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&`: `X(_t)`
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:300:12
|
LL | let &X(_t) = &x;
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:304:31
|
LL | if let &Either::One(_t) = &e { }
| ---------------- ^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:304:25
|
LL | if let &Either::One(_t) = &e { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:308:34
|
LL | while let &Either::One(_t) = &e { }
| ---------------- ^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:308:28
|
LL | while let &Either::One(_t) = &e { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:312:11
|
LL | match &e {
| ^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &Either::One(_t)
| ----------------
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:314:22
|
LL | &Either::One(_t)
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:320:11
|
LL | match &e {
| ^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &Either::One(_t) => (),
| ----------------
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:322:22
|
LL | &Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:327:11
|
LL | match &e {
| ^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &Either::One(_t) => (),
| ----------------
| | |
| | data moved here
| help: consider removing the `&`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:329:22
|
LL | &Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:335:22
|
LL | let &mut X(_t) = &mut xm;
| ---------- ^^^^^^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&mut`: `X(_t)`
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:335:16
|
LL | let &mut X(_t) = &mut xm;
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:339:35
|
LL | if let &mut Either::One(_t) = &mut em { }
| -------------------- ^^^^^^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:339:29
|
LL | if let &mut Either::One(_t) = &mut em { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:343:38
|
LL | while let &mut Either::One(_t) = &mut em { }
| -------------------- ^^^^^^^ cannot move out of borrowed content
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:343:32
|
LL | while let &mut Either::One(_t) = &mut em { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:347:11
|
LL | match &mut em {
| ^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &mut Either::One(_t)
| --------------------
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:349:26
|
LL | &mut Either::One(_t)
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:355:11
|
LL | match &mut em {
| ^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &mut Either::One(_t) => (),
| --------------------
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:357:26
|
LL | &mut Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:362:11
|
LL | match &mut em {
| ^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &mut Either::One(_t) => (),
| --------------------
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:364:26
|
LL | &mut Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:369:11
|
LL | match &mut em {
| ^^^^^^^ cannot move out of borrowed content
LL | //~^ ERROR cannot move
LL | &mut Either::One(_t) => (),
| --------------------
| | |
| | data moved here
| help: consider removing the `&mut`: `Either::One(_t)`
|
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/simple.rs:371:26
|
LL | &mut Either::One(_t) => (),
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:214:11
|
LL | fn f1(&X(_t): &X) { }
| ^^^--^
| | |
| | data moved here
| cannot move out of borrowed content
| help: consider removing the `&`: `X(_t)`
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:214:14
|
LL | fn f1(&X(_t): &X) { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:261:11
|
LL | fn f2(&mut X(_t): &mut X) { }
| ^^^^^^^--^
| | |
| | data moved here
| cannot move out of borrowed content
| help: consider removing the `&mut`: `X(_t)`
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:261:18
|
LL | fn f2(&mut X(_t): &mut X) { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:281:11
|
LL | fn f3((&X(_t),): (&X,)) { }
| ^^^^--^^^
| | |
| | data moved here
| cannot move out of borrowed content
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:281:15
|
LL | fn f3((&X(_t),): (&X,)) { }
| ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/simple.rs:295:11
|
LL | fn f4((&mut X(_t),): (&mut X,)) { }
| ^^^^^^^^--^^^
| | |
| | data moved here
| cannot move out of borrowed content
|
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
--> $DIR/simple.rs:295:19
|
LL | fn f4((&mut X(_t),): (&mut X,)) { }
| ^^
error: aborting due to 60 previous errors
For more information about this error, try `rustc --explain E0507`.