summary refs log tree commit diff
path: root/src/test/ui/or-patterns/feature-gate-const-fn.rs
blob: 2ef5537db60ad84776675f15b930770ea429f155 (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
#![feature(or_patterns)]

const fn foo((Ok(a) | Err(a)): Result<i32, i32>) {
    //~^ ERROR or-pattern is not allowed in a `const fn`
    let x = Ok(3);
    let Ok(y) | Err(y) = x;
    //~^ ERROR or-pattern is not allowed in a `const fn`
}

const X: () = {
    let x = Ok(3);
    let Ok(y) | Err(y) = x;
    //~^ ERROR or-pattern is not allowed in a `const`
};

static Y: () = {
    let x = Ok(3);
    let Ok(y) | Err(y) = x;
    //~^ ERROR or-pattern is not allowed in a `static`
};

static mut Z: () = {
    let x = Ok(3);
    let Ok(y) | Err(y) = x;
    //~^ ERROR or-pattern is not allowed in a `static mut`
};

fn main() {
    let _: [(); {
        let x = Ok(3);
        let Ok(y) | Err(y) = x;
        //~^ ERROR or-pattern is not allowed in a `const`
        //~| ERROR constant contains unimplemented expression type
        //~| ERROR constant contains unimplemented expression type
        2
    }];
}