Tweak move error due to non-Copy
This commit is contained in:
parent
9a595417a2
commit
9c97d73a2d
10 changed files with 31 additions and 175 deletions
|
@ -555,7 +555,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
err: &mut DiagnosticBuilder<'a>,
|
||||
binds_to: &[Local],
|
||||
) {
|
||||
let mut noncopy_var_spans = Vec::new();
|
||||
for (j, local) in binds_to.into_iter().enumerate() {
|
||||
let bind_to = &self.body.local_decls[*local];
|
||||
let binding_span = bind_to.source_info.span;
|
||||
|
@ -573,16 +572,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
bind_to.ty,
|
||||
Some(binding_span)
|
||||
);
|
||||
} else {
|
||||
noncopy_var_spans.push(binding_span);
|
||||
}
|
||||
}
|
||||
|
||||
if binds_to.len() > 1 {
|
||||
err.span_note(
|
||||
noncopy_var_spans,
|
||||
"move occurs because these variables have types that \
|
||||
don't implement the `Copy` trait",
|
||||
err.note("move occurs because these variables have types that \
|
||||
don't implement the `Copy` trait",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,7 @@ LL | num2) => (),
|
|||
LL | Foo::Foo2(num) => (),
|
||||
| --- ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/borrowck-move-error-with-note.rs:12:19
|
||||
|
|
||||
LL | Foo::Foo1(num1,
|
||||
| ^^^^
|
||||
LL | num2) => (),
|
||||
| ^^^^
|
||||
LL | Foo::Foo2(num) => (),
|
||||
| ^^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
|
||||
--> $DIR/borrowck-move-error-with-note.rs:28:11
|
||||
|
@ -31,13 +23,7 @@ LL | f: _s,
|
|||
LL | g: _t
|
||||
| -- ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/borrowck-move-error-with-note.rs:31:16
|
||||
|
|
||||
LL | f: _s,
|
||||
| ^^
|
||||
LL | g: _t
|
||||
| ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of `a.a` which is behind a shared reference
|
||||
--> $DIR/borrowck-move-error-with-note.rs:46:11
|
||||
|
|
|
@ -9,13 +9,7 @@ LL | &[Foo { string: a },
|
|||
LL | Foo { string: b }] => {
|
||||
| - ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/borrowck-move-out-of-vec-tail.rs:21:33
|
||||
|
|
||||
LL | &[Foo { string: a },
|
||||
| ^
|
||||
LL | Foo { string: b }] => {
|
||||
| ^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
help: consider removing the `&`
|
||||
|
|
||||
LL | [Foo { string: a },
|
||||
|
|
|
@ -75,12 +75,12 @@ fn e() {
|
|||
match vec {
|
||||
//~^ ERROR cannot move out
|
||||
//~| NOTE cannot move out
|
||||
//~| NOTE move occurs because these variables have types
|
||||
&mut [_a, _b, _c] => {}
|
||||
//~^ NOTE data moved here
|
||||
//~| NOTE and here
|
||||
//~| NOTE and here
|
||||
//~| HELP consider removing the `&mut`
|
||||
//~| NOTE move occurs because these variables have types
|
||||
_ => {}
|
||||
}
|
||||
let a = vec[0]; //~ ERROR cannot move out
|
||||
|
|
|
@ -97,11 +97,7 @@ LL | &mut [_a, _b, _c] => {}
|
|||
| | 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
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:78:15
|
||||
|
|
||||
LL | &mut [_a, _b, _c] => {}
|
||||
| ^^ ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:86:13
|
||||
|
|
|
@ -10,14 +10,7 @@ LL | => println!("one empty"),
|
|||
LL | (&[hd1, ..], &[hd2, ..])
|
||||
| --- ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/issue-12567.rs:8:17
|
||||
|
|
||||
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
|
||||
| ^^
|
||||
LL | => println!("one empty"),
|
||||
LL | (&[hd1, ..], &[hd2, ..])
|
||||
| ^^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0508]: cannot move out of type `[T]`, a non-copy slice
|
||||
--> $DIR/issue-12567.rs:4:11
|
||||
|
@ -31,14 +24,7 @@ LL | => println!("one empty"),
|
|||
LL | (&[hd1, ..], &[hd2, ..])
|
||||
| --- ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/issue-12567.rs:8:17
|
||||
|
|
||||
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
|
||||
| ^^
|
||||
LL | => println!("one empty"),
|
||||
LL | (&[hd1, ..], &[hd2, ..])
|
||||
| ^^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -7,11 +7,7 @@ LL | let (a, b) = x[0];
|
|||
| | ...and here
|
||||
| data moved here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/issue-40402-2.rs:5:10
|
||||
|
|
||||
LL | let (a, b) = x[0];
|
||||
| ^ ^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -83,13 +83,7 @@ LL | B::U(d) => (),
|
|||
LL | B::V(s) => (),
|
||||
| - ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/move-errors.rs:76:14
|
||||
|
|
||||
LL | B::U(d) => (),
|
||||
| ^
|
||||
LL | B::V(s) => (),
|
||||
| ^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0509]: cannot move out of type `D`, which implements the `Drop` trait
|
||||
--> $DIR/move-errors.rs:83:11
|
||||
|
@ -138,11 +132,7 @@ LL | F(s, mut t) => (),
|
|||
| |
|
||||
| data moved here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/move-errors.rs:104:11
|
||||
|
|
||||
LL | F(s, mut t) => (),
|
||||
| ^ ^^^^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of `x.0` which is behind a shared reference
|
||||
--> $DIR/move-errors.rs:110:11
|
||||
|
|
|
@ -8,11 +8,7 @@ LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
|
|||
| | data moved here
|
||||
| help: consider removing the `&`: `(X(_t), X(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:39:13
|
||||
|
|
||||
LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a shared reference
|
||||
--> $DIR/duplicate-suggestions.rs:43:50
|
||||
|
@ -24,11 +20,7 @@ LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) {
|
|||
| | data moved here
|
||||
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:43:26
|
||||
|
|
||||
LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a shared reference
|
||||
--> $DIR/duplicate-suggestions.rs:47:53
|
||||
|
@ -40,11 +32,7 @@ LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone())
|
|||
| | data moved here
|
||||
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:47:29
|
||||
|
|
||||
LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a shared reference
|
||||
--> $DIR/duplicate-suggestions.rs:51:11
|
||||
|
@ -60,14 +48,7 @@ LL | &(Either::One(_t), Either::Two(_u)) => (),
|
|||
LL | &(Either::Two(_t), Either::One(_u)) => (),
|
||||
| -- ...and here -- ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:53:23
|
||||
|
|
||||
LL | &(Either::One(_t), Either::Two(_u)) => (),
|
||||
| ^^ ^^
|
||||
...
|
||||
LL | &(Either::Two(_t), Either::One(_u)) => (),
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
help: consider removing the `&`
|
||||
|
|
||||
LL | (Either::One(_t), Either::Two(_u)) => (),
|
||||
|
@ -90,11 +71,7 @@ LL | &(Either::One(_t), Either::Two(_u))
|
|||
| | data moved here
|
||||
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:63:23
|
||||
|
|
||||
LL | &(Either::One(_t), Either::Two(_u))
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a shared reference
|
||||
--> $DIR/duplicate-suggestions.rs:70:11
|
||||
|
@ -109,11 +86,7 @@ LL | &(Either::One(_t), Either::Two(_u)) => (),
|
|||
| | data moved here
|
||||
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:72:23
|
||||
|
|
||||
LL | &(Either::One(_t), Either::Two(_u)) => (),
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a shared reference
|
||||
--> $DIR/duplicate-suggestions.rs:78:11
|
||||
|
@ -128,11 +101,7 @@ LL | &(Either::One(_t), Either::Two(_u)) => (),
|
|||
| | data moved here
|
||||
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:80:23
|
||||
|
|
||||
LL | &(Either::One(_t), Either::Two(_u)) => (),
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a mutable reference
|
||||
--> $DIR/duplicate-suggestions.rs:91:31
|
||||
|
@ -144,11 +113,7 @@ LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
|
|||
| | data moved here
|
||||
| help: consider removing the `&mut`: `(X(_t), X(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:91:17
|
||||
|
|
||||
LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a mutable reference
|
||||
--> $DIR/duplicate-suggestions.rs:95:54
|
||||
|
@ -160,11 +125,7 @@ LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.c
|
|||
| | data moved here
|
||||
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:95:30
|
||||
|
|
||||
LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a mutable reference
|
||||
--> $DIR/duplicate-suggestions.rs:99:57
|
||||
|
@ -176,11 +137,7 @@ LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), e
|
|||
| | data moved here
|
||||
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:99:33
|
||||
|
|
||||
LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a mutable reference
|
||||
--> $DIR/duplicate-suggestions.rs:103:11
|
||||
|
@ -196,14 +153,7 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
|
|||
LL | &mut (Either::Two(_t), Either::One(_u)) => (),
|
||||
| -- ...and here -- ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:105:27
|
||||
|
|
||||
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
|
||||
| ^^ ^^
|
||||
...
|
||||
LL | &mut (Either::Two(_t), Either::One(_u)) => (),
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
help: consider removing the `&mut`
|
||||
|
|
||||
LL | (Either::One(_t), Either::Two(_u)) => (),
|
||||
|
@ -226,11 +176,7 @@ LL | &mut (Either::One(_t), Either::Two(_u))
|
|||
| | data moved here
|
||||
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:115:27
|
||||
|
|
||||
LL | &mut (Either::One(_t), Either::Two(_u))
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a mutable reference
|
||||
--> $DIR/duplicate-suggestions.rs:122:11
|
||||
|
@ -245,11 +191,7 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
|
|||
| | data moved here
|
||||
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:124:27
|
||||
|
|
||||
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a mutable reference
|
||||
--> $DIR/duplicate-suggestions.rs:130:11
|
||||
|
@ -264,11 +206,7 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
|
|||
| | data moved here
|
||||
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:132:27
|
||||
|
|
||||
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a mutable reference
|
||||
--> $DIR/duplicate-suggestions.rs:138:11
|
||||
|
@ -283,11 +221,7 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
|
|||
| | data moved here
|
||||
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:140:27
|
||||
|
|
||||
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a shared reference
|
||||
--> $DIR/duplicate-suggestions.rs:86:11
|
||||
|
@ -299,11 +233,7 @@ LL | fn f5(&(X(_t), X(_u)): &(X, X)) { }
|
|||
| | data moved here
|
||||
| help: consider removing the `&`: `(X(_t), X(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:86:15
|
||||
|
|
||||
LL | fn f5(&(X(_t), X(_u)): &(X, X)) { }
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a mutable reference
|
||||
--> $DIR/duplicate-suggestions.rs:146:11
|
||||
|
@ -315,11 +245,7 @@ LL | fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
|
|||
| | data moved here
|
||||
| help: consider removing the `&mut`: `(X(_t), X(_u))`
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/duplicate-suggestions.rs:146:19
|
||||
|
|
||||
LL | fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
|
||||
| ^^ ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
|
|
@ -337,14 +337,7 @@ LL | &mut Either::One(_t) => (),
|
|||
LL | &mut Either::Two(_t) => (),
|
||||
| -- ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/simple.rs:221:26
|
||||
|
|
||||
LL | &mut Either::One(_t) => (),
|
||||
| ^^
|
||||
...
|
||||
LL | &mut Either::Two(_t) => (),
|
||||
| ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
help: consider removing the `&mut`
|
||||
|
|
||||
LL | Either::One(_t) => (),
|
||||
|
@ -470,13 +463,7 @@ LL | (&mut Either::One(_t),) => (),
|
|||
LL | (&mut Either::Two(_t),) => (),
|
||||
| -- ...and here
|
||||
|
|
||||
note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
--> $DIR/simple.rs:280:27
|
||||
|
|
||||
LL | (&mut Either::One(_t),) => (),
|
||||
| ^^
|
||||
LL | (&mut Either::Two(_t),) => (),
|
||||
| ^^
|
||||
= note: move occurs because these variables have types that don't implement the `Copy` trait
|
||||
|
||||
error[E0507]: cannot move out of a shared reference
|
||||
--> $DIR/simple.rs:288:18
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue