Skip to content

Commit a3bb9fb

Browse files
Add & bless tests
1 parent 91bc117 commit a3bb9fb

9 files changed

+221
-36
lines changed

src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ fn foo() {
1111
//~| ERROR range-to patterns with `...` are not allowed
1212
if let ..5 = 0 {}
1313
//~^ ERROR half-open range patterns are unstable
14-
if let 5.. = 0 {}
15-
//~^ ERROR half-open range patterns are unstable
1614
if let 5..= = 0 {}
17-
//~^ ERROR half-open range patterns are unstable
18-
//~| ERROR inclusive range with no end
15+
//~^ ERROR inclusive range with no end
1916
if let 5... = 0 {}
20-
//~^ ERROR half-open range patterns are unstable
21-
//~| ERROR inclusive range with no end
17+
//~^ ERROR inclusive range with no end
2218
}

src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr

+3-30
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ LL | if let ...5 = 0 {}
55
| ^^^ help: use `..=` instead
66

77
error[E0586]: inclusive range with no end
8-
--> $DIR/feature-gate-half-open-range-patterns.rs:16:13
8+
--> $DIR/feature-gate-half-open-range-patterns.rs:14:13
99
|
1010
LL | if let 5..= = 0 {}
1111
| ^^^ help: use `..` instead
1212
|
1313
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
1414

1515
error[E0586]: inclusive range with no end
16-
--> $DIR/feature-gate-half-open-range-patterns.rs:19:13
16+
--> $DIR/feature-gate-half-open-range-patterns.rs:16:13
1717
|
1818
LL | if let 5... = 0 {}
1919
| ^^^ help: use `..` instead
@@ -47,34 +47,7 @@ LL | if let ..5 = 0 {}
4747
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
4848
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
4949

50-
error[E0658]: half-open range patterns are unstable
51-
--> $DIR/feature-gate-half-open-range-patterns.rs:14:12
52-
|
53-
LL | if let 5.. = 0 {}
54-
| ^^^
55-
|
56-
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
57-
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
58-
59-
error[E0658]: half-open range patterns are unstable
60-
--> $DIR/feature-gate-half-open-range-patterns.rs:16:12
61-
|
62-
LL | if let 5..= = 0 {}
63-
| ^^^^
64-
|
65-
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
66-
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
67-
68-
error[E0658]: half-open range patterns are unstable
69-
--> $DIR/feature-gate-half-open-range-patterns.rs:19:12
70-
|
71-
LL | if let 5... = 0 {}
72-
| ^^^^
73-
|
74-
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
75-
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
76-
77-
error: aborting due to 9 previous errors
50+
error: aborting due to 6 previous errors
7851

