about summary refs log tree commit diff
path: root/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs
blob: 47cc7a64bd1abd7a6cde78aead0ab0541457be8a (plain)
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
// Tests for #88015 when using if let chains in match guards

//@run-pass

#![feature(if_let_guard)]
#![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));
}