1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
// Tests for #88015 when using if let chains in match guards
//@run-pass
#![feature(if_let_guard)]
#![feature(let_chains)]
#![allow(irrefutable_let_patterns)]
fn lhs_let(opt: Option<bool>) {
match opt {
None | Some(false) | Some(true) if let x = 42 && true => assert_eq!(x, 42),
_ => panic!()
}
}
fn rhs_let(opt: Option<bool>) {
match opt {
None | Some(false) | Some(true) if true && let x = 41 => assert_eq!(x, 41),
_ => panic!()
}
}
fn main() {
lhs_let(None);
lhs_let(Some(false));
lhs_let(Some(true));
rhs_let(None);
rhs_let(Some(false));
rhs_let(Some(true));
}
|