]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-2294-if-let-guard/feature-gate.rs
Rollup merge of #106570 - Xaeroxe:div-duration-tests, r=JohnTitor
[rust.git] / tests / ui / rfc-2294-if-let-guard / feature-gate.rs
1 // gate-test-if_let_guard
2
3 use std::ops::Range;
4
5 fn _if_let_guard() {
6     match () {
7         () if let 0 = 1 => {}
8         //~^ ERROR `if let` guards are experimental
9
10         () if (let 0 = 1) => {}
11         //~^ ERROR `let` expressions in this position are unstable
12         //~| ERROR expected expression, found `let` statement
13
14         () if (((let 0 = 1))) => {}
15         //~^ ERROR `let` expressions in this position are unstable
16         //~| ERROR expected expression, found `let` statement
17
18         () if true && let 0 = 1 => {}
19         //~^ ERROR `if let` guards are experimental
20         //~| ERROR `let` expressions in this position are unstable
21
22         () if let 0 = 1 && true => {}
23         //~^ ERROR `if let` guards are experimental
24         //~| ERROR `let` expressions in this position are unstable
25
26         () if (let 0 = 1) && true => {}
27         //~^ ERROR `let` expressions in this position are unstable
28         //~| ERROR expected expression, found `let` statement
29
30         () if true && (let 0 = 1) => {}
31         //~^ ERROR `let` expressions in this position are unstable
32         //~| ERROR expected expression, found `let` statement
33
34         () if (let 0 = 1) && (let 0 = 1) => {}
35         //~^ ERROR `let` expressions in this position are unstable
36         //~| ERROR `let` expressions in this position are unstable
37         //~| ERROR expected expression, found `let` statement
38         //~| ERROR expected expression, found `let` statement
39
40         () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
41         //~^ ERROR `if let` guards are experimental
42         //~| ERROR `let` expressions in this position are unstable
43         //~| ERROR `let` expressions in this position are unstable
44         //~| ERROR `let` expressions in this position are unstable
45         //~| ERROR `let` expressions in this position are unstable
46         //~| ERROR `let` expressions in this position are unstable
47         //~| ERROR expected expression, found `let` statement
48         //~| ERROR expected expression, found `let` statement
49         //~| ERROR expected expression, found `let` statement
50
51         () if let Range { start: _, end: _ } = (true..true) && false => {}
52         //~^ ERROR `if let` guards are experimental
53         //~| ERROR `let` expressions in this position are unstable
54
55         _ => {}
56     }
57 }
58
59 fn _macros() {
60     macro_rules! use_expr {
61         ($e:expr) => {
62             match () {
63                 () if $e => {}
64                 _ => {}
65             }
66         }
67     }
68     use_expr!((let 0 = 1 && 0 == 0));
69     //~^ ERROR `let` expressions in this position are unstable
70     //~| ERROR expected expression, found `let` statement
71     use_expr!((let 0 = 1));
72     //~^ ERROR `let` expressions in this position are unstable
73     //~| ERROR expected expression, found `let` statement
74     match () {
75         #[cfg(FALSE)]
76         () if let 0 = 1 => {}
77         //~^ ERROR `if let` guards are experimental
78         _ => {}
79     }
80     use_expr!(let 0 = 1);
81     //~^ ERROR no rules expected the token `let`
82 }
83
84 fn main() {}