about summary refs log tree commit diff
path: root/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs
blob: 59e33bb6af8e99cdcc282e22b2ec856df4fb9253 (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
// Ensure that temporaries in if-let guards live for the arm
// regression test for #118593

//@ check-pass

#![feature(if_let_guard)]

fn get_temp() -> Option<String> {
    None
}

fn let_guard(num: u8) {
    match num {
        1 | 2 if let Some(ref a) = get_temp() => {
            let _b = a;
        }
        _ => {}
    }
    match num {
        3 | 4 if let Some(ref mut c) = get_temp() => {
            let _d = c;
        }
        _ => {}
    }
}

fn main() {}