]> git.proxmox.com Git - rustc.git/blame - 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
CommitLineData
fc512014
XL
1// run-pass
2
3#![feature(if_let_guard)]
fc512014
XL
4
5enum Foo {
6 Bar,
7 Baz,
8 Qux(u8),
9}
10
11fn bar(x: bool) -> Foo {
12 if x { Foo::Baz } else { Foo::Bar }
13}
14
15fn baz(x: u8) -> Foo {
16 if x % 2 == 0 { Foo::Bar } else { Foo::Baz }
17}
18
19fn qux(x: u8) -> Foo {
20 Foo::Qux(x.rotate_left(1))
21}
22
23fn 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}