Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,9 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
}
} else if j == 0 {
err.span_label(binding_span, "data moved here");
} else if j == 5 && binds_to.len() > 6 && !self.infcx.tcx.sess.opts.verbose {
err.note(format!("...and {} other places", binds_to.len() - 5));
break;
} else {
err.span_label(binding_span, "...and here");
}
Expand Down
28 changes: 28 additions & 0 deletions tests/ui/borrowck/borrowck-move-error-many-places.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![allow(unused)]
enum Foo {
Foo1(Box<u32>, Box<u32>),
Foo2(Box<u32>),
Foo3(Box<u32>),
Foo4(Box<u32>),
Foo5(Box<u32>),
Foo6(Box<u32>),
Foo7(Box<u32>),
Foo8(Box<u32>),
}

fn blah() {
let f = &Foo::Foo1(Box::new(1), Box::new(2));
match *f { //~ ERROR cannot move out of
Foo::Foo1(num1,
num2) => (),
Foo::Foo2(num) => (),
Foo::Foo3(num) => (),
Foo::Foo4(num) => (),
Foo::Foo5(num) => (),
Foo::Foo6(num) => (),
Foo::Foo7(num) => (),
Foo::Foo8(num) => (),
}
}

fn main() {}
27 changes: 27 additions & 0 deletions tests/ui/borrowck/borrowck-move-error-many-places.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0507]: cannot move out of `f` as enum variant `Foo1` which is behind a shared reference
--> $DIR/borrowck-move-error-many-places.rs:15:11
|
LL | match *f {
| ^^
LL | Foo::Foo1(num1,
| ---- data moved here
LL | num2) => (),
| ---- ...and here
LL | Foo::Foo2(num) => (),
| --- ...and here
LL | Foo::Foo3(num) => (),
| --- ...and here
LL | Foo::Foo4(num) => (),
| --- ...and here
|
= note: ...and 4 other places
= note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the dereference here
|
LL - match *f {
LL + match f {
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0507`.
Loading