]> git.proxmox.com Git - rustc.git/blame - src/test/ui/or-patterns/feature-gate-const-fn.rs
New upstream version 1.45.0+dfsg1
[rustc.git] / src / test / ui / or-patterns / feature-gate-const-fn.rs
CommitLineData
dfeec247 1#![feature(or_patterns)]
dfeec247
XL
2
3const fn foo((Ok(a) | Err(a)): Result<i32, i32>) {
4 //~^ ERROR or-pattern is not allowed in a `const fn`
5 let x = Ok(3);
6 let Ok(y) | Err(y) = x;
7 //~^ ERROR or-pattern is not allowed in a `const fn`
8}
9
10const X: () = {
11 let x = Ok(3);
12 let Ok(y) | Err(y) = x;
13 //~^ ERROR or-pattern is not allowed in a `const`
14};
15
16static Y: () = {
17 let x = Ok(3);
18 let Ok(y) | Err(y) = x;
19 //~^ ERROR or-pattern is not allowed in a `static`
20};
21
22static mut Z: () = {
23 let x = Ok(3);
24 let Ok(y) | Err(y) = x;
25 //~^ ERROR or-pattern is not allowed in a `static mut`
26};
27
28fn main() {
29 let _: [(); {
30 let x = Ok(3);
31 let Ok(y) | Err(y) = x;
32 //~^ ERROR or-pattern is not allowed in a `const`
33 2
34 }];
35}