rust/tests/ui/moves/move-out-of-slice-2.rs

37 lines
888 B
Rust
Raw Normal View History

#![feature(unsized_locals)]
2020-05-23 07:35:22 -05:00
//~^ WARN the feature `unsized_locals` is incomplete
#![allow(unused)]
2019-12-15 10:14:24 -06:00
struct A;
#[derive(Clone, Copy)]
struct C;
fn main() {
let a: Box<[A]> = Box::new([A]);
match *a {
//~^ ERROR cannot move out of type `[A]`, a non-copy slice
[a @ ..] => {}
2019-12-15 10:14:24 -06:00
_ => {}
}
let b: Box<[A]> = Box::new([A, A, A]);
match *b {
//~^ ERROR cannot move out of type `[A]`, a non-copy slice
[_, _, b @ .., _] => {}
2019-12-15 10:14:24 -06:00
_ => {}
}
// `[C]` isn't `Copy`, even if `C` is.
let c: Box<[C]> = Box::new([C]);
match *c {
//~^ ERROR cannot move out of type `[C]`, a non-copy slice
[c @ ..] => {}
2019-12-15 10:14:24 -06:00
_ => {}
}
let d: Box<[C]> = Box::new([C, C, C]);
match *d {
//~^ ERROR cannot move out of type `[C]`, a non-copy slice
[_, _, d @ .., _] => {}
2019-12-15 10:14:24 -06:00
_ => {}
}
}