parent
3d9f57a292
commit
c1ed862bc4
4 changed files with 18 additions and 19 deletions
|
@ -153,20 +153,19 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
Categorization::Interior(ref b, mc::InteriorElement(ik)) => {
|
||||
match (&b.ty.sty, ik) {
|
||||
(&ty::TySlice(..), _) |
|
||||
(_, Kind::Index) => {
|
||||
let mut err = struct_span_err!(bccx, move_from.span, E0508,
|
||||
"cannot move out of type `{}`, \
|
||||
a non-copy array",
|
||||
b.ty);
|
||||
err.span_label(move_from.span, "cannot move out of here");
|
||||
err
|
||||
}
|
||||
(_, Kind::Pattern) => {
|
||||
let type_name = match (&b.ty.sty, ik) {
|
||||
(&ty::TyArray(_, _), Kind::Index) => "array",
|
||||
(&ty::TySlice(_), _) => "slice",
|
||||
_ => {
|
||||
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
let mut err = struct_span_err!(bccx, move_from.span, E0508,
|
||||
"cannot move out of type `{}`, \
|
||||
a non-copy {}",
|
||||
b.ty, type_name);
|
||||
err.span_label(move_from.span, "cannot move out of here");
|
||||
err
|
||||
}
|
||||
|
||||
Categorization::Downcast(ref b, _) |
|
||||
|
|
|
@ -15,12 +15,12 @@ fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) {
|
|||
(&[], &[]) => println!("both empty"),
|
||||
(&[], &[hd, ..]) | (&[hd, ..], &[])
|
||||
=> println!("one empty"),
|
||||
//~^^ ERROR: cannot move out of type `[T]`, a non-copy array
|
||||
//~^^^ ERROR: cannot move out of type `[T]`, a non-copy array
|
||||
//~^^ ERROR: cannot move out of type `[T]`, a non-copy slice
|
||||
//~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice
|
||||
(&[hd1, ..], &[hd2, ..])
|
||||
=> println!("both nonempty"),
|
||||
//~^^ ERROR: cannot move out of type `[T]`, a non-copy array
|
||||
//~^^^ ERROR: cannot move out of type `[T]`, a non-copy array
|
||||
//~^^ ERROR: cannot move out of type `[T]`, a non-copy slice
|
||||
//~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,5 +24,5 @@ fn main() {
|
|||
}
|
||||
|
||||
fn foo(a: [D; 4], i: usize) -> D {
|
||||
a[i] //~ ERROR cannot move out of type `[D; 4]`
|
||||
a[i] //~ ERROR cannot move out of type `[D; 4]`, a non-copy array
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ struct A;
|
|||
fn main() {
|
||||
let a: Box<[A]> = Box::new([A]);
|
||||
match a {
|
||||
box [a] => {}, //~ ERROR cannot move out of type `[A]`
|
||||
box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue