1
Fork 0

Change pattern borrowing suggestions to be verbose

Synthesize a more accurate span and use verbose suggestion output to
make the message clearer.
This commit is contained in:
Esteban Küber 2022-12-08 09:02:54 -08:00
parent ed620cf969
commit e46416eed6
41 changed files with 1309 additions and 766 deletions

View file

@ -4,7 +4,7 @@ use rustc_middle::ty;
use rustc_mir_dataflow::move_paths::{ use rustc_mir_dataflow::move_paths::{
IllegalMoveOrigin, IllegalMoveOriginKind, LookupResult, MoveError, MovePathIndex, IllegalMoveOrigin, IllegalMoveOriginKind, LookupResult, MoveError, MovePathIndex,
}; };
use rustc_span::Span; use rustc_span::{BytePos, Span};
use crate::diagnostics::{DescribePlaceOpt, UseSpans}; use crate::diagnostics::{DescribePlaceOpt, UseSpans};
use crate::prefixes::PrefixSet; use crate::prefixes::PrefixSet;
@ -148,7 +148,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
match_span: Span, match_span: Span,
statement_span: Span, statement_span: Span,
) { ) {
debug!("append_binding_error(match_place={:?}, match_span={:?})", match_place, match_span); debug!(?match_place, ?match_span, "append_binding_error");
let from_simple_let = match_place.is_none(); let from_simple_let = match_place.is_none();
let match_place = match_place.unwrap_or(move_from); let match_place = match_place.unwrap_or(move_from);
@ -160,7 +160,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if let GroupedMoveError::MovesFromPlace { span, binds_to, .. } = ge if let GroupedMoveError::MovesFromPlace { span, binds_to, .. } = ge
&& match_span == *span && match_span == *span
{ {
debug!("appending local({:?}) to list", bind_to); debug!("appending local({bind_to:?}) to list");
if !binds_to.is_empty() { if !binds_to.is_empty() {
binds_to.push(bind_to); binds_to.push(bind_to);
} }
@ -198,7 +198,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
} = ge } = ge
{ {
if match_span == *span && mpi == *other_mpi { if match_span == *span && mpi == *other_mpi {
debug!("appending local({:?}) to list", bind_to); debug!("appending local({bind_to:?}) to list");
binds_to.push(bind_to); binds_to.push(bind_to);
return; return;
} }
@ -410,14 +410,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
fn add_move_hints(&self, error: GroupedMoveError<'tcx>, err: &mut Diagnostic, span: Span) { fn add_move_hints(&self, error: GroupedMoveError<'tcx>, err: &mut Diagnostic, span: Span) {
match error { match error {
GroupedMoveError::MovesFromPlace { mut binds_to, move_from, .. } => { GroupedMoveError::MovesFromPlace { mut binds_to, move_from, .. } => {
if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) { err.span_suggestion_verbose(
err.span_suggestion( span.shrink_to_lo(),
span, "consider borrowing here",
"consider borrowing here", "&".to_string(),
format!("&{snippet}"), Applicability::Unspecified,
Applicability::Unspecified, );
);
}
if binds_to.is_empty() { if binds_to.is_empty() {
let place_ty = move_from.ty(self.body, self.infcx.tcx).ty; let place_ty = move_from.ty(self.body, self.infcx.tcx).ty;
@ -469,28 +467,36 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
VarBindingForm { pat_span, .. }, VarBindingForm { pat_span, .. },
)))) = bind_to.local_info )))) = bind_to.local_info
{ {
if let Ok(pat_snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(pat_span) let Ok(pat_snippet) =
self.infcx.tcx.sess.source_map().span_to_snippet(pat_span) else { continue; };
let Some(stripped) = pat_snippet.strip_prefix('&') else { continue; };
let inner_pat_snippet = stripped.trim_start();
let (pat_span, suggestion, to_remove) = if inner_pat_snippet.starts_with("mut")
&& inner_pat_snippet["mut".len()..].starts_with(rustc_lexer::is_whitespace)
{ {
if let Some(stripped) = pat_snippet.strip_prefix('&') { let pat_span = pat_span.with_hi(
let pat_snippet = stripped.trim_start(); pat_span.lo()
let (suggestion, to_remove) = if pat_snippet.starts_with("mut") + BytePos((pat_snippet.len() - inner_pat_snippet.len()) as u32),
&& pat_snippet["mut".len()..].starts_with(rustc_lexer::is_whitespace) );
{ (pat_span, String::new(), "mutable borrow")
(pat_snippet["mut".len()..].trim_start(), "&mut") } else {
} else { let pat_span = pat_span.with_hi(
(pat_snippet, "&") pat_span.lo()
}; + BytePos(
suggestions.push((pat_span, to_remove, suggestion.to_owned())); (pat_snippet.len() - inner_pat_snippet.trim_start().len()) as u32,
} ),
} );
(pat_span, String::new(), "borrow")
};
suggestions.push((pat_span, to_remove, suggestion.to_owned()));
} }
} }
suggestions.sort_unstable_by_key(|&(span, _, _)| span); suggestions.sort_unstable_by_key(|&(span, _, _)| span);
suggestions.dedup_by_key(|&mut (span, _, _)| span); suggestions.dedup_by_key(|&mut (span, _, _)| span);
for (span, to_remove, suggestion) in suggestions { for (span, to_remove, suggestion) in suggestions {
err.span_suggestion( err.span_suggestion_verbose(
span, span,
&format!("consider removing the `{to_remove}`"), &format!("consider removing the {to_remove}"),
suggestion, suggestion,
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
@ -521,8 +527,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if binds_to.len() > 1 { if binds_to.len() > 1 {
err.note( err.note(
"move occurs because these variables have types that \ "move occurs because these variables have types that don't implement the `Copy` \
don't implement the `Copy` trait", trait",
); );
} }
} }

View file

@ -3,10 +3,14 @@ error[E0507]: cannot move out of `s` which is behind a shared reference
| |
LL | match *s { S(v) => v } LL | match *s { S(v) => v }
| ^^ - | ^^ -
| | | | |
| | data moved here | data moved here
| | move occurs because `v` has type `Vec<isize>`, which does not implement the `Copy` trait | move occurs because `v` has type `Vec<isize>`, which does not implement the `Copy` trait
| help: consider borrowing here: `&*s` |
help: consider borrowing here
|
LL | match &*s { S(v) => v }
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,31 +2,46 @@ error[E0507]: cannot move out of a shared reference
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:15 --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:15
| |
LL | for &a in x.iter() { LL | for &a in x.iter() {
| -- ^^^^^^^^ | - ^^^^^^^^
| || | |
| |data moved here | data moved here
| |move occurs because `a` has type `&mut i32`, which does not implement the `Copy` trait | move occurs because `a` has type `&mut i32`, which does not implement the `Copy` trait
| help: consider removing the `&`: `a` |
help: consider removing the borrow
|
LL - for &a in x.iter() {
LL + for a in x.iter() {
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:15 --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:15
| |
LL | for &a in &f.a { LL | for &a in &f.a {
| -- ^^^^ | - ^^^^
| || | |
| |data moved here | data moved here
| |move occurs because `a` has type `Box<isize>`, which does not implement the `Copy` trait | move occurs because `a` has type `Box<isize>`, which does not implement the `Copy` trait
| help: consider removing the `&`: `a` |
help: consider removing the borrow
|
LL - for &a in &f.a {
LL + for a in &f.a {
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15 --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15
| |
LL | for &a in x.iter() { LL | for &a in x.iter() {
| -- ^^^^^^^^ | - ^^^^^^^^
| || | |
| |data moved here | data moved here
| |move occurs because `a` has type `Box<i32>`, which does not implement the `Copy` trait | move occurs because `a` has type `Box<i32>`, which does not implement the `Copy` trait
| help: consider removing the `&`: `a` |
help: consider removing the borrow
|
LL - for &a in x.iter() {
LL + for a in x.iter() {
|
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of `*y` which is behind a shared reference
--> $DIR/borrowck-issue-2657-2.rs:7:18 --> $DIR/borrowck-issue-2657-2.rs:7:18
| |
LL | let _b = *y; LL | let _b = *y;
| ^^ | ^^ move occurs because `*y` has type `Box<i32>`, which does not implement the `Copy` trait
| | |
| move occurs because `*y` has type `Box<i32>`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*y` |
LL | let _b = &*y;
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,7 +2,7 @@ error[E0507]: cannot move out of `f` as enum variant `Foo1` which is behind a sh
--> $DIR/borrowck-move-error-with-note.rs:11:11 --> $DIR/borrowck-move-error-with-note.rs:11:11
| |
LL | match *f { LL | match *f {
| ^^ help: consider borrowing here: `&*f` | ^^
LL | Foo::Foo1(num1, LL | Foo::Foo1(num1,
| ---- data moved here | ---- data moved here
LL | num2) => (), LL | num2) => (),
@ -11,6 +11,10 @@ LL | Foo::Foo2(num) => (),
| --- ...and here | --- ...and here
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider borrowing here
|
LL | match &*f {
| +
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-error-with-note.rs:28:11 --> $DIR/borrowck-move-error-with-note.rs:28:11
@ -29,12 +33,17 @@ error[E0507]: cannot move out of `a.a` which is behind a shared reference
--> $DIR/borrowck-move-error-with-note.rs:46:11 --> $DIR/borrowck-move-error-with-note.rs:46:11
| |
LL | match a.a { LL | match a.a {
| ^^^ help: consider borrowing here: `&a.a` | ^^^
LL | n => { LL | n => {
| - | -
| | | |
| data moved here | data moved here
| move occurs because `n` has type `Box<isize>`, which does not implement the `Copy` trait | move occurs because `n` has type `Box<isize>`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &a.a {
| +
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of `*x` which is behind a raw pointer
--> $DIR/borrowck-move-from-unsafe-ptr.rs:2:13 --> $DIR/borrowck-move-from-unsafe-ptr.rs:2:13
| |
LL | let y = *x; LL | let y = *x;
| ^^ | ^^ move occurs because `*x` has type `Box<isize>`, which does not implement the `Copy` trait
| | |
| move occurs because `*x` has type `Box<isize>`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*x` |
LL | let y = &*x;
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -3,30 +3,45 @@ error[E0507]: cannot move out of a shared reference
| |
LL | fn arg_item(&_x: &String) {} LL | fn arg_item(&_x: &String) {}
| ^-- | ^--
| || | |
| |data moved here | data moved here
| |move occurs because `_x` has type `String`, which does not implement the `Copy` trait | move occurs because `_x` has type `String`, which does not implement the `Copy` trait
| help: consider removing the `&`: `_x` |
help: consider removing the borrow
|
LL - fn arg_item(&_x: &String) {}
LL + fn arg_item(_x: &String) {}
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/borrowck-move-in-irrefut-pat.rs:7:11 --> $DIR/borrowck-move-in-irrefut-pat.rs:7:11
| |
LL | with(|&_x| ()) LL | with(|&_x| ())
| ^-- | ^--
| || | |
| |data moved here | data moved here
| |move occurs because `_x` has type `String`, which does not implement the `Copy` trait | move occurs because `_x` has type `String`, which does not implement the `Copy` trait
| help: consider removing the `&`: `_x` |
help: consider removing the borrow
|
LL - with(|&_x| ())
LL + with(|_x| ())
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/borrowck-move-in-irrefut-pat.rs:12:15 --> $DIR/borrowck-move-in-irrefut-pat.rs:12:15
| |
LL | let &_x = &"hi".to_string(); LL | let &_x = &"hi".to_string();
| --- ^^^^^^^^^^^^^^^^^ | -- ^^^^^^^^^^^^^^^^^
| || | |
| |data moved here | data moved here
| |move occurs because `_x` has type `String`, which does not implement the `Copy` trait | move occurs because `_x` has type `String`, which does not implement the `Copy` trait
| help: consider removing the `&`: `_x` |
help: consider removing the borrow
|
LL - let &_x = &"hi".to_string();
LL + let _x = &"hi".to_string();
|
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of an `Rc`
--> $DIR/borrowck-move-out-of-overloaded-deref.rs:4:14 --> $DIR/borrowck-move-out-of-overloaded-deref.rs:4:14
| |
LL | let _x = *Rc::new("hi".to_string()); LL | let _x = *Rc::new("hi".to_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*Rc::new("hi".to_string())` |
LL | let _x = &*Rc::new("hi".to_string());
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -10,10 +10,10 @@ LL | Foo { string: b }] => {
| - ...and here | - ...and here
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the `&` help: consider removing the borrow
| |
LL ~ [Foo { string: a }, LL - &[Foo { string: a },
LL ~ Foo { string: b }] => { LL + [Foo { string: a },
| |
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of index of `MyVec<Box<i32>>`
--> $DIR/borrowck-overloaded-index-move-from-vec.rs:20:15 --> $DIR/borrowck-overloaded-index-move-from-vec.rs:20:15
| |
LL | let bad = v[0]; LL | let bad = v[0];
| ^^^^ | ^^^^ move occurs because value has type `Box<i32>`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `Box<i32>`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&v[0]` |
LL | let bad = &v[0];
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -37,7 +37,7 @@ fn c() {
&mut [_a, &mut [_a,
//~^ NOTE data moved here //~^ NOTE data moved here
//~| NOTE move occurs because `_a` has type //~| NOTE move occurs because `_a` has type
//~| HELP consider removing the `&mut` //~| HELP consider removing the mutable borrow
.. ..
] => { ] => {
} }
@ -56,7 +56,7 @@ fn d() {
//~^ ERROR cannot move out //~^ ERROR cannot move out
//~| NOTE cannot move out //~| NOTE cannot move out
&mut [ &mut [
//~^ HELP consider removing the `&mut` //~^ HELP consider removing the mutable borrow
_b] => {} _b] => {}
//~^ NOTE data moved here //~^ NOTE data moved here
//~| NOTE move occurs because `_b` has type //~| NOTE move occurs because `_b` has type
@ -79,7 +79,7 @@ fn e() {
//~^ NOTE data moved here //~^ NOTE data moved here
//~| NOTE and here //~| NOTE and here
//~| NOTE and here //~| NOTE and here
//~| HELP consider removing the `&mut` //~| HELP consider removing the mutable borrow
_ => {} _ => {}
} }
let a = vec[0]; //~ ERROR cannot move out let a = vec[0]; //~ ERROR cannot move out

View file

@ -34,14 +34,10 @@ LL | &mut [_a,
| data moved here | data moved here
| move occurs because `_a` has type `Box<isize>`, which does not implement the `Copy` trait | move occurs because `_a` has type `Box<isize>`, which does not implement the `Copy` trait
| |
help: consider removing the `&mut` help: consider removing the mutable borrow
| |
LL ~ [_a, LL - &mut [_a,
LL + LL + mut [_a,
LL +
LL +
LL + ..
LL ~ ] => {
| |
error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice
@ -52,7 +48,11 @@ LL | let a = vec[0];
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `vec[_]` has type `Box<isize>`, which does not implement the `Copy` trait | move occurs because `vec[_]` has type `Box<isize>`, which does not implement the `Copy` trait
| help: consider borrowing here: `&vec[0]` |
help: consider borrowing here
|
LL | let a = &vec[0];
| +
error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:55:11 --> $DIR/borrowck-vec-pattern-nesting.rs:55:11
@ -66,11 +66,10 @@ LL | _b] => {}
| data moved here | data moved here
| move occurs because `_b` has type `Box<isize>`, which does not implement the `Copy` trait | move occurs because `_b` has type `Box<isize>`, which does not implement the `Copy` trait
| |
help: consider removing the `&mut` help: consider removing the mutable borrow
| |
LL ~ [ LL - &mut [
LL + LL + mut [
LL ~ _b] => {}
| |
error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice
@ -81,7 +80,11 @@ LL | let a = vec[0];
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `vec[_]` has type `Box<isize>`, which does not implement the `Copy` trait | move occurs because `vec[_]` has type `Box<isize>`, which does not implement the `Copy` trait
| help: consider borrowing here: `&vec[0]` |
help: consider borrowing here
|
LL | let a = &vec[0];
| +
error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:74:11 --> $DIR/borrowck-vec-pattern-nesting.rs:74:11
@ -90,14 +93,17 @@ LL | match vec {
| ^^^ cannot move out of here | ^^^ cannot move out of here
... ...
LL | &mut [_a, _b, _c] => {} LL | &mut [_a, _b, _c] => {}
| ----------------- | -- -- -- ...and here
| | | | | | | |
| | | | ...and here | | ...and here
| | | ...and here | data moved here
| | data moved here
| help: consider removing the `&mut`: `[_a, _b, _c]`
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the mutable borrow
|
LL - &mut [_a, _b, _c] => {}
LL + mut [_a, _b, _c] => {}
|
error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:85:13 --> $DIR/borrowck-vec-pattern-nesting.rs:85:13
@ -107,7 +113,11 @@ LL | let a = vec[0];
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `vec[_]` has type `Box<isize>`, which does not implement the `Copy` trait | move occurs because `vec[_]` has type `Box<isize>`, which does not implement the `Copy` trait
| help: consider borrowing here: `&vec[0]` |
help: consider borrowing here
|
LL | let a = &vec[0];
| +
error: aborting due to 8 previous errors error: aborting due to 8 previous errors

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of static item `FOO`
--> $DIR/issue-17718-static-move.rs:6:14 --> $DIR/issue-17718-static-move.rs:6:14
| |
LL | let _a = FOO; LL | let _a = FOO;
| ^^^ | ^^^ move occurs because `FOO` has type `Foo`, which does not implement the `Copy` trait
| | |
| move occurs because `FOO` has type `Foo`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&FOO` |
LL | let _a = &FOO;
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,37 +2,45 @@ error[E0507]: cannot move out of a mutable reference
--> $DIR/issue-20801.rs:26:22 --> $DIR/issue-20801.rs:26:22
| |
LL | let a = unsafe { *mut_ref() }; LL | let a = unsafe { *mut_ref() };
| ^^^^^^^^^^ | ^^^^^^^^^^ move occurs because value has type `T`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `T`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*mut_ref()` |
LL | let a = unsafe { &*mut_ref() };
| +
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/issue-20801.rs:29:22 --> $DIR/issue-20801.rs:29:22
| |
LL | let b = unsafe { *imm_ref() }; LL | let b = unsafe { *imm_ref() };
| ^^^^^^^^^^ | ^^^^^^^^^^ move occurs because value has type `T`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `T`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*imm_ref()` |
LL | let b = unsafe { &*imm_ref() };
| +
error[E0507]: cannot move out of a raw pointer error[E0507]: cannot move out of a raw pointer
--> $DIR/issue-20801.rs:32:22 --> $DIR/issue-20801.rs:32:22
| |
LL | let c = unsafe { *mut_ptr() }; LL | let c = unsafe { *mut_ptr() };
| ^^^^^^^^^^ | ^^^^^^^^^^ move occurs because value has type `T`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `T`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*mut_ptr()` |
LL | let c = unsafe { &*mut_ptr() };
| +
error[E0507]: cannot move out of a raw pointer error[E0507]: cannot move out of a raw pointer
--> $DIR/issue-20801.rs:35:22 --> $DIR/issue-20801.rs:35:22
| |
LL | let d = unsafe { *const_ptr() }; LL | let d = unsafe { *const_ptr() };
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ move occurs because value has type `T`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `T`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*const_ptr()` |
LL | let d = unsafe { &*const_ptr() };
| +
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of static item `X`
--> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 --> $DIR/issue-47215-ice-from-drop-elab.rs:17:21
| |
LL | let mut x = X; LL | let mut x = X;
| ^ | ^ move occurs because `X` has type `AtomicUsize`, which does not implement the `Copy` trait
| | |
| move occurs because `X` has type `AtomicUsize`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&X` |
LL | let mut x = &X;
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of `*array` which is behind a shared reference
--> $DIR/issue-54597-reject-move-out-of-borrow-via-pat.rs:14:13 --> $DIR/issue-54597-reject-move-out-of-borrow-via-pat.rs:14:13
| |
LL | *array LL | *array
| ^^^^^^ | ^^^^^^ move occurs because `*array` has type `Vec<Value>`, which does not implement the `Copy` trait
| | |
| move occurs because `*array` has type `Vec<Value>`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*array` |
LL | &*array
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -8,10 +8,12 @@ LL | take_mut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
LL | LL |
LL | let _foo: String = val; LL | let _foo: String = val;
| ^^^ | ^^^ move occurs because `val` has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because `val` has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&val` |
LL | let _foo: String = &val;
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,10 +2,7 @@ error[E0507]: cannot move out of static item `D`
--> $DIR/move-error-snippets-ext.rs:5:17 --> $DIR/move-error-snippets-ext.rs:5:17
| |
LL | let a = $c; LL | let a = $c;
| ^^ | ^^ move occurs because `D` has type `A`, which does not implement the `Copy` trait
| |
| move occurs because `D` has type `A`, which does not implement the `Copy` trait
| help: consider borrowing here: `&$c`
| |
::: $DIR/move-error-snippets.rs:21:1 ::: $DIR/move-error-snippets.rs:21:1
| |
@ -13,6 +10,10 @@ LL | sss!();
| ------ in this macro invocation | ------ in this macro invocation
| |
= note: this error originates in the macro `aaa` which comes from the expansion of the macro `sss` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `aaa` which comes from the expansion of the macro `sss` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider borrowing here
|
LL | let a = &$c;
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -19,4 +19,11 @@ fn main() {
&E::Foo => {} &E::Foo => {}
&E::Bar(ref identifier) => println!("{}", *identifier) &E::Bar(ref identifier) => println!("{}", *identifier)
}; };
if let &E::Bar(identifier) = &s.x { //~ ERROR cannot move
f(identifier.clone());
};
let &E::Bar(identifier) = &s.x else { //~ ERROR cannot move
return;
};
f(identifier.clone());
} }

View file

@ -5,12 +5,43 @@ LL | match &s.x {
| ^^^^ | ^^^^
LL | &E::Foo => {} LL | &E::Foo => {}
LL | &E::Bar(identifier) => f(identifier.clone()) LL | &E::Bar(identifier) => f(identifier.clone())
| ------------------- | ----------
| | | | |
| | data moved here | data moved here
| | move occurs because `identifier` has type `String`, which does not implement the `Copy` trait | move occurs because `identifier` has type `String`, which does not implement the `Copy` trait
| help: consider removing the `&`: `E::Bar(identifier)` |
help: consider removing the borrow
|
LL - &E::Bar(identifier) => f(identifier.clone())
LL + E::Bar(identifier) => f(identifier.clone())
|
error: aborting due to previous error error[E0507]: cannot move out of a shared reference
--> $DIR/by-move-pattern-binding.rs:22:34
|
LL | if let &E::Bar(identifier) = &s.x {
| ---------- ^^^^
| |
| data moved here
| move occurs because `identifier` has type `String`, which does not implement the `Copy` trait
|
help: consider removing the borrow
|
LL - if let &E::Bar(identifier) = &s.x {
LL + if let E::Bar(identifier) = &s.x {
|
error[E0507]: cannot move out of a shared reference
--> $DIR/by-move-pattern-binding.rs:25:17
|
LL | let &E::Bar(identifier) = &s.x else {
| ^^^^^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let &E::Bar(&identifier) = &s.x else {
| +
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0507`. For more information about this error, try `rustc --explain E0507`.

View file

@ -58,10 +58,12 @@ error[E0507]: cannot move out of static item `x`
--> $DIR/check-static-values-constraints.rs:110:45 --> $DIR/check-static-values-constraints.rs:110:45
| |
LL | let y = { static x: Box<isize> = box 3; x }; LL | let y = { static x: Box<isize> = box 3; x };
| ^ | ^ move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait
| | |
| move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&x` |
LL | let y = { static x: Box<isize> = box 3; &x };
| +
error[E0010]: allocations are not allowed in statics error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:110:38 --> $DIR/check-static-values-constraints.rs:110:38

View file

@ -6,7 +6,11 @@ LL | let _value = array[0];
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `array[_]` has type `NonCopy`, which does not implement the `Copy` trait | move occurs because `array[_]` has type `NonCopy`, which does not implement the `Copy` trait
| help: consider borrowing here: `&array[0]` |
help: consider borrowing here
|
LL | let _value = &array[0];
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -6,7 +6,11 @@ LL | let _value = array[0];
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `array[_]` has type `NonCopy`, which does not implement the `Copy` trait | move occurs because `array[_]` has type `NonCopy`, which does not implement the `Copy` trait
| help: consider borrowing here: `&array[0]` |
help: consider borrowing here
|
LL | let _value = &array[0];
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -6,7 +6,11 @@ LL | let fancy_field = drop_struct.fancy;
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `drop_struct.fancy` has type `FancyNum`, which does not implement the `Copy` trait | move occurs because `drop_struct.fancy` has type `FancyNum`, which does not implement the `Copy` trait
| help: consider borrowing here: `&drop_struct.fancy` |
help: consider borrowing here
|
LL | let fancy_field = &drop_struct.fancy;
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of index of `Vec<String>`
--> $DIR/issue-40402-1.rs:9:13 --> $DIR/issue-40402-1.rs:9:13
| |
LL | let e = f.v[0]; LL | let e = f.v[0];
| ^^^^^^ | ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&f.v[0]` |
LL | let e = &f.v[0];
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,12 +2,16 @@ error[E0507]: cannot move out of index of `Vec<(String, String)>`
--> $DIR/issue-40402-2.rs:5:18 --> $DIR/issue-40402-2.rs:5:18
| |
LL | let (a, b) = x[0]; LL | let (a, b) = x[0];
| - - ^^^^ help: consider borrowing here: `&x[0]` | - - ^^^^
| | | | | |
| | ...and here | | ...and here
| data moved here | data moved here
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider borrowing here
|
LL | let (a, b) = &x[0];
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -5,11 +5,16 @@ LL | match x {
| ^ | ^
LL | LL |
LL | &Some(_y) => (), LL | &Some(_y) => (),
| --------- | --
| | | | |
| | data moved here | data moved here
| | move occurs because `_y` has type `Box<i32>`, which does not implement the `Copy` trait | move occurs because `_y` has type `Box<i32>`, which does not implement the `Copy` trait
| help: consider removing the `&`: `Some(_y)` |
help: consider removing the borrow
|
LL - &Some(_y) => (),
LL + Some(_y) => (),
|
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,45 +2,57 @@ error[E0508]: cannot move out of type `[D; 4]`, a non-copy array
--> $DIR/move-out-of-array-ref.rs:8:24 --> $DIR/move-out-of-array-ref.rs:8:24
| |
LL | let [_, e, _, _] = *a; LL | let [_, e, _, _] = *a;
| - ^^ | - ^^ cannot move out of here
| | | | |
| | cannot move out of here
| | help: consider borrowing here: `&*a`
| data moved here | data moved here
| move occurs because `e` has type `D`, which does not implement the `Copy` trait | move occurs because `e` has type `D`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let [_, e, _, _] = &*a;
| +
error[E0508]: cannot move out of type `[D; 4]`, a non-copy array error[E0508]: cannot move out of type `[D; 4]`, a non-copy array
--> $DIR/move-out-of-array-ref.rs:13:27 --> $DIR/move-out-of-array-ref.rs:13:27
| |
LL | let [_, s @ .. , _] = *a; LL | let [_, s @ .. , _] = *a;
| - ^^ | - ^^ cannot move out of here
| | | | |
| | cannot move out of here
| | help: consider borrowing here: `&*a`
| data moved here | data moved here
| move occurs because `s` has type `[D; 2]`, which does not implement the `Copy` trait | move occurs because `s` has type `[D; 2]`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let [_, s @ .. , _] = &*a;
| +
error[E0508]: cannot move out of type `[D; 4]`, a non-copy array error[E0508]: cannot move out of type `[D; 4]`, a non-copy array
--> $DIR/move-out-of-array-ref.rs:18:24 --> $DIR/move-out-of-array-ref.rs:18:24
| |
LL | let [_, e, _, _] = *a; LL | let [_, e, _, _] = *a;
| - ^^ | - ^^ cannot move out of here
| | | | |
| | cannot move out of here
| | help: consider borrowing here: `&*a`
| data moved here | data moved here
| move occurs because `e` has type `D`, which does not implement the `Copy` trait | move occurs because `e` has type `D`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let [_, e, _, _] = &*a;
| +
error[E0508]: cannot move out of type `[D; 4]`, a non-copy array error[E0508]: cannot move out of type `[D; 4]`, a non-copy array
--> $DIR/move-out-of-array-ref.rs:23:27 --> $DIR/move-out-of-array-ref.rs:23:27
| |
LL | let [_, s @ .. , _] = *a; LL | let [_, s @ .. , _] = *a;
| - ^^ | - ^^ cannot move out of here
| | | | |
| | cannot move out of here
| | help: consider borrowing here: `&*a`
| data moved here | data moved here
| move occurs because `s` has type `[D; 2]`, which does not implement the `Copy` trait | move occurs because `s` has type `[D; 2]`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let [_, s @ .. , _] = &*a;
| +
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -2,13 +2,18 @@ error[E0507]: cannot move out of `hellothere.x` as enum variant `Bar` which is b
--> $DIR/moves-based-on-type-block-bad.rs:22:19 --> $DIR/moves-based-on-type-block-bad.rs:22:19
| |
LL | match hellothere.x { LL | match hellothere.x {
| ^^^^^^^^^^^^ help: consider borrowing here: `&hellothere.x` | ^^^^^^^^^^^^
LL | box E::Foo(_) => {} LL | box E::Foo(_) => {}
LL | box E::Bar(x) => println!("{}", x.to_string()), LL | box E::Bar(x) => println!("{}", x.to_string()),
| - | -
| | | |
| data moved here | data moved here
| move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait | move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &hellothere.x {
| +
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,28 +2,34 @@ error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:5:15 --> $DIR/cannot-move-block-spans.rs:5:15
| |
LL | let x = { *r }; LL | let x = { *r };
| ^^ | ^^ move occurs because `*r` has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because `*r` has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*r` |
LL | let x = { &*r };
| +
error[E0507]: cannot move out of `*r` which is behind a shared reference error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:6:22 --> $DIR/cannot-move-block-spans.rs:6:22
| |
LL | let y = unsafe { *r }; LL | let y = unsafe { *r };
| ^^ | ^^ move occurs because `*r` has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because `*r` has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*r` |
LL | let y = unsafe { &*r };
| +
error[E0507]: cannot move out of `*r` which is behind a shared reference error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:7:26 --> $DIR/cannot-move-block-spans.rs:7:26
| |
LL | let z = loop { break *r; }; LL | let z = loop { break *r; };
| ^^ | ^^ move occurs because `*r` has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because `*r` has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*r` |
LL | let z = loop { break &*r; };
| +
error[E0508]: cannot move out of type `[String; 2]`, a non-copy array error[E0508]: cannot move out of type `[String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:11:15 --> $DIR/cannot-move-block-spans.rs:11:15
@ -33,7 +39,11 @@ LL | let x = { arr[0] };
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `arr[_]` has type `String`, which does not implement the `Copy` trait | move occurs because `arr[_]` has type `String`, which does not implement the `Copy` trait
| help: consider borrowing here: `&arr[0]` |
help: consider borrowing here
|
LL | let x = { &arr[0] };
| +
error[E0508]: cannot move out of type `[String; 2]`, a non-copy array error[E0508]: cannot move out of type `[String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:12:22 --> $DIR/cannot-move-block-spans.rs:12:22
@ -43,7 +53,11 @@ LL | let y = unsafe { arr[0] };
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `arr[_]` has type `String`, which does not implement the `Copy` trait | move occurs because `arr[_]` has type `String`, which does not implement the `Copy` trait
| help: consider borrowing here: `&arr[0]` |
help: consider borrowing here
|
LL | let y = unsafe { &arr[0] };
| +
error[E0508]: cannot move out of type `[String; 2]`, a non-copy array error[E0508]: cannot move out of type `[String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:13:26 --> $DIR/cannot-move-block-spans.rs:13:26
@ -53,34 +67,44 @@ LL | let z = loop { break arr[0]; };
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `arr[_]` has type `String`, which does not implement the `Copy` trait | move occurs because `arr[_]` has type `String`, which does not implement the `Copy` trait
| help: consider borrowing here: `&arr[0]` |
help: consider borrowing here
|
LL | let z = loop { break &arr[0]; };
| +
error[E0507]: cannot move out of `*r` which is behind a shared reference error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:17:38 --> $DIR/cannot-move-block-spans.rs:17:38
| |
LL | let x = { let mut u = 0; u += 1; *r }; LL | let x = { let mut u = 0; u += 1; *r };
| ^^ | ^^ move occurs because `*r` has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because `*r` has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*r` |
LL | let x = { let mut u = 0; u += 1; &*r };
| +
error[E0507]: cannot move out of `*r` which is behind a shared reference error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:18:45 --> $DIR/cannot-move-block-spans.rs:18:45
| |
LL | let y = unsafe { let mut u = 0; u += 1; *r }; LL | let y = unsafe { let mut u = 0; u += 1; *r };
| ^^ | ^^ move occurs because `*r` has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because `*r` has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*r` |
LL | let y = unsafe { let mut u = 0; u += 1; &*r };
| +
error[E0507]: cannot move out of `*r` which is behind a shared reference error[E0507]: cannot move out of `*r` which is behind a shared reference
--> $DIR/cannot-move-block-spans.rs:19:49 --> $DIR/cannot-move-block-spans.rs:19:49
| |
LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; };
| ^^ | ^^ move occurs because `*r` has type `String`, which does not implement the `Copy` trait
| | |
| move occurs because `*r` has type `String`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*r` |
LL | let z = loop { let mut u = 0; u += 1; break &*r; u += 2; };
| +
error: aborting due to 9 previous errors error: aborting due to 9 previous errors

View file

@ -36,7 +36,11 @@ LL | let p = s.url; p
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `s.url` has type `&mut String`, which does not implement the `Copy` trait | move occurs because `s.url` has type `&mut String`, which does not implement the `Copy` trait
| help: consider borrowing here: `&s.url` |
help: consider borrowing here
|
LL | let p = &s.url; p
| +
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -2,10 +2,12 @@ error[E0507]: cannot move out of `*a` which is behind a shared reference
--> $DIR/move-errors.rs:6:13 --> $DIR/move-errors.rs:6:13
| |
LL | let b = *a; LL | let b = *a;
| ^^ | ^^ move occurs because `*a` has type `A`, which does not implement the `Copy` trait
| | |
| move occurs because `*a` has type `A`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*a` |
LL | let b = &*a;
| +
error[E0508]: cannot move out of type `[A; 1]`, a non-copy array error[E0508]: cannot move out of type `[A; 1]`, a non-copy array
--> $DIR/move-errors.rs:12:13 --> $DIR/move-errors.rs:12:13
@ -15,25 +17,33 @@ LL | let b = a[0];
| | | |
| cannot move out of here | cannot move out of here
| move occurs because `a[_]` has type `A`, which does not implement the `Copy` trait | move occurs because `a[_]` has type `A`, which does not implement the `Copy` trait
| help: consider borrowing here: `&a[0]` |
help: consider borrowing here
|
LL | let b = &a[0];
| +
error[E0507]: cannot move out of `**r` which is behind a shared reference error[E0507]: cannot move out of `**r` which is behind a shared reference
--> $DIR/move-errors.rs:19:13 --> $DIR/move-errors.rs:19:13
| |
LL | let s = **r; LL | let s = **r;
| ^^^ | ^^^ move occurs because `**r` has type `A`, which does not implement the `Copy` trait
| | |
| move occurs because `**r` has type `A`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&**r` |
LL | let s = &**r;
| +
error[E0507]: cannot move out of an `Rc` error[E0507]: cannot move out of an `Rc`
--> $DIR/move-errors.rs:27:13 --> $DIR/move-errors.rs:27:13
| |
LL | let s = *r; LL | let s = *r;
| ^^ | ^^ move occurs because value has type `A`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `A`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*r` |
LL | let s = &*r;
| +
error[E0508]: cannot move out of type `[A; 1]`, a non-copy array error[E0508]: cannot move out of type `[A; 1]`, a non-copy array
--> $DIR/move-errors.rs:32:13 --> $DIR/move-errors.rs:32:13
@ -43,16 +53,25 @@ LL | let a = [A("".to_string())][0];
| | | |
| cannot move out of here | cannot move out of here
| move occurs because value has type `A`, which does not implement the `Copy` trait | move occurs because value has type `A`, which does not implement the `Copy` trait
| help: consider borrowing here: `&[A("".to_string())][0]` |
help: consider borrowing here
|
LL | let a = &[A("".to_string())][0];
| +
error[E0507]: cannot move out of `a` which is behind a shared reference error[E0507]: cannot move out of `a` which is behind a shared reference
--> $DIR/move-errors.rs:38:16 --> $DIR/move-errors.rs:38:16
| |
LL | let A(s) = *a; LL | let A(s) = *a;
| - ^^ help: consider borrowing here: `&*a` | - ^^
| | | |
| data moved here | data moved here
| move occurs because `s` has type `String`, which does not implement the `Copy` trait | move occurs because `s` has type `String`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let A(s) = &*a;
| +
error[E0509]: cannot move out of type `D`, which implements the `Drop` trait error[E0509]: cannot move out of type `D`, which implements the `Drop` trait
--> $DIR/move-errors.rs:44:19 --> $DIR/move-errors.rs:44:19
@ -73,10 +92,7 @@ error[E0508]: cannot move out of type `[B; 1]`, a non-copy array
--> $DIR/move-errors.rs:74:11 --> $DIR/move-errors.rs:74:11
| |
LL | match x[0] { LL | match x[0] {
| ^^^^ | ^^^^ cannot move out of here
| |
| cannot move out of here
| help: consider borrowing here: `&x[0]`
LL | LL |
LL | B::U(d) => (), LL | B::U(d) => (),
| - data moved here | - data moved here
@ -84,6 +100,10 @@ LL | B::V(s) => (),
| - ...and here | - ...and here
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider borrowing here
|
LL | match &x[0] {
| +
error[E0509]: cannot move out of type `D`, which implements the `Drop` trait error[E0509]: cannot move out of type `D`, which implements the `Drop` trait
--> $DIR/move-errors.rs:83:11 --> $DIR/move-errors.rs:83:11
@ -138,13 +158,18 @@ error[E0507]: cannot move out of `x` as enum variant `Err` which is behind a sha
--> $DIR/move-errors.rs:110:11 --> $DIR/move-errors.rs:110:11
| |
LL | match *x { LL | match *x {
| ^^ help: consider borrowing here: `&*x` | ^^
LL | LL |
LL | Ok(s) | Err(s) => (), LL | Ok(s) | Err(s) => (),
| - | -
| | | |
| data moved here | data moved here
| move occurs because `s` has type `String`, which does not implement the `Copy` trait | move occurs because `s` has type `String`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &*x {
| +
error: aborting due to 14 previous errors error: aborting due to 14 previous errors

View file

@ -2,37 +2,45 @@ error[E0507]: cannot move out of a shared reference
--> $DIR/std-uncopyable-atomics.rs:9:13 --> $DIR/std-uncopyable-atomics.rs:9:13
| |
LL | let x = *&x; LL | let x = *&x;
| ^^^ | ^^^ move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*&x` |
LL | let x = &*&x;
| +
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/std-uncopyable-atomics.rs:11:13 --> $DIR/std-uncopyable-atomics.rs:11:13
| |
LL | let x = *&x; LL | let x = *&x;
| ^^^ | ^^^ move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*&x` |
LL | let x = &*&x;
| +
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/std-uncopyable-atomics.rs:13:13 --> $DIR/std-uncopyable-atomics.rs:13:13
| |
LL | let x = *&x; LL | let x = *&x;
| ^^^ | ^^^ move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*&x` |
LL | let x = &*&x;
| +
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/std-uncopyable-atomics.rs:15:13 --> $DIR/std-uncopyable-atomics.rs:15:13
| |
LL | let x = *&x; LL | let x = *&x;
| ^^^ | ^^^ move occurs because value has type `std::sync::atomic::AtomicPtr<usize>`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `std::sync::atomic::AtomicPtr<usize>`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&*&x` |
LL | let x = &*&x;
| +
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -38,31 +38,25 @@ pub fn main() {
let &(X(_t), X(_u)) = &(x.clone(), x.clone()); let &(X(_t), X(_u)) = &(x.clone(), x.clone());
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing the borrow
//~| SUGGESTION (X(_t), X(_u))
if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { } if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing the borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { } while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing the borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
match &(e.clone(), e.clone()) { match &(e.clone(), e.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&(Either::One(_t), Either::Two(_u)) => (), &(Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&` //~^ HELP consider removing the borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&(Either::Two(_t), Either::One(_u)) => (), &(Either::Two(_t), Either::One(_u)) => (),
//~^ HELP consider removing the `&` //~^ HELP consider removing the borrow
//~| SUGGESTION (Either::Two(_t), Either::One(_u))
_ => (), _ => (),
} }
match &(e.clone(), e.clone()) { match &(e.clone(), e.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&(Either::One(_t), Either::Two(_u)) &(Either::One(_t), Either::Two(_u))
//~^ HELP consider removing the `&` //~^ HELP consider removing the borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
| &(Either::Two(_t), Either::One(_u)) => (), | &(Either::Two(_t), Either::One(_u)) => (),
// FIXME: would really like a suggestion here too // FIXME: would really like a suggestion here too
_ => (), _ => (),
@ -70,51 +64,42 @@ pub fn main() {
match &(e.clone(), e.clone()) { match &(e.clone(), e.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&(Either::One(_t), Either::Two(_u)) => (), &(Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&` //~^ HELP consider removing the borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&(Either::Two(ref _t), Either::One(ref _u)) => (), &(Either::Two(ref _t), Either::One(ref _u)) => (),
_ => (), _ => (),
} }
match &(e.clone(), e.clone()) { match &(e.clone(), e.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&(Either::One(_t), Either::Two(_u)) => (), &(Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&` //~^ HELP consider removing the borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
(Either::Two(_t), Either::One(_u)) => (), (Either::Two(_t), Either::One(_u)) => (),
_ => (), _ => (),
} }
fn f5(&(X(_t), X(_u)): &(X, X)) { } fn f5(&(X(_t), X(_u)): &(X, X)) { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing the borrow
//~| SUGGESTION (X(_t), X(_u))
let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone()); let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing the mutable borrow
//~| SUGGESTION (X(_t), X(_u))
if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { } if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing the mutable borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { } while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing the mutable borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
match &mut (em.clone(), em.clone()) { match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) => (), &mut (Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing the mutable borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&mut (Either::Two(_t), Either::One(_u)) => (), &mut (Either::Two(_t), Either::One(_u)) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing the mutable borrow
//~| SUGGESTION (Either::Two(_t), Either::One(_u))
_ => (), _ => (),
} }
match &mut (em.clone(), em.clone()) { match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) &mut (Either::One(_t), Either::Two(_u))
//~^ HELP consider removing the `&mut` //~^ HELP consider removing the mutable borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
| &mut (Either::Two(_t), Either::One(_u)) => (), | &mut (Either::Two(_t), Either::One(_u)) => (),
// FIXME: would really like a suggestion here too // FIXME: would really like a suggestion here too
_ => (), _ => (),
@ -122,29 +107,25 @@ pub fn main() {
match &mut (em.clone(), em.clone()) { match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) => (), &mut (Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing the mutable borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&mut (Either::Two(ref _t), Either::One(ref _u)) => (), &mut (Either::Two(ref _t), Either::One(ref _u)) => (),
_ => (), _ => (),
} }
match &mut (em.clone(), em.clone()) { match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) => (), &mut (Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing the mutable borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&mut (Either::Two(ref mut _t), Either::One(ref mut _u)) => (), &mut (Either::Two(ref mut _t), Either::One(ref mut _u)) => (),
_ => (), _ => (),
} }
match &mut (em.clone(), em.clone()) { match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) => (), &mut (Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing the mutable borrow
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
(Either::Two(_t), Either::One(_u)) => (), (Either::Two(_t), Either::One(_u)) => (),
_ => (), _ => (),
} }
fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { } fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing the mutable borrow
//~| SUGGESTION (X(_t), X(_u))
} }

View file

@ -2,40 +2,52 @@ error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:39:27 --> $DIR/duplicate-suggestions.rs:39:27
| |
LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone()); LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
| --------------- ^^^^^^^^^^^^^^^^^^^^^^^ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^
| | | | | | |
| | | ...and here | | ...and here
| | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the borrow
|
LL - let &(X(_t), X(_u)) = &(x.clone(), x.clone());
LL + let (X(_t), X(_u)) = &(x.clone(), x.clone());
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:43:50 --> $DIR/duplicate-suggestions.rs:42:50
| |
LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { } LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ----------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^
| | | | | | |
| | | ...and here | | ...and here
| | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the borrow
|
LL - if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
LL + if let (Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:47:53 --> $DIR/duplicate-suggestions.rs:45:53
| |
LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { } LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ----------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^
| | | | | | |
| | | ...and here | | ...and here
| | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the borrow
|
LL - while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
LL + while let (Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:51:11 --> $DIR/duplicate-suggestions.rs:48:11
| |
LL | match &(e.clone(), e.clone()) { LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -44,22 +56,24 @@ LL | &(Either::One(_t), Either::Two(_u)) => (),
| -- -- ...and here | -- -- ...and here
| | | |
| data moved here | data moved here
... LL |
LL | &(Either::Two(_t), Either::One(_u)) => (), LL | &(Either::Two(_t), Either::One(_u)) => (),
| -- ...and here -- ...and here | -- ...and here -- ...and here
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the `&` help: consider removing the borrow
| |
LL | (Either::One(_t), Either::Two(_u)) => (), LL - &(Either::One(_t), Either::Two(_u)) => (),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LL + (Either::One(_t), Either::Two(_u)) => (),
help: consider removing the `&` |
help: consider removing the borrow
|
LL - &(Either::Two(_t), Either::One(_u)) => (),
LL + (Either::Two(_t), Either::One(_u)) => (),
| |
LL | (Either::Two(_t), Either::One(_u)) => (),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:61:11 --> $DIR/duplicate-suggestions.rs:56:11
| |
LL | match &(e.clone(), e.clone()) { LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -70,82 +84,98 @@ LL | &(Either::One(_t), Either::Two(_u))
| data moved here | data moved here
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the `&` help: consider removing the borrow
| |
LL ~ (Either::One(_t), Either::Two(_u)) LL - &(Either::One(_t), Either::Two(_u))
LL + LL + (Either::One(_t), Either::Two(_u))
LL +
LL ~ | &(Either::Two(_t), Either::One(_u)) => (),
| |
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:70:11 --> $DIR/duplicate-suggestions.rs:64:11
| |
LL | match &(e.clone(), e.clone()) { LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
LL | LL |
LL | &(Either::One(_t), Either::Two(_u)) => (), LL | &(Either::One(_t), Either::Two(_u)) => (),
| ----------------------------------- | -- -- ...and here
| | | | | |
| | | ...and here | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the borrow
|
LL - &(Either::One(_t), Either::Two(_u)) => (),
LL + (Either::One(_t), Either::Two(_u)) => (),
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:78:11 --> $DIR/duplicate-suggestions.rs:71:11
| |
LL | match &(e.clone(), e.clone()) { LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
LL | LL |
LL | &(Either::One(_t), Either::Two(_u)) => (), LL | &(Either::One(_t), Either::Two(_u)) => (),
| ----------------------------------- | -- -- ...and here
| | | | | |
| | | ...and here | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the borrow
|
LL - &(Either::One(_t), Either::Two(_u)) => (),
LL + (Either::One(_t), Either::Two(_u)) => (),
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:91:31 --> $DIR/duplicate-suggestions.rs:82:31
| |
LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone()); LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | | | | |
| | | ...and here | | ...and here
| | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the mutable borrow
|
LL - let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
LL + let mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:95:54 --> $DIR/duplicate-suggestions.rs:85:54
| |
LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { } LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| --------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | | | | |
| | | ...and here | | ...and here
| | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the mutable borrow
|
LL - if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
LL + if let mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:99:57 --> $DIR/duplicate-suggestions.rs:88:57
| |
LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { } LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| --------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | | | | |
| | | ...and here | | ...and here
| | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the mutable borrow
|
LL - while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
LL + while let mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:103:11 --> $DIR/duplicate-suggestions.rs:91:11
| |
LL | match &mut (em.clone(), em.clone()) { LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -154,22 +184,24 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| -- -- ...and here | -- -- ...and here
| | | |
| data moved here | data moved here
... LL |
LL | &mut (Either::Two(_t), Either::One(_u)) => (), LL | &mut (Either::Two(_t), Either::One(_u)) => (),
| -- ...and here -- ...and here | -- ...and here -- ...and here
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the `&mut` help: consider removing the mutable borrow
| |
LL | (Either::One(_t), Either::Two(_u)) => (), LL - &mut (Either::One(_t), Either::Two(_u)) => (),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LL + mut (Either::One(_t), Either::Two(_u)) => (),
help: consider removing the `&mut` |
help: consider removing the mutable borrow
|
LL - &mut (Either::Two(_t), Either::One(_u)) => (),
LL + mut (Either::Two(_t), Either::One(_u)) => (),
| |
LL | (Either::Two(_t), Either::One(_u)) => (),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:113:11 --> $DIR/duplicate-suggestions.rs:99:11
| |
LL | match &mut (em.clone(), em.clone()) { LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -180,82 +212,97 @@ LL | &mut (Either::One(_t), Either::Two(_u))
| data moved here | data moved here
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the `&mut` help: consider removing the mutable borrow
| |
LL ~ (Either::One(_t), Either::Two(_u)) LL - &mut (Either::One(_t), Either::Two(_u))
LL + LL + mut (Either::One(_t), Either::Two(_u))
LL +
LL ~ | &mut (Either::Two(_t), Either::One(_u)) => (),
| |
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:122:11 --> $DIR/duplicate-suggestions.rs:107:11
| |
LL | match &mut (em.clone(), em.clone()) { LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | LL |
LL | &mut (Either::One(_t), Either::Two(_u)) => (), LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| --------------------------------------- | -- -- ...and here
| | | | | |
| | | ...and here | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the mutable borrow
|
LL - &mut (Either::One(_t), Either::Two(_u)) => (),
LL + mut (Either::One(_t), Either::Two(_u)) => (),
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:130:11 --> $DIR/duplicate-suggestions.rs:114:11
| |
LL | match &mut (em.clone(), em.clone()) { LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | LL |
LL | &mut (Either::One(_t), Either::Two(_u)) => (), LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| --------------------------------------- | -- -- ...and here
| | | | | |
| | | ...and here | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the mutable borrow
|
LL - &mut (Either::One(_t), Either::Two(_u)) => (),
LL + mut (Either::One(_t), Either::Two(_u)) => (),
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:138:11 --> $DIR/duplicate-suggestions.rs:121:11
| |
LL | match &mut (em.clone(), em.clone()) { LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | LL |
LL | &mut (Either::One(_t), Either::Two(_u)) => (), LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| --------------------------------------- | -- -- ...and here
| | | | | |
| | | ...and here | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the mutable borrow
|
LL - &mut (Either::One(_t), Either::Two(_u)) => (),
LL + mut (Either::One(_t), Either::Two(_u)) => (),
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:86:11 --> $DIR/duplicate-suggestions.rs:78:11
| |
LL | fn f5(&(X(_t), X(_u)): &(X, X)) { } LL | fn f5(&(X(_t), X(_u)): &(X, X)) { }
| ^^^^--^^^^^--^^ | ^^^^--^^^^^--^^
| | | | | | |
| | | ...and here | | ...and here
| | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the borrow
|
LL - fn f5(&(X(_t), X(_u)): &(X, X)) { }
LL + fn f5((X(_t), X(_u)): &(X, X)) { }
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:146:11 --> $DIR/duplicate-suggestions.rs:128:11
| |
LL | fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { } LL | fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
| ^^^^^^^^--^^^^^--^^ | ^^^^^^^^--^^^^^--^^
| | | | | | |
| | | ...and here | | ...and here
| | data moved 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 = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the mutable borrow
|
LL - fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
LL + fn f6(mut (X(_t), X(_u)): &mut (X, X)) { }
|
error: aborting due to 17 previous errors error: aborting due to 17 previous errors

View file

@ -28,26 +28,21 @@ fn move_into_fn() {
let X(_t) = x; let X(_t) = x;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &x
if let Either::One(_t) = e { } if let Either::One(_t) = e { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &e
while let Either::One(_t) = e { } while let Either::One(_t) = e { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &e
match e { match e {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &e
Either::One(_t) Either::One(_t)
| Either::Two(_t) => (), | Either::Two(_t) => (),
} }
match e { match e {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &e
Either::One(_t) => (), Either::One(_t) => (),
Either::Two(ref _t) => (), Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -56,26 +51,21 @@ fn move_into_fn() {
let X(mut _t) = x; let X(mut _t) = x;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &x
if let Either::One(mut _t) = em { } if let Either::One(mut _t) = em { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
while let Either::One(mut _t) = em { } while let Either::One(mut _t) = em { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
match em { match em {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
Either::One(mut _t) Either::One(mut _t)
| Either::Two(mut _t) => (), | Either::Two(mut _t) => (),
} }
match em { match em {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
Either::One(mut _t) => (), Either::One(mut _t) => (),
Either::Two(ref _t) => (), Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -95,26 +85,21 @@ fn move_into_fnmut() {
let X(_t) = x; let X(_t) = x;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &x
if let Either::One(_t) = e { } if let Either::One(_t) = e { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &e
while let Either::One(_t) = e { } while let Either::One(_t) = e { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &e
match e { match e {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &e
Either::One(_t) Either::One(_t)
| Either::Two(_t) => (), | Either::Two(_t) => (),
} }
match e { match e {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &e
Either::One(_t) => (), Either::One(_t) => (),
Either::Two(ref _t) => (), Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -123,26 +108,21 @@ fn move_into_fnmut() {
let X(mut _t) = x; let X(mut _t) = x;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &x
if let Either::One(mut _t) = em { } if let Either::One(mut _t) = em { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
while let Either::One(mut _t) = em { } while let Either::One(mut _t) = em { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
match em { match em {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
Either::One(mut _t) Either::One(mut _t)
| Either::Two(mut _t) => (), | Either::Two(mut _t) => (),
} }
match em { match em {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
Either::One(mut _t) => (), Either::One(mut _t) => (),
Either::Two(ref _t) => (), Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -150,7 +130,6 @@ fn move_into_fnmut() {
match em { match em {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &em
Either::One(mut _t) => (), Either::One(mut _t) => (),
Either::Two(ref mut _t) => (), Either::Two(ref mut _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too

View file

@ -7,13 +7,18 @@ LL | let x = X(Y);
LL | consume_fn(|| { LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
LL | let X(_t) = x; LL | let X(_t) = x;
| -- ^ help: consider borrowing here: `&x` | -- ^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `Y`, which does not implement the `Copy` trait | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let X(_t) = &x;
| +
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:32:34 --> $DIR/move-into-closure.rs:31:34
| |
LL | let e = Either::One(X(Y)); LL | let e = Either::One(X(Y));
| - captured outer variable | - captured outer variable
@ -22,13 +27,18 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | if let Either::One(_t) = e { } LL | if let Either::One(_t) = e { }
| -- ^ help: consider borrowing here: `&e` | -- ^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | if let Either::One(_t) = &e { }
| +
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:36:37 --> $DIR/move-into-closure.rs:34:37
| |
LL | let e = Either::One(X(Y)); LL | let e = Either::One(X(Y));
| - captured outer variable | - captured outer variable
@ -37,13 +47,18 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | while let Either::One(_t) = e { } LL | while let Either::One(_t) = e { }
| -- ^ help: consider borrowing here: `&e` | -- ^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | while let Either::One(_t) = &e { }
| +
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:40:15 --> $DIR/move-into-closure.rs:37:15
| |
LL | let e = Either::One(X(Y)); LL | let e = Either::One(X(Y));
| - captured outer variable | - captured outer variable
@ -52,16 +67,21 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | match e { LL | match e {
| ^ help: consider borrowing here: `&e` | ^
... ...
LL | Either::One(_t) LL | Either::One(_t)
| -- | --
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &e {
| +
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:47:15 --> $DIR/move-into-closure.rs:43:15
| |
LL | let e = Either::One(X(Y)); LL | let e = Either::One(X(Y));
| - captured outer variable | - captured outer variable
@ -70,16 +90,21 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | match e { LL | match e {
| ^ help: consider borrowing here: `&e` | ^
... ...
LL | Either::One(_t) => (), LL | Either::One(_t) => (),
| -- | --
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &e {
| +
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:56:25 --> $DIR/move-into-closure.rs:51:25
| |
LL | let x = X(Y); LL | let x = X(Y);
| - captured outer variable | - captured outer variable
@ -88,13 +113,18 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | let X(mut _t) = x; LL | let X(mut _t) = x;
| ------ ^ help: consider borrowing here: `&x` | ------ ^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `Y`, which does not implement the `Copy` trait | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let X(mut _t) = &x;
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:60:38 --> $DIR/move-into-closure.rs:54:38
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -103,13 +133,18 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | if let Either::One(mut _t) = em { } LL | if let Either::One(mut _t) = em { }
| ------ ^^ help: consider borrowing here: `&em` | ------ ^^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | if let Either::One(mut _t) = &em { }
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:64:41 --> $DIR/move-into-closure.rs:57:41
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -118,13 +153,18 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | while let Either::One(mut _t) = em { } LL | while let Either::One(mut _t) = em { }
| ------ ^^ help: consider borrowing here: `&em` | ------ ^^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | while let Either::One(mut _t) = &em { }
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:68:15 --> $DIR/move-into-closure.rs:60:15
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -133,16 +173,21 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | match em { LL | match em {
| ^^ help: consider borrowing here: `&em` | ^^
... ...
LL | Either::One(mut _t) LL | Either::One(mut _t)
| ------ | ------
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &em {
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:75:15 --> $DIR/move-into-closure.rs:66:15
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -151,16 +196,21 @@ LL | consume_fn(|| {
| -- captured by this `Fn` closure | -- captured by this `Fn` closure
... ...
LL | match em { LL | match em {
| ^^ help: consider borrowing here: `&em` | ^^
... ...
LL | Either::One(mut _t) => (), LL | Either::One(mut _t) => (),
| ------ | ------
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &em {
| +
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:95:21 --> $DIR/move-into-closure.rs:85:21
| |
LL | let x = X(Y); LL | let x = X(Y);
| - captured outer variable | - captured outer variable
@ -168,13 +218,18 @@ LL | let x = X(Y);
LL | consume_fnmut(|| { LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
LL | let X(_t) = x; LL | let X(_t) = x;
| -- ^ help: consider borrowing here: `&x` | -- ^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `Y`, which does not implement the `Copy` trait | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let X(_t) = &x;
| +
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:99:34 --> $DIR/move-into-closure.rs:88:34
| |
LL | let e = Either::One(X(Y)); LL | let e = Either::One(X(Y));
| - captured outer variable | - captured outer variable
@ -183,13 +238,18 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | if let Either::One(_t) = e { } LL | if let Either::One(_t) = e { }
| -- ^ help: consider borrowing here: `&e` | -- ^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | if let Either::One(_t) = &e { }
| +
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:103:37 --> $DIR/move-into-closure.rs:91:37
| |
LL | let e = Either::One(X(Y)); LL | let e = Either::One(X(Y));
| - captured outer variable | - captured outer variable
@ -198,13 +258,18 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | while let Either::One(_t) = e { } LL | while let Either::One(_t) = e { }
| -- ^ help: consider borrowing here: `&e` | -- ^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | while let Either::One(_t) = &e { }
| +
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:107:15 --> $DIR/move-into-closure.rs:94:15
| |
LL | let e = Either::One(X(Y)); LL | let e = Either::One(X(Y));
| - captured outer variable | - captured outer variable
@ -213,16 +278,21 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | match e { LL | match e {
| ^ help: consider borrowing here: `&e` | ^
... ...
LL | Either::One(_t) LL | Either::One(_t)
| -- | --
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &e {
| +
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:114:15 --> $DIR/move-into-closure.rs:100:15
| |
LL | let e = Either::One(X(Y)); LL | let e = Either::One(X(Y));
| - captured outer variable | - captured outer variable
@ -231,16 +301,21 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | match e { LL | match e {
| ^ help: consider borrowing here: `&e` | ^
... ...
LL | Either::One(_t) => (), LL | Either::One(_t) => (),
| -- | --
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &e {
| +
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:123:25 --> $DIR/move-into-closure.rs:108:25
| |
LL | let x = X(Y); LL | let x = X(Y);
| - captured outer variable | - captured outer variable
@ -249,13 +324,18 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | let X(mut _t) = x; LL | let X(mut _t) = x;
| ------ ^ help: consider borrowing here: `&x` | ------ ^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `Y`, which does not implement the `Copy` trait | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | let X(mut _t) = &x;
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:127:38 --> $DIR/move-into-closure.rs:111:38
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -264,13 +344,18 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | if let Either::One(mut _t) = em { } LL | if let Either::One(mut _t) = em { }
| ------ ^^ help: consider borrowing here: `&em` | ------ ^^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | if let Either::One(mut _t) = &em { }
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:131:41 --> $DIR/move-into-closure.rs:114:41
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -279,13 +364,18 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | while let Either::One(mut _t) = em { } LL | while let Either::One(mut _t) = em { }
| ------ ^^ help: consider borrowing here: `&em` | ------ ^^
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | while let Either::One(mut _t) = &em { }
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:135:15 --> $DIR/move-into-closure.rs:117:15
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -294,16 +384,21 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | match em { LL | match em {
| ^^ help: consider borrowing here: `&em` | ^^
... ...
LL | Either::One(mut _t) LL | Either::One(mut _t)
| ------ | ------
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &em {
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:142:15 --> $DIR/move-into-closure.rs:123:15
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -312,16 +407,21 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | match em { LL | match em {
| ^^ help: consider borrowing here: `&em` | ^^
... ...
LL | Either::One(mut _t) => (), LL | Either::One(mut _t) => (),
| ------ | ------
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &em {
| +
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:150:15 --> $DIR/move-into-closure.rs:130:15
| |
LL | let mut em = Either::One(X(Y)); LL | let mut em = Either::One(X(Y));
| ------ captured outer variable | ------ captured outer variable
@ -330,13 +430,18 @@ LL | consume_fnmut(|| {
| -- captured by this `FnMut` closure | -- captured by this `FnMut` closure
... ...
LL | match em { LL | match em {
| ^^ help: consider borrowing here: `&em` | ^^
... ...
LL | Either::One(mut _t) => (), LL | Either::One(mut _t) => (),
| ------ | ------
| | | |
| data moved here | data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
|
help: consider borrowing here
|
LL | match &em {
| +
error: aborting due to 21 previous errors error: aborting due to 21 previous errors

View file

@ -38,26 +38,21 @@ pub fn main() {
let X(_t) = *s; let X(_t) = *s;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION s
if let Either::One(_t) = *r { } if let Either::One(_t) = *r { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION r
while let Either::One(_t) = *r { } while let Either::One(_t) = *r { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION r
match *r { match *r {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION r
Either::One(_t) Either::One(_t)
| Either::Two(_t) => (), | Either::Two(_t) => (),
} }
match *r { match *r {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION r
Either::One(_t) => (), Either::One(_t) => (),
Either::Two(ref _t) => (), Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -66,26 +61,21 @@ pub fn main() {
let X(_t) = *sm; let X(_t) = *sm;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION sm
if let Either::One(_t) = *rm { } if let Either::One(_t) = *rm { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION rm
while let Either::One(_t) = *rm { } while let Either::One(_t) = *rm { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION rm
match *rm { match *rm {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION rm
Either::One(_t) Either::One(_t)
| Either::Two(_t) => (), | Either::Two(_t) => (),
} }
match *rm { match *rm {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION rm
Either::One(_t) => (), Either::One(_t) => (),
Either::Two(ref _t) => (), Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -93,7 +83,6 @@ pub fn main() {
match *rm { match *rm {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION rm
Either::One(_t) => (), Either::One(_t) => (),
Either::Two(ref mut _t) => (), Either::Two(ref mut _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -102,26 +91,21 @@ pub fn main() {
let X(_t) = vs[0]; let X(_t) = vs[0];
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vs[0]
if let Either::One(_t) = vr[0] { } if let Either::One(_t) = vr[0] { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vr[0]
while let Either::One(_t) = vr[0] { } while let Either::One(_t) = vr[0] { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vr[0]
match vr[0] { match vr[0] {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vr[0]
Either::One(_t) Either::One(_t)
| Either::Two(_t) => (), | Either::Two(_t) => (),
} }
match vr[0] { match vr[0] {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vr[0]
Either::One(_t) => (), Either::One(_t) => (),
Either::Two(ref _t) => (), Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -130,26 +114,21 @@ pub fn main() {
let X(_t) = vsm[0]; let X(_t) = vsm[0];
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vsm[0]
if let Either::One(_t) = vrm[0] { } if let Either::One(_t) = vrm[0] { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vrm[0]
while let Either::One(_t) = vrm[0] { } while let Either::One(_t) = vrm[0] { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vrm[0]
match vrm[0] { match vrm[0] {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vrm[0]
Either::One(_t) Either::One(_t)
| Either::Two(_t) => (), | Either::Two(_t) => (),
} }
match vrm[0] { match vrm[0] {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vrm[0]
Either::One(_t) => (), Either::One(_t) => (),
Either::Two(ref _t) => (), Either::Two(ref _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -157,7 +136,6 @@ pub fn main() {
match vrm[0] { match vrm[0] {
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider borrowing here //~| HELP consider borrowing here
//~| SUGGESTION &vrm[0]
Either::One(_t) => (), Either::One(_t) => (),
Either::Two(ref mut _t) => (), Either::Two(ref mut _t) => (),
// FIXME: should suggest removing `ref` too // FIXME: should suggest removing `ref` too
@ -167,89 +145,73 @@ pub fn main() {
let &X(_t) = s; let &X(_t) = s;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing
//~| SUGGESTION X(_t)
if let &Either::One(_t) = r { } if let &Either::One(_t) = r { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing
//~| SUGGESTION Either::One(_t)
while let &Either::One(_t) = r { } while let &Either::One(_t) = r { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing
//~| SUGGESTION Either::One(_t)
match r { match r {
//~^ ERROR cannot move //~^ ERROR cannot move
&Either::One(_t) &Either::One(_t)
//~^ HELP consider removing the `&` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
| &Either::Two(_t) => (), | &Either::Two(_t) => (),
// FIXME: would really like a suggestion here too // FIXME: would really like a suggestion here too
} }
match r { match r {
//~^ ERROR cannot move //~^ ERROR cannot move
&Either::One(_t) => (), &Either::One(_t) => (),
//~^ HELP consider removing the `&` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
&Either::Two(ref _t) => (), &Either::Two(ref _t) => (),
} }
match r { match r {
//~^ ERROR cannot move //~^ ERROR cannot move
&Either::One(_t) => (), &Either::One(_t) => (),
//~^ HELP consider removing the `&` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
Either::Two(_t) => (), Either::Two(_t) => (),
} }
fn f1(&X(_t): &X) { } fn f1(&X(_t): &X) { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing
//~| SUGGESTION X(_t)
let &mut X(_t) = sm; let &mut X(_t) = sm;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing
//~| SUGGESTION X(_t)
if let &mut Either::One(_t) = rm { } if let &mut Either::One(_t) = rm { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing
//~| SUGGESTION Either::One(_t)
while let &mut Either::One(_t) = rm { } while let &mut Either::One(_t) = rm { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing
//~| SUGGESTION Either::One(_t)
match rm { match rm {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut Either::One(_t) => (), &mut Either::One(_t) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
&mut Either::Two(_t) => (), &mut Either::Two(_t) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::Two(_t)
} }
match rm { match rm {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut Either::One(_t) => (), &mut Either::One(_t) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
&mut Either::Two(ref _t) => (), &mut Either::Two(ref _t) => (),
} }
match rm { match rm {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut Either::One(_t) => (), &mut Either::One(_t) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
&mut Either::Two(ref mut _t) => (), &mut Either::Two(ref mut _t) => (),
} }
match rm { match rm {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut Either::One(_t) => (), &mut Either::One(_t) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
Either::Two(_t) => (), Either::Two(_t) => (),
} }
fn f2(&mut X(_t): &mut X) { } fn f2(&mut X(_t): &mut X) { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing
//~| SUGGESTION X(_t)
// move from tuple of &Either/&X // move from tuple of &Either/&X
@ -287,78 +249,77 @@ pub fn main() {
let &X(_t) = &x; let &X(_t) = &x;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing
//~| SUGGESTION X(_t)
if let &Either::One(_t) = &e { } if let &Either::One(_t) = &e { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing
//~| SUGGESTION Either::One(_t)
while let &Either::One(_t) = &e { } while let &Either::One(_t) = &e { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&` //~| HELP consider removing
//~| SUGGESTION Either::One(_t)
match &e { match &e {
//~^ ERROR cannot move //~^ ERROR cannot move
&Either::One(_t) &Either::One(_t)
//~^ HELP consider removing the `&` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
| &Either::Two(_t) => (), | &Either::Two(_t) => (),
// FIXME: would really like a suggestion here too // FIXME: would really like a suggestion here too
} }
match &e { match &e {
//~^ ERROR cannot move //~^ ERROR cannot move
&Either::One(_t) => (), &Either::One(_t) => (),
//~^ HELP consider removing the `&` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
&Either::Two(ref _t) => (), &Either::Two(ref _t) => (),
} }
match &e { match &e {
//~^ ERROR cannot move //~^ ERROR cannot move
&Either::One(_t) => (), &Either::One(_t) => (),
//~^ HELP consider removing the `&` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
Either::Two(_t) => (), Either::Two(_t) => (),
} }
let &mut X(_t) = &mut xm; let &mut X(_t) = &mut xm;
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing
//~| SUGGESTION X(_t)
if let &mut Either::One(_t) = &mut em { } if let &mut Either::One(_t) = &mut em { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing
//~| SUGGESTION Either::One(_t)
while let &mut Either::One(_t) = &mut em { } while let &mut Either::One(_t) = &mut em { }
//~^ ERROR cannot move //~^ ERROR cannot move
//~| HELP consider removing the `&mut` //~| HELP consider removing
//~| SUGGESTION Either::One(_t)
match &mut em { match &mut em {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut Either::One(_t) &mut Either::One(_t)
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
| &mut Either::Two(_t) => (), | &mut Either::Two(_t) => (),
// FIXME: would really like a suggestion here too // FIXME: would really like a suggestion here too
} }
match &mut em { match &mut em {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut Either::One(_t) => (), &mut Either::One(_t) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
&mut Either::Two(ref _t) => (), &mut Either::Two(ref _t) => (),
} }
match &mut em { match &mut em {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut Either::One(_t) => (), &mut Either::One(_t) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
&mut Either::Two(ref mut _t) => (), &mut Either::Two(ref mut _t) => (),
} }
match &mut em { match &mut em {
//~^ ERROR cannot move //~^ ERROR cannot move
&mut Either::One(_t) => (), &mut Either::One(_t) => (),
//~^ HELP consider removing the `&mut` //~^ HELP consider removing
//~| SUGGESTION Either::One(_t)
Either::Two(_t) => (), Either::Two(_t) => (),
} }
} }
struct Testing {
a: Option<String>
}
fn testing(a: &Testing) {
let Some(_s) = a.a else {
//~^ ERROR cannot move
//~| HELP consider borrowing
return;
};
}

File diff suppressed because it is too large Load diff

View file

@ -14,10 +14,12 @@ error[E0507]: cannot move out of dereference of `ManuallyDrop<((MockVec<u8>, Moc
--> $DIR/union-borrow-move-parent-sibling.rs:62:13 --> $DIR/union-borrow-move-parent-sibling.rs:62:13
| |
LL | let a = u.x.0; LL | let a = u.x.0;
| ^^^^^ | ^^^^^ move occurs because value has type `(MockVec<u8>, MockVec<u8>)`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `(MockVec<u8>, MockVec<u8>)`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&u.x.0` |
LL | let a = &u.x.0;
| +
error[E0382]: use of moved value: `u` error[E0382]: use of moved value: `u`
--> $DIR/union-borrow-move-parent-sibling.rs:64:13 --> $DIR/union-borrow-move-parent-sibling.rs:64:13
@ -46,10 +48,12 @@ error[E0507]: cannot move out of dereference of `ManuallyDrop<((MockVec<u8>, Moc
--> $DIR/union-borrow-move-parent-sibling.rs:76:13 --> $DIR/union-borrow-move-parent-sibling.rs:76:13
| |
LL | let a = (u.x.0).0; LL | let a = (u.x.0).0;
| ^^^^^^^^^ | ^^^^^^^^^ move occurs because value has type `MockVec<u8>`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `MockVec<u8>`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&(u.x.0).0` |
LL | let a = &(u.x.0).0;
| +
error[E0382]: use of moved value: `u` error[E0382]: use of moved value: `u`
--> $DIR/union-borrow-move-parent-sibling.rs:78:13 --> $DIR/union-borrow-move-parent-sibling.rs:78:13

View file

@ -14,10 +14,12 @@ error[E0507]: cannot move out of dereference of `ManuallyDrop<((MockVec<u8>, Moc
--> $DIR/union-borrow-move-parent-sibling.rs:62:13 --> $DIR/union-borrow-move-parent-sibling.rs:62:13
| |
LL | let a = u.x.0; LL | let a = u.x.0;
| ^^^^^ | ^^^^^ move occurs because value has type `(MockVec<u8>, MockVec<u8>)`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `(MockVec<u8>, MockVec<u8>)`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&u.x.0` |
LL | let a = &u.x.0;
| +
error[E0382]: use of moved value: `u` error[E0382]: use of moved value: `u`
--> $DIR/union-borrow-move-parent-sibling.rs:64:13 --> $DIR/union-borrow-move-parent-sibling.rs:64:13
@ -46,10 +48,12 @@ error[E0507]: cannot move out of dereference of `ManuallyDrop<((MockVec<u8>, Moc
--> $DIR/union-borrow-move-parent-sibling.rs:76:13 --> $DIR/union-borrow-move-parent-sibling.rs:76:13
| |
LL | let a = (u.x.0).0; LL | let a = (u.x.0).0;
| ^^^^^^^^^ | ^^^^^^^^^ move occurs because value has type `MockVec<u8>`, which does not implement the `Copy` trait
| | |
| move occurs because value has type `MockVec<u8>`, which does not implement the `Copy` trait help: consider borrowing here
| help: consider borrowing here: `&(u.x.0).0` |
LL | let a = &(u.x.0).0;
| +
error[E0382]: use of moved value: `u` error[E0382]: use of moved value: `u`
--> $DIR/union-borrow-move-parent-sibling.rs:78:13 --> $DIR/union-borrow-move-parent-sibling.rs:78:13