7952
Some errors have detailed explanations: E0586, E0658.
8053
For more information about an error, try `rustc --explain E0586`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// run-pass
2+
#![allow(incomplete_features)]
3+
#![feature(exclusive_range_pattern)]
4+
#![feature(half_open_range_patterns)]
5+
#![feature(inline_const)]
6+
7+
fn main() {
8+
let mut if_lettable = vec![];
9+
let mut first_or = vec![];
10+
let mut or_two = vec![];
11+
let mut range_from = vec![];
12+
let mut bottom = vec![];
13+
14+
for x in -9 + 1..=(9 - 2) {
15+
if let -1..=0 | 2..3 | 4 = x {
16+
if_lettable.push(x)
17+
}
18+
match x {
19+
1 | -3..0 => first_or.push(x),
20+
y @ (0..5 | 6) => or_two.push(y),
21+
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
22+
y @ -5.. => range_from.push(y),
23+
y @ ..-7 => assert_eq!(y, -8),
24+
y => bottom.push(y),
25+
}
26+
}
27+
assert_eq!(if_lettable, [-1, 0, 2, 4]);
28+
assert_eq!(first_or, [-3, -2, -1, 1]);
29+
assert_eq!(or_two, [0, 2, 3, 4, 6]);
30+
assert_eq!(range_from, [-5, -4, 7]);
31+
assert_eq!(bottom, [-7, -6]);
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
fn main() {
2+
let mut if_lettable = Vec::<i32>::new();
3+
let mut first_or = Vec::<i32>::new();
4+
let mut or_two = Vec::<i32>::new();
5+
let mut range_from = Vec::<i32>::new();
6+
let mut bottom = Vec::<i32>::new();
7+
let mut errors_only = Vec::<i32>::new();
8+
9+
for x in -9 + 1..=(9 - 2) {
10+
if let n @ 2..3|4 = x {
11+
//~^ error: variable `n` is not bound in all patterns
12+
//~| exclusive range pattern syntax is experimental
13+
errors_only.push(x);
14+
} else if let 2..3 | 4 = x {
15+
//~^ exclusive range pattern syntax is experimental
16+
if_lettable.push(x);
17+
}
18+
match x as i32 {
19+
0..5+1 => errors_only.push(x),
20+
//~^ error: expected one of `=>`, `if`, or `|`, found `+`
21+
1 | -3..0 => first_or.push(x),
22+
y @ (0..5 | 6) => or_two.push(y),
23+
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
24+
y @ -5.. => range_from.push(y),
25+
y @ ..-7 => assert_eq!(y, -8),
26+
y => bottom.push(y),
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error: expected one of `=>`, `if`, or `|`, found `+`
2+
--> $DIR/range_pat_interactions1.rs:19:17
3+
|
4+
LL | 0..5+1 => errors_only.push(x),
5+
| ^ expected one of `=>`, `if`, or `|`
6+
7+
error[E0408]: variable `n` is not bound in all patterns
8+
--> $DIR/range_pat_interactions1.rs:10:25
9+
|
10+
LL | if let n @ 2..3|4 = x {
11+
| - ^ pattern doesn't bind `n`
12+
| |
13+
| variable not in all patterns
14+
15+
error[E0658]: exclusive range pattern syntax is experimental
16+
--> $DIR/range_pat_interactions1.rs:10:20
17+
|
18+
LL | if let n @ 2..3|4 = x {
19+
| ^^^^
20+
|
21+
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
22+
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
23+
24+
error[E0658]: exclusive range pattern syntax is experimental
25+
--> $DIR/range_pat_interactions1.rs:14:23
26+
|
27+
LL | } else if let 2..3 | 4 = x {
28+
| ^^^^
29+
|
30+
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
31+
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
32+
33+
error: aborting due to 4 previous errors
34+
35+
Some errors have detailed explanations: E0408, E0658.
36+
For more information about an error, try `rustc --explain E0408`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
fn main() {
2+
let mut first_or = Vec::<i32>::new();
3+
let mut or_two = Vec::<i32>::new();
4+
let mut range_from = Vec::<i32>::new();
5+
let mut bottom = Vec::<i32>::new();
6+
let mut errors_only = Vec::<i32>::new();
7+
8+
for x in -9 + 1..=(9 - 2) {
9+
match x as i32 {
10+
0..=(5+1) => errors_only.push(x),
11+
//~^ error: inclusive range with no end
12+
//~| error: expected one of `=>`, `if`, or `|`, found `(`
13+
1 | -3..0 => first_or.push(x),
14+
y @ (0..5 | 6) => or_two.push(y),
15+
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
16+
y @ -5.. => range_from.push(y),
17+
y @ ..-7 => assert_eq!(y, -8),
18+
y => bottom.push(y),
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0586]: inclusive range with no end
2+
--> $DIR/range_pat_interactions2.rs:10:14
3+
|
4+
LL | 0..=(5+1) => errors_only.push(x),
5+
| ^^^ help: use `..` instead
6+
|
7+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
8+
9+
error: expected one of `=>`, `if`, or `|`, found `(`
10+
--> $DIR/range_pat_interactions2.rs:10:17
11+
|
12+
LL | 0..=(5+1) => errors_only.push(x),
13+
| ^ expected one of `=>`, `if`, or `|`
14+
15+
error: aborting due to 2 previous errors
16+
17+
For more information about this error, try `rustc --explain E0586`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fn main() {
2+
let mut first_or = Vec::<i32>::new();
3+
let mut or_two = Vec::<i32>::new();
4+
let mut range_from = Vec::<i32>::new();
5+
let mut bottom = Vec::<i32>::new();
6+
7+
for x in -9 + 1..=(9 - 2) {
8+
match x as i32 {
9+
8.. => bottom.push(x),
10+
1 | -3..0 => first_or.push(x),
11+
//~^ exclusive range pattern syntax is experimental
12+
y @ (0..5 | 6) => or_two.push(y),
13+
//~^ exclusive range pattern syntax is experimental
14+
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
15+
//~^ inline-const is experimental
16+
//~| exclusive range pattern syntax is experimental
17+
y @ -5.. => range_from.push(y),
18+
y @ ..-7 => assert_eq!(y, -8),
19+
//~^ half-open range patterns are unstable
20+
//~| exclusive range pattern syntax is experimental
21+
y => bottom.push(y),
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
error[E0658]: half-open range patterns are unstable
2+
--> $DIR/range_pat_interactions3.rs:18:17
3+
|
4+
LL | y @ ..-7 => assert_eq!(y, -8),
5+
| ^^^^
6+
|
7+
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
8+
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
9+
10+
error[E0658]: inline-const is experimental
11+
--> $DIR/range_pat_interactions3.rs:14:20
12+
|
13+
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
14+
| ^^^^^
15+
|
16+
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
17+
= help: add `#![feature(inline_const)]` to the crate attributes to enable
18+
19+
error[E0658]: exclusive range pattern syntax is experimental
20+
--> $DIR/range_pat_interactions3.rs:10:17
21+
|
22+
LL | 1 | -3..0 => first_or.push(x),
23+
| ^^^^^
24+
|
25+
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
26+
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
27+
28+
error[E0658]: exclusive range pattern syntax is experimental
29+
--> $DIR/range_pat_interactions3.rs:12:18
30+
|
31+
LL | y @ (0..5 | 6) => or_two.push(y),
32+
| ^^^^
33+
|
34+
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
35+
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
36+
37+
error[E0658]: exclusive range pattern syntax is experimental
38+
--> $DIR/range_pat_interactions3.rs:14:17
39+
|
40+
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
41+
| ^^^^^^^^^^^^^^^^^^
42+
|
43+
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
44+
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
45+
46+
error[E0658]: exclusive range pattern syntax is experimental
47+
--> $DIR/range_pat_interactions3.rs:18:17
48+
|
49+
LL | y @ ..-7 => assert_eq!(y, -8),
50+
| ^^^^
51+
|
52+
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
53+
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
54+
55+
error: aborting due to 6 previous errors
56+
57+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)