summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs
blob: a942d1f4cafbfaccc17095f143907126aa0e0bb0 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#![feature(let_chains)]

fn main() {
    let _opt = Some(1i32);

    #[cfg(FALSE)]
    {
        let _ = &&let Some(x) = Some(42);
        //~^ ERROR expected expression, found `let` statement
    }
    #[cfg(FALSE)]
    {
        if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 {
        //~^ ERROR expected expression, found `let` statement
        //~| ERROR expected expression, found `let` statement
            true
        }
    }

    #[cfg(FALSE)]
    {
        if let Some(elem) = _opt && {
            [1, 2, 3][let _ = ()];
            //~^ ERROR expected expression, found `let` statement
            true
        } {
        }
    }

    #[cfg(FALSE)]
    {
        if let Some(elem) = _opt && [1, 2, 3][let _ = ()] = 1 {
        //~^ ERROR expected expression, found `let` statement
            true
        }
    }
    #[cfg(FALSE)]
    {
        if let a = 1 && {
            let x = let y = 1;
            //~^ ERROR expected expression, found `let` statement
        } {
        }
    }
}