]> git.proxmox.com Git - rustc.git/blob - src/test/ui/rfc-2294-if-let-guard/run-pass.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / rfc-2294-if-let-guard / run-pass.rs
1 // run-pass
2
3 #![feature(if_let_guard)]
4
5 enum Foo {
6 Bar,
7 Baz,
8 Qux(u8),
9 }
10
11 fn bar(x: bool) -> Foo {
12 if x { Foo::Baz } else { Foo::Bar }
13 }
14
15 fn baz(x: u8) -> Foo {
16 if x % 2 == 0 { Foo::Bar } else { Foo::Baz }
17 }
18
19 fn qux(x: u8) -> Foo {
20 Foo::Qux(x.rotate_left(1))
21 }
22
23 fn main() {
24 match Some((true, 3)) {
25 Some((x, _)) if let Foo::Bar = bar(x) => panic!(),
26 Some((_, x)) if let Foo::Baz = baz(x) => {},
27 _ => panic!(),
28 }
29 match Some(42) {
30 Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84),
31 _ => panic!(),
32 }
33 }