Skip to content

Commit 1ffea18

Browse files
committed
or-patterns: harden feature gating tests.
1 parent d3b3bce commit 1ffea18

File tree

2 files changed

+227
-2
lines changed

2 files changed

+227
-2
lines changed
Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![crate_type="lib"]
1+
fn main() {}
22

33
pub fn example(x: Option<usize>) {
44
match x {
@@ -7,3 +7,48 @@ pub fn example(x: Option<usize>) {
77
_ => {}
88
}
99
}
10+
11+
// Test the `pat` macro fragment parser:
12+
macro_rules! accept_pat {
13+
($p:pat) => {}
14+
}
15+
16+
accept_pat!((p | q)); //~ ERROR or-patterns syntax is experimental
17+
accept_pat!((p | q,)); //~ ERROR or-patterns syntax is experimental
18+
accept_pat!(TS(p | q)); //~ ERROR or-patterns syntax is experimental
19+
accept_pat!(NS { f: p | q }); //~ ERROR or-patterns syntax is experimental
20+
accept_pat!([p | q]); //~ ERROR or-patterns syntax is experimental
21+
22+
// Non-macro tests:
23+
24+
#[cfg(FALSE)]
25+
fn or_patterns() {
26+
// Gated:
27+
28+
let | A | B; //~ ERROR or-patterns syntax is experimental
29+
//~^ ERROR or-patterns syntax is experimental
30+
let A | B; //~ ERROR or-patterns syntax is experimental
31+
for | A | B in 0 {} //~ ERROR or-patterns syntax is experimental
32+
//~^ ERROR or-patterns syntax is experimental
33+
for A | B in 0 {} //~ ERROR or-patterns syntax is experimental
34+
fn fun((A | B): _) {} //~ ERROR or-patterns syntax is experimental
35+
let _ = |(A | B): u8| (); //~ ERROR or-patterns syntax is experimental
36+
let (A | B); //~ ERROR or-patterns syntax is experimental
37+
let (A | B,); //~ ERROR or-patterns syntax is experimental
38+
let A(B | C); //~ ERROR or-patterns syntax is experimental
39+
let E::V(B | C); //~ ERROR or-patterns syntax is experimental
40+
let S { f1: B | C, f2 }; //~ ERROR or-patterns syntax is experimental
41+
let E::V { f1: B | C, f2 }; //~ ERROR or-patterns syntax is experimental
42+
let [A | B]; //~ ERROR or-patterns syntax is experimental
43+
44+
// Top level of `while`, `if`, and `match` arms are allowed:
45+
46+
while let | A = 0 {}
47+
while let A | B = 0 {}
48+
if let | A = 0 {}
49+
if let A | B = 0 {}
50+
match 0 {
51+
| A => {},
52+
A | B => {},
53+
}
54+
}

src/test/ui/or-patterns/feature-gate-or_patterns.stderr

Lines changed: 181 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,186 @@ LL | Some(0 | 1 | 2) => {}
77
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
88
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
99

10-
error: aborting due to previous error
10+
error[E0658]: or-patterns syntax is experimental
11+
--> $DIR/feature-gate-or_patterns.rs:28:9
12+
|
13+
LL | let | A | B;
14+
| ^
15+
|
16+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
17+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
18+
19+
error[E0658]: or-patterns syntax is experimental
20+
--> $DIR/feature-gate-or_patterns.rs:28:11
21+
|
22+
LL | let | A | B;
23+
| ^^^^^
24+
|
25+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
26+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
27+
28+
error[E0658]: or-patterns syntax is experimental
29+
--> $DIR/feature-gate-or_patterns.rs:30:9
30+
|
31+
LL | let A | B;
32+
| ^^^^^
33+
|
34+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
35+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
36+
37+
error[E0658]: or-patterns syntax is experimental
38+
--> $DIR/feature-gate-or_patterns.rs:31:9
39+
|
40+
LL | for | A | B in 0 {}
41+
| ^
42+
|
43+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
44+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
45+
46+
error[E0658]: or-patterns syntax is experimental
47+
--> $DIR/feature-gate-or_patterns.rs:31:11
48+
|
49+
LL | for | A | B in 0 {}
50+
| ^^^^^
51+
|
52+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
53+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
54+
55+
error[E0658]: or-patterns syntax is experimental
56+
--> $DIR/feature-gate-or_patterns.rs:33:9
57+
|
58+
LL | for A | B in 0 {}
59+
| ^^^^^
60+
|
61+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
62+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
63+
64+
error[E0658]: or-patterns syntax is experimental
65+
--> $DIR/feature-gate-or_patterns.rs:34:13
66+
|
67+
LL | fn fun((A | B): _) {}
68+
| ^^^^^
69+
|
70+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
71+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
72+
73+
error[E0658]: or-patterns syntax is experimental
74+
--> $DIR/feature-gate-or_patterns.rs:35:15
75+
|
76+
LL | let _ = |(A | B): u8| ();
77+
| ^^^^^
78+
|
79+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
80+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
81+
82+
error[E0658]: or-patterns syntax is experimental
83+
--> $DIR/feature-gate-or_patterns.rs:36:10
84+
|
85+
LL | let (A | B);
86+
| ^^^^^
87+
|
88+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
89+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
90+
91+
error[E0658]: or-patterns syntax is experimental
92+
--> $DIR/feature-gate-or_patterns.rs:37:10
93+
|
94+
LL | let (A | B,);
95+
| ^^^^^
96+
|
97+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
98+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
99+
100+
error[E0658]: or-patterns syntax is experimental
101+
--> $DIR/feature-gate-or_patterns.rs:38:11
102+
|
103+
LL | let A(B | C);
104+
| ^^^^^
105+
|
106+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
107+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
108+
109+
error[E0658]: or-patterns syntax is experimental
110+
--> $DIR/feature-gate-or_patterns.rs:39:14
111+
|
112+
LL | let E::V(B | C);
113+
| ^^^^^
114+
|
115+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
116+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
117+
118+
error[E0658]: or-patterns syntax is experimental
119+
--> $DIR/feature-gate-or_patterns.rs:40:17
120+
|
121+
LL | let S { f1: B | C, f2 };
122+
| ^^^^^
123+
|
124+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
125+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
126+
127+
error[E0658]: or-patterns syntax is experimental
128+
--> $DIR/feature-gate-or_patterns.rs:41:20
129+
|
130+
LL | let E::V { f1: B | C, f2 };
131+
| ^^^^^
132+
|
133+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
134+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
135+
136+
error[E0658]: or-patterns syntax is experimental
137+
--> $DIR/feature-gate-or_patterns.rs:42:10
138+
|
139+
LL | let [A | B];
140+
| ^^^^^
141+
|
142+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
143+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
144+
145+
error[E0658]: or-patterns syntax is experimental
146+
--> $DIR/feature-gate-or_patterns.rs:16:14
147+
|
148+
LL | accept_pat!((p | q));
149+
| ^^^^^
150+
|
151+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
152+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
153+
154+
error[E0658]: or-patterns syntax is experimental
155+
--> $DIR/feature-gate-or_patterns.rs:17:14
156+
|
157+
LL | accept_pat!((p | q,));
158+
| ^^^^^
159+
|
160+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
161+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
162+
163+
error[E0658]: or-patterns syntax is experimental
164+
--> $DIR/feature-gate-or_patterns.rs:18:16
165+
|
166+
LL | accept_pat!(TS(p | q));
167+
| ^^^^^
168+
|
169+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
170+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
171+
172+
error[E0658]: or-patterns syntax is experimental
173+
--> $DIR/feature-gate-or_patterns.rs:19:21
174+
|
175+
LL | accept_pat!(NS { f: p | q });
176+
| ^^^^^
177+
|
178+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
179+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
180+
181+
error[E0658]: or-patterns syntax is experimental
182+
--> $DIR/feature-gate-or_patterns.rs:20:14
183+
|
184+
LL | accept_pat!([p | q]);
185+
| ^^^^^
186+
|
187+
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
188+
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
189+
190+
error: aborting due to 21 previous errors
11191

12192
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)