Files
rust/src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.rs
Mazdak Farrokhzad d984f127f6 move_ref_patterns: introduce tests
bindings_after_at: harden tests
2020-02-02 14:13:07 +01:00

24 lines
712 B
Rust

fn main() {
#[derive(Clone)]
struct X {
x: (),
}
let mut tup = (X { x: () }, X { x: () });
match Some(tup.clone()) {
Some((y, ref z)) => {}
//~^ ERROR binding by-move and by-ref in the same pattern is unstable
None => panic!(),
}
let (ref a, b) = tup.clone();
//~^ ERROR binding by-move and by-ref in the same pattern is unstable
let (a, mut b) = &tup;
//~^ ERROR binding by-move and by-ref in the same pattern is unstable
//~| ERROR cannot move out of a shared reference
let (mut a, b) = &mut tup;
//~^ ERROR binding by-move and by-ref in the same pattern is unstable
//~| ERROR cannot move out of a mutable reference
}