summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2294-if-let-guard/shadowing.rs
blob: dba292ef9e21c58f28104e524fbb3cc595d00795 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Check shadowing in if let guards works as expected.
// check-pass

#![feature(if_let_guard)]
#![feature(let_chains)]

fn main() {
    let x: Option<Option<i32>> = Some(Some(6));
    match x {
        Some(x) if let Some(x) = x => {
            let _: i32 = x;
        }
        _ => {}
    }

    let y: Option<Option<Option<i32>>> = Some(Some(Some(-24)));
    match y {
        Some(y) if let Some(y) = y && let Some(y) = y => {
            let _: i32 = y;
        }
        _ => {}
    }
}