2022-12-21 09:29:35 -06:00
|
|
|
#![feature(if_let_guard)]
|
|
|
|
|
2018-09-07 10:52:49 -05:00
|
|
|
struct A { a: Box<i32> }
|
|
|
|
|
2022-12-21 09:29:35 -06:00
|
|
|
fn if_guard(n: i32) {
|
2018-09-07 10:52:49 -05:00
|
|
|
let x = A { a: Box::new(n) };
|
|
|
|
let _y = match x {
|
|
|
|
A { a: v } if { drop(v); true } => v,
|
2019-05-05 06:02:32 -05:00
|
|
|
//~^ ERROR cannot move out of `v` in pattern guard
|
2018-09-07 10:52:49 -05:00
|
|
|
_ => Box::new(0),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-21 09:29:35 -06:00
|
|
|
fn if_let_guard(n: i32) {
|
|
|
|
let x = A { a: Box::new(n) };
|
|
|
|
let _y = match x {
|
|
|
|
A { a: v } if let Some(()) = { drop(v); Some(()) } => v,
|
|
|
|
//~^ ERROR cannot move out of `v` in pattern guard
|
|
|
|
_ => Box::new(0),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-09-07 10:52:49 -05:00
|
|
|
fn main() {
|
2022-12-21 09:29:35 -06:00
|
|
|
if_guard(107);
|
|
|
|
if_let_guard(107);
|
2018-09-07 10:52:49 -05:00
|
|
|
}
|