2019-12-14 21:09:47 -06:00
|
|
|
// This test is taken directly from #16053.
|
|
|
|
// It checks that you cannot use an AND-pattern (`binding @ pat`)
|
|
|
|
// where one side is by-ref and the other is by-move.
|
|
|
|
|
2019-11-11 04:39:52 -06:00
|
|
|
#![feature(bindings_after_at)]
|
2020-01-18 19:47:01 -06:00
|
|
|
#![feature(move_ref_pattern)]
|
2019-11-11 04:39:52 -06:00
|
|
|
|
2020-01-18 19:47:01 -06:00
|
|
|
struct X {
|
|
|
|
x: (),
|
|
|
|
}
|
2019-11-11 04:39:52 -06:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Some(X { x: () });
|
|
|
|
match x {
|
2020-01-18 19:47:01 -06:00
|
|
|
Some(ref _y @ _z) => {} //~ ERROR cannot move out of `_y` because it is borrowed
|
|
|
|
None => panic!(),
|
2019-11-11 04:39:52 -06:00
|
|
|
}
|
2019-12-14 21:09:47 -06:00
|
|
|
|
|
|
|
let x = Some(X { x: () });
|
|
|
|
match x {
|
2020-01-18 19:47:01 -06:00
|
|
|
Some(_z @ ref _y) => {}
|
2019-12-14 21:09:47 -06:00
|
|
|
//~^ ERROR borrow of moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
//~| ERROR borrow of moved value
|
|
|
|
None => panic!(),
|
2019-12-14 21:09:47 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
let mut x = Some(X { x: () });
|
|
|
|
match x {
|
2020-01-18 19:47:01 -06:00
|
|
|
Some(ref mut _y @ _z) => {} //~ ERROR cannot move out of `_y` because it is borrowed
|
|
|
|
None => panic!(),
|
2019-12-14 21:09:47 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
let mut x = Some(X { x: () });
|
|
|
|
match x {
|
2020-01-18 19:47:01 -06:00
|
|
|
Some(_z @ ref mut _y) => {}
|
2019-12-14 21:09:47 -06:00
|
|
|
//~^ ERROR borrow of moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
//~| ERROR borrow of moved value
|
|
|
|
None => panic!(),
|
2019-12-14 21:09:47 -06:00
|
|
|
}
|
2019-11-11 04:39:52 -06:00
|
|
|
}
|