]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2497-if-let-chains/feature-gate.rs
Rollup merge of #105843 - compiler-errors:sugg-const, r=lcnr
[rust.git] / src / test / ui / rfc-2497-if-let-chains / feature-gate.rs
1 // gate-test-let_chains
2
3 // Here we test feature gating for ´let_chains`.
4 // See `disallowed-positions.rs` for the grammar
5 // defining the language for gated allowed positions.
6
7 #![allow(irrefutable_let_patterns)]
8
9 use std::ops::Range;
10
11 fn _if() {
12     if let 0 = 1 {} // Stable!
13
14     if true && let 0 = 1 {}
15     //~^ ERROR `let` expressions in this position are unstable [E0658]
16
17     if let 0 = 1 && true {}
18     //~^ ERROR `let` expressions in this position are unstable [E0658]
19
20     if let Range { start: _, end: _ } = (true..true) && false {}
21     //~^ ERROR `let` expressions in this position are unstable [E0658]
22
23     if let 1 = 1 && let true = { true } && false {
24     //~^ ERROR `let` expressions in this position are unstable [E0658]
25     //~| ERROR `let` expressions in this position are unstable [E0658]
26     }
27 }
28
29 fn _while() {
30     while let 0 = 1 {} // Stable!
31
32     while true && let 0 = 1 {}
33     //~^ ERROR `let` expressions in this position are unstable [E0658]
34
35     while let 0 = 1 && true {}
36     //~^ ERROR `let` expressions in this position are unstable [E0658]
37
38     while let Range { start: _, end: _ } = (true..true) && false {}
39     //~^ ERROR `let` expressions in this position are unstable [E0658]
40 }
41
42 fn _macros() {
43     macro_rules! noop_expr { ($e:expr) => {}; }
44
45     noop_expr!((let 0 = 1));
46     //~^ ERROR `let` expressions in this position are unstable [E0658]
47     //~| ERROR expected expression, found `let` statement
48
49     macro_rules! use_expr {
50         ($e:expr) => {
51             if $e {}
52             while $e {}
53         }
54     }
55     #[cfg(FALSE)] (let 0 = 1);
56     //~^ ERROR `let` expressions in this position are unstable [E0658]
57     //~| ERROR expected expression, found `let` statement
58     use_expr!(let 0 = 1);
59     //~^ ERROR no rules expected the token `let`
60 }
61
62 fn main() {}