Skip to content

Commit cb6c0be

Browse files
committed
let_chains: Add feature gate tests.
1 parent 6b4e833 commit cb6c0be

File tree

2 files changed

+380
-0
lines changed

2 files changed

+380
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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 (let 0 = 1) {}
15+
//~^ ERROR `let` expressions in this position are experimental [E0658]
16+
//~| ERROR `let` expressions only supported in `if`
17+
18+
if (((let 0 = 1))) {}
19+
//~^ ERROR `let` expressions in this position are experimental [E0658]
20+
21+
if true && let 0 = 1 {}
22+
//~^ ERROR `let` expressions in this position are experimental [E0658]
23+
24+
if let 0 = 1 && true {}
25+
//~^ ERROR `let` expressions in this position are experimental [E0658]
26+
27+
if (let 0 = 1) && true {}
28+
//~^ ERROR `let` expressions in this position are experimental [E0658]
29+
30+
if true && (let 0 = 1) {}
31+
//~^ ERROR `let` expressions in this position are experimental [E0658]
32+
33+
if (let 0 = 1) && (let 0 = 1) {}
34+
//~^ ERROR `let` expressions in this position are experimental [E0658]
35+
//~| ERROR `let` expressions in this position are experimental [E0658]
36+
37+
if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
38+
//~^ ERROR `let` expressions in this position are experimental [E0658]
39+
//~| ERROR `let` expressions in this position are experimental [E0658]
40+
//~| ERROR `let` expressions in this position are experimental [E0658]
41+
//~| ERROR `let` expressions in this position are experimental [E0658]
42+
//~| ERROR `let` expressions in this position are experimental [E0658]
43+
44+
if let Range { start: _, end: _ } = (true..true) && false {}
45+
//~^ ERROR `let` expressions in this position are experimental [E0658]
46+
}
47+
48+
fn _while() {
49+
if let 0 = 1 {} // Stable!
50+
51+
while (let 0 = 1) {}
52+
//~^ ERROR `let` expressions in this position are experimental [E0658]
53+
54+
while (((let 0 = 1))) {}
55+
//~^ ERROR `let` expressions in this position are experimental [E0658]
56+
57+
while true && let 0 = 1 {}
58+
//~^ ERROR `let` expressions in this position are experimental [E0658]
59+
60+
while let 0 = 1 && true {}
61+
//~^ ERROR `let` expressions in this position are experimental [E0658]
62+
63+
while (let 0 = 1) && true {}
64+
//~^ ERROR `let` expressions in this position are experimental [E0658]
65+
66+
while true && (let 0 = 1) {}
67+
//~^ ERROR `let` expressions in this position are experimental [E0658]
68+
69+
while (let 0 = 1) && (let 0 = 1) {}
70+
//~^ ERROR `let` expressions in this position are experimental [E0658]
71+
//~| ERROR `let` expressions in this position are experimental [E0658]
72+
73+
while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
74+
//~^ ERROR `let` expressions in this position are experimental [E0658]
75+
//~| ERROR `let` expressions in this position are experimental [E0658]
76+
//~| ERROR `let` expressions in this position are experimental [E0658]
77+
//~| ERROR `let` expressions in this position are experimental [E0658]
78+
//~| ERROR `let` expressions in this position are experimental [E0658]
79+
80+
while let Range { start: _, end: _ } = (true..true) && false {}
81+
//~^ ERROR `let` expressions in this position are experimental [E0658]
82+
}
83+
84+
fn _macros() {
85+
macro_rules! noop_expr { ($e:expr) => {}; }
86+
noop_expr!((let 0 = 1));
87+
88+
macro_rules! use_expr {
89+
($e:expr) => {
90+
if $e {}
91+
while $e {}
92+
}
93+
}
94+
use_expr!(let 0 = 1 && 0 == 0);
95+
//~^ ERROR `let` expressions in this position are experimental [E0658]
96+
use_expr!((let 0 = 1));
97+
//~^ ERROR `let` expressions in this position are experimental [E0658]
98+
use_expr!(let 0 = 1);
99+
}
100+
101+
fn main() {}
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
error[E0658]: `let` expressions in this position are experimental
2+
--> $DIR/feature-gate.rs:14:9
3+
|
4+
LL | if (let 0 = 1) {}
5+
| ^^^^^^^^^
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
8+
= help: add #![feature(let_chains)] to the crate attributes to enable
9+
10+
error[E0658]: `let` expressions in this position are experimental
11+
--> $DIR/feature-gate.rs:18:11
12+
|
13+
LL | if (((let 0 = 1))) {}
14+
| ^^^^^^^^^
15+
|
16+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
17+
= help: add #![feature(let_chains)] to the crate attributes to enable
18+
19+
error[E0658]: `let` expressions in this position are experimental
20+
--> $DIR/feature-gate.rs:21:16
21+
|
22+
LL | if true && let 0 = 1 {}
23+
| ^^^^^^^^^
24+
|
25+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
26+
= help: add #![feature(let_chains)] to the crate attributes to enable
27+
28+
error[E0658]: `let` expressions in this position are experimental
29+
--> $DIR/feature-gate.rs:24:8
30+
|
31+
LL | if let 0 = 1 && true {}
32+
| ^^^^^^^^^
33+
|
34+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
35+
= help: add #![feature(let_chains)] to the crate attributes to enable
36+
37+
error[E0658]: `let` expressions in this position are experimental
38+
--> $DIR/feature-gate.rs:27:9
39+
|
40+
LL | if (let 0 = 1) && true {}
41+
| ^^^^^^^^^
42+
|
43+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
44+
= help: add #![feature(let_chains)] to the crate attributes to enable
45+
46+
error[E0658]: `let` expressions in this position are experimental
47+
--> $DIR/feature-gate.rs:30:17
48+
|
49+
LL | if true && (let 0 = 1) {}
50+
| ^^^^^^^^^
51+
|
52+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
53+
= help: add #![feature(let_chains)] to the crate attributes to enable
54+
55+
error[E0658]: `let` expressions in this position are experimental
56+
--> $DIR/feature-gate.rs:33:9
57+
|
58+
LL | if (let 0 = 1) && (let 0 = 1) {}
59+
| ^^^^^^^^^
60+
|
61+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
62+
= help: add #![feature(let_chains)] to the crate attributes to enable
63+
64+
error[E0658]: `let` expressions in this position are experimental
65+
--> $DIR/feature-gate.rs:33:24
66+
|
67+
LL | if (let 0 = 1) && (let 0 = 1) {}
68+
| ^^^^^^^^^
69+
|
70+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
71+
= help: add #![feature(let_chains)] to the crate attributes to enable
72+
73+
error[E0658]: `let` expressions in this position are experimental
74+
--> $DIR/feature-gate.rs:37:8
75+
|
76+
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
77+
| ^^^^^^^^^
78+
|
79+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
80+
= help: add #![feature(let_chains)] to the crate attributes to enable
81+
82+
error[E0658]: `let` expressions in this position are experimental
83+
--> $DIR/feature-gate.rs:37:21
84+
|
85+
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
86+
| ^^^^^^^^^
87+
|
88+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
89+
= help: add #![feature(let_chains)] to the crate attributes to enable
90+
91+
error[E0658]: `let` expressions in this position are experimental
92+
--> $DIR/feature-gate.rs:37:35
93+
|
94+
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
95+
| ^^^^^^^^^
96+
|
97+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
98+
= help: add #![feature(let_chains)] to the crate attributes to enable
99+
100+
error[E0658]: `let` expressions in this position are experimental
101+
--> $DIR/feature-gate.rs:37:48
102+
|
103+
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
104+
| ^^^^^^^^^
105+
|
106+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
107+
= help: add #![feature(let_chains)] to the crate attributes to enable
108+
109+
error[E0658]: `let` expressions in this position are experimental
110+
--> $DIR/feature-gate.rs:37:61
111+
|
112+
LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
113+
| ^^^^^^^^^
114+
|
115+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
116+
= help: add #![feature(let_chains)] to the crate attributes to enable
117+
118+
error[E0658]: `let` expressions in this position are experimental
119+
--> $DIR/feature-gate.rs:44:8
120+
|
121+
LL | if let Range { start: _, end: _ } = (true..true) && false {}
122+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
123+
|
124+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
125+
= help: add #![feature(let_chains)] to the crate attributes to enable
126+
127+
error[E0658]: `let` expressions in this position are experimental
128+
--> $DIR/feature-gate.rs:51:12
129+
|
130+
LL | while (let 0 = 1) {}
131+
| ^^^^^^^^^
132+
|
133+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
134+
= help: add #![feature(let_chains)] to the crate attributes to enable
135+
136+
error[E0658]: `let` expressions in this position are experimental
137+
--> $DIR/feature-gate.rs:54:14
138+
|
139+
LL | while (((let 0 = 1))) {}
140+
| ^^^^^^^^^
141+
|
142+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
143+
= help: add #![feature(let_chains)] to the crate attributes to enable
144+
145+
error[E0658]: `let` expressions in this position are experimental
146+
--> $DIR/feature-gate.rs:57:19
147+
|
148+
LL | while true && let 0 = 1 {}
149+
| ^^^^^^^^^
150+
|
151+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
152+
= help: add #![feature(let_chains)] to the crate attributes to enable
153+
154+
error[E0658]: `let` expressions in this position are experimental
155+
--> $DIR/feature-gate.rs:60:11
156+
|
157+
LL | while let 0 = 1 && true {}
158+
| ^^^^^^^^^
159+
|
160+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
161+
= help: add #![feature(let_chains)] to the crate attributes to enable
162+
163+
error[E0658]: `let` expressions in this position are experimental
164+
--> $DIR/feature-gate.rs:63:12
165+
|
166+
LL | while (let 0 = 1) && true {}
167+
| ^^^^^^^^^
168+
|
169+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
170+
= help: add #![feature(let_chains)] to the crate attributes to enable
171+
172+
error[E0658]: `let` expressions in this position are experimental
173+
--> $DIR/feature-gate.rs:66:20
174+
|
175+
LL | while true && (let 0 = 1) {}
176+
| ^^^^^^^^^
177+
|
178+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
179+
= help: add #![feature(let_chains)] to the crate attributes to enable
180+
181+
error[E0658]: `let` expressions in this position are experimental
182+
--> $DIR/feature-gate.rs:69:12
183+
|
184+
LL | while (let 0 = 1) && (let 0 = 1) {}
185+
| ^^^^^^^^^
186+
|
187+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
188+
= help: add #![feature(let_chains)] to the crate attributes to enable
189+
190+
error[E0658]: `let` expressions in this position are experimental
191+
--> $DIR/feature-gate.rs:69:27
192+
|
193+
LL | while (let 0 = 1) && (let 0 = 1) {}
194+
| ^^^^^^^^^
195+
|
196+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
197+
= help: add #![feature(let_chains)] to the crate attributes to enable
198+
199+
error[E0658]: `let` expressions in this position are experimental
200+
--> $DIR/feature-gate.rs:73:11
201+
|
202+
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
203+
| ^^^^^^^^^
204+
|
205+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
206+
= help: add #![feature(let_chains)] to the crate attributes to enable
207+
208+
error[E0658]: `let` expressions in this position are experimental
209+
--> $DIR/feature-gate.rs:73:24
210+
|
211+
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
212+
| ^^^^^^^^^
213+
|
214+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
215+
= help: add #![feature(let_chains)] to the crate attributes to enable
216+
217+
error[E0658]: `let` expressions in this position are experimental
218+
--> $DIR/feature-gate.rs:73:38
219+
|
220+
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
221+
| ^^^^^^^^^
222+
|
223+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
224+
= help: add #![feature(let_chains)] to the crate attributes to enable
225+
226+
error[E0658]: `let` expressions in this position are experimental
227+
--> $DIR/feature-gate.rs:73:51
228+
|
229+
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
230+
| ^^^^^^^^^
231+
|
232+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
233+
= help: add #![feature(let_chains)] to the crate attributes to enable
234+
235+
error[E0658]: `let` expressions in this position are experimental
236+
--> $DIR/feature-gate.rs:73:64
237+
|
238+
LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {}
239+
| ^^^^^^^^^
240+
|
241+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
242+
= help: add #![feature(let_chains)] to the crate attributes to enable
243+
244+
error[E0658]: `let` expressions in this position are experimental
245+
--> $DIR/feature-gate.rs:80:11
246+
|
247+
LL | while let Range { start: _, end: _ } = (true..true) && false {}
248+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
249+
|
250+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
251+
= help: add #![feature(let_chains)] to the crate attributes to enable
252+
253+
error[E0658]: `let` expressions in this position are experimental
254+
--> $DIR/feature-gate.rs:94:15
255+
|
256+
LL | use_expr!(let 0 = 1 && 0 == 0);
257+
| ^^^^^^^^^
258+
|
259+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
260+
= help: add #![feature(let_chains)] to the crate attributes to enable
261+
262+
error[E0658]: `let` expressions in this position are experimental
263+
--> $DIR/feature-gate.rs:96:16
264+
|
265+
LL | use_expr!((let 0 = 1));
266+
| ^^^^^^^^^
267+
|
268+
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
269+
= help: add #![feature(let_chains)] to the crate attributes to enable
270+
271+
error: `let` expressions only supported in `if`
272+
--> $DIR/feature-gate.rs:14:9
273+
|
274+
LL | if (let 0 = 1) {}
275+
| ^^^^^^^^^
276+
277+
error: aborting due to 31 previous errors
278+
279+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)