2019-11-11 04:39:52 -06:00
|
|
|
// check-pass
|
|
|
|
|
|
|
|
// Test `Copy` bindings in the rhs of `@` patterns.
|
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
struct C;
|
|
|
|
|
2019-12-14 17:50:44 -06:00
|
|
|
fn mk_c() -> C { C }
|
|
|
|
|
2019-11-11 04:39:52 -06:00
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
struct P<A, B>(A, B);
|
|
|
|
|
|
|
|
enum E<A, B> { L(A), R(B) }
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let a @ b @ c @ d = C;
|
2019-12-14 17:50:44 -06:00
|
|
|
let a @ (b, c) = (C, mk_c());
|
|
|
|
let a @ P(b, P(c, d)) = P(mk_c(), P(C, C));
|
2019-11-11 04:39:52 -06:00
|
|
|
let a @ [b, c] = [C, C];
|
2019-12-14 17:50:44 -06:00
|
|
|
let a @ [b, .., c] = [C, mk_c(), C];
|
2019-12-14 20:50:55 -06:00
|
|
|
let a @ [b, mid @ .., c] = [C, mk_c(), C];
|
2019-11-11 04:39:52 -06:00
|
|
|
let a @ &(b, c) = &(C, C);
|
2019-12-14 17:50:44 -06:00
|
|
|
let a @ &(b, &P(c, d)) = &(mk_c(), &P(C, C));
|
2019-11-11 04:39:52 -06:00
|
|
|
|
2019-12-14 20:50:55 -06:00
|
|
|
fn foo(a @ [b, mid @ .., c]: [C; 3]) {}
|
|
|
|
|
2019-11-11 04:39:52 -06:00
|
|
|
use self::E::*;
|
|
|
|
match L(C) {
|
|
|
|
L(a) | R(a) => {
|
|
|
|
let a: C = a;
|
|
|
|
drop(a);
|
|
|
|
drop(a);
|
|
|
|
}
|
|
|
|
}
|
2019-12-14 17:50:44 -06:00
|
|
|
match R(&L(&mk_c())) {
|
2019-11-11 04:39:52 -06:00
|
|
|
L(L(&a)) | L(R(&a)) | R(L(&a)) | R(R(&a)) => {
|
|
|
|
let a: C = a;
|
|
|
|
drop(a);
|
|
|
|
drop(a);
|
|
|
|
}
|
|
|
|
}
|
2019-12-14 21:12:35 -06:00
|
|
|
|
|
|
|
match Ok(mk_c()) {
|
|
|
|
Ok(ref a @ b) | Err(b @ ref a) => {
|
|
|
|
let _: &C = a;
|
|
|
|
let _: C = b;
|
|
|
|
}
|
|
|
|
}
|
2019-11-11 04:39:52 -06:00
|
|
|
}
|