summaryrefslogtreecommitdiffstats
path: root/tests/ui/issues/issue-29723.rs
blob: 399e9ba0df73053982325f68abd8e5e324012092 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// test for https://github.com/rust-lang/rust/issues/29723

#![feature(if_let_guard)]

fn main() {
    let s = String::new();
    let _s = match 0 {
        0 if { drop(s); false } => String::from("oops"),
        _ => {
            // This should trigger an error,
            // s could have been moved from.
            s
            //~^ ERROR use of moved value: `s`
        }
    };

    let s = String::new();
    let _s = match 0 {
        0 if let Some(()) = { drop(s); None } => String::from("oops"),
        _ => s //~ ERROR use of moved value: `s`
    };
}