Skip to content
Permalink
Browse files

Tweak move error due to non-Copy

  • Loading branch information
estebank committed Nov 25, 2019
1 parent 9a59541 commit 9c97d73a2dad4828e64e152c1ce9ced94022f4f6
@@ -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

0 comments on commit 9c97d73

Please sign in to comment.
You can’t perform that action at this time